Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PFC] pfc config commands lead to traceback due to KeyError #20398

Closed
gpunathilell opened this issue Oct 1, 2024 · 2 comments · Fixed by sonic-net/sonic-utilities#3563
Closed

Comments

@gpunathilell
Copy link
Contributor

gpunathilell commented Oct 1, 2024

Description

After addition of the following PR in sonic-utilities sonic-net/sonic-utilities#3521 pfc config commands fail with the following error KeyError: 'UTILITIES_UNIT_TESTING' due to the UTILITIES_UNIT_TESTING environment variable not being configured. This variable is being accessed in the dump_config_to_json function as shown here

Steps to reproduce the issue:

  1. Deploy latest master image with updated sonic-utilities
  2. Execute pfc config command (Ex: pfc config assymmetric on Ethernet64)

Describe the results you received:

root@sonic:~# pfc config asymmetric on Ethernet64
Traceback (most recent call last):
  File "/usr/local/bin/pfc", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pfc/main.py", line 167, in configAsym
    Pfc(namespace).configPfcAsym(interface, status)
  File "/usr/local/lib/python3.11/dist-packages/utilities_common/multi_asic.py", line 156, in wrapped_run_on_all_asics
    func(self,  *args, **kwargs)
  File "/usr/local/lib/python3.11/dist-packages/pfc/main.py", line 47, in configPfcAsym
    self.dump_config_to_json(PORT_TABLE_NAME, self.multi_asic.current_namespace)
  File "/usr/local/lib/python3.11/dist-packages/pfc/main.py", line 31, in dump_config_to_json
    if os.environ["UTILITIES_UNIT_TESTING"] != "2":
       ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 679, in __getitem__
KeyError: 'UTILITIES_UNIT_TESTING'

Describe the results you expected:

No traceback should appear

Additional information you deem important (e.g. issue happens only occasionally):

Issue can be solved by handling the call in a try except block as shown here and here or use the get method

@dgsudharsan
Copy link
Collaborator

@arista-hpandya Can you please prioritize fixing this? @prsunny @qiluo-msft for visibility

@arista-hpandya
Copy link

Fix included in the linked PR. Thank you for catching this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants