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

Fix reload_config failed on M0 device because PFCWD feature does not exist #14138

Merged

Conversation

liuh-80
Copy link
Contributor

@liuh-80 liuh-80 commented Aug 15, 2024

Fix reload_config failed on M0 device because PFCWD feature does not exist

Why I did it

test case test_fallback_to_local_authorization_with_config_reload failed on M0 device when reload config.
It's because PFCWD feature does not exist on M0.

Work item tracking
  • Microsoft ADO: 28794363

How I did it

Ignore check when PFCWD feature not enable on device.

How to verify it

Pass all test case.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Fix reload_config failed on M0 device because PFCWD feature does not exist

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Failed
- hook id: check-ast
- exit code: 1

tests/common/config_reload.py: failed parsing with CPython 3.10.12:

Traceback (most recent call last):
File "/home/AzDevOps/.cache/pre-commit/repobw5yv0k7/py_env-python3/lib/python3.10/site-packages/pre_commit_hooks/check_ast.py", line 21, in main
ast.parse(f.read(), filename=filename)
File "/usr/lib/python3.10/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "tests/common/config_reload.py", line 207
if config_source == 'minigraph' && pfcwd_feature_enabled(sonic_host):
^
SyntaxError: invalid syntax
...
[truncated extra lines, please run pre-commit locally to view full check results]

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@liuh-80 liuh-80 marked this pull request as ready for review August 21, 2024 10:29
@liuh-80 liuh-80 requested a review from Blueve August 21, 2024 10:29
@@ -105,6 +106,13 @@ def config_reload_minigraph_with_rendered_golden_config_override(
override_config=True, golden_config_path=golden_config_path, is_dut=is_dut)


def pfcwd_feature_enabled(duthost):
localhost_config = duthost.shell('sonic-db-dump -n CONFIG_DB -y -k \"DEVICE_METADATA|localhost\"')
meta_data = json.loads(localhost_config["stdout"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency purposes, it might be better to use duthost.config_facts(host=duthost.hostname, source="running")['ansible_facts']['DEVICE_METADATA']['localhost']. (This also protects against an old image running where sonic-db-dump isn't available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/common/config_reload.py:1:1: F401 'json' imported but unused
tests/common/config_reload.py:110:121: E501 line too long (133 > 120 characters)

flake8...............................................(no files to check)Skipped
check conditional mark sort..........................(no files to check)Skipped

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-mgmt

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@qiluo-msft qiluo-msft merged commit 994d265 into sonic-net:master Sep 6, 2024
16 checks passed
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Sep 6, 2024
…exist (sonic-net#14138)

Fix reload_config failed on M0 device because PFCWD feature does not exist

#### Why I did it
test case test_fallback_to_local_authorization_with_config_reload failed on M0 device when reload config.
It's because PFCWD feature does not exist on M0.

### How I did it
Ignore check when PFCWD feature not enable on device.

#### How to verify it
Pass all test case.

### Description for the changelog
Fix reload_config failed on M0 device because PFCWD feature does not exist
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202405: #14446

@mssonicbld
Copy link
Collaborator

@liuh-80 PR conflicts with 202311 branch

@mssonicbld
Copy link
Collaborator

@liuh-80 PR conflicts with 202305 branch

mssonicbld pushed a commit that referenced this pull request Sep 6, 2024
…exist (#14138)

Fix reload_config failed on M0 device because PFCWD feature does not exist

#### Why I did it
test case test_fallback_to_local_authorization_with_config_reload failed on M0 device when reload config.
It's because PFCWD feature does not exist on M0.

### How I did it
Ignore check when PFCWD feature not enable on device.

#### How to verify it
Pass all test case.

### Description for the changelog
Fix reload_config failed on M0 device because PFCWD feature does not exist
hdwhdw pushed a commit to hdwhdw/sonic-mgmt that referenced this pull request Sep 20, 2024
…exist (sonic-net#14138)

Fix reload_config failed on M0 device because PFCWD feature does not exist

#### Why I did it
test case test_fallback_to_local_authorization_with_config_reload failed on M0 device when reload config.
It's because PFCWD feature does not exist on M0.

### How I did it
Ignore check when PFCWD feature not enable on device.

#### How to verify it
Pass all test case.

### Description for the changelog
Fix reload_config failed on M0 device because PFCWD feature does not exist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants