Skip to content

Fix PR #9312 for KeyError and AttributeError#9523

Merged
yutongzhang-microsoft merged 6 commits intosonic-net:masterfrom
yutongzhang-microsoft:yutongzhang/fix_PR_9312
Aug 21, 2023
Merged

Fix PR #9312 for KeyError and AttributeError#9523
yutongzhang-microsoft merged 6 commits intosonic-net:masterfrom
yutongzhang-microsoft:yutongzhang/fix_PR_9312

Conversation

@yutongzhang-microsoft
Copy link
Copy Markdown
Contributor

@yutongzhang-microsoft yutongzhang-microsoft commented Aug 17, 2023

Description of PR

PR #9312 will try to get DATAACL in running config in fixture recover_acl_rule. But if param enable_data_acl is set false when deploying minigraph, DATAACL will not appear in running config. Which may cause key error in fixture recover_acl_rule. In this PR, we fix this issue.

Summary:
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911
  • 202012
  • 202205

Approach

What is the motivation for this PR?

PR #9312 will try to get DATAACL in running config in fixture recover_acl_rule. But if param enable_data_acl is set false when deploying minigraph, DATAACL will not appear in running config. Which may cause key error in fixture recover_acl_rule. In this PR, we fix this issue.

How did you do it?

Run TC on testbed which enable_data_acl is false when deploying minigraph.

How did you verify/test it?

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It would be more pythonic to use code like this:

    pre_acl_rules = acl_facts.get("DATAACL", {}).get("rules", None)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, so pythonic

wangxin
wangxin previously approved these changes Aug 17, 2023
@yutongzhang-microsoft yutongzhang-microsoft changed the title Fix PR #9312 for key error. Fix PR #9312 for KeyError and AttributeError Aug 17, 2023
wangxin
wangxin previously approved these changes Aug 17, 2023
@wangxin
Copy link
Copy Markdown
Collaborator

wangxin commented Aug 17, 2023

@yutongzhang-microsoft Got new merge conflicts. Can you check?

@mssonicbld
Copy link
Copy Markdown
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.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/common/utilities.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed
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>

bingwang-ms
bingwang-ms previously approved these changes Aug 17, 2023
@mssonicbld
Copy link
Copy Markdown
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.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/common/utilities.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed
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>

@yutongzhang-microsoft
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
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.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/common/utilities.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed
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
Copy Markdown
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.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/common/utilities.py

fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Passed
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>

@yutongzhang-microsoft yutongzhang-microsoft merged commit b1f9123 into sonic-net:master Aug 21, 2023
@yutongzhang-microsoft yutongzhang-microsoft deleted the yutongzhang/fix_PR_9312 branch August 21, 2023 01:55
@mssonicbld
Copy link
Copy Markdown
Collaborator

@yutongzhang-microsoft PR conflicts with 202012 branch

@mssonicbld
Copy link
Copy Markdown
Collaborator

@yutongzhang-microsoft PR conflicts with 202305 branch

@mssonicbld
Copy link
Copy Markdown
Collaborator

@yutongzhang-microsoft PR conflicts with 202205 branch

yutongzhang-microsoft added a commit to yutongzhang-microsoft/sonic-mgmt that referenced this pull request Aug 22, 2023
yutongzhang-microsoft added a commit to yutongzhang-microsoft/sonic-mgmt that referenced this pull request Aug 22, 2023
yutongzhang-microsoft added a commit to yutongzhang-microsoft/sonic-mgmt that referenced this pull request Aug 22, 2023
StormLiangMS pushed a commit that referenced this pull request Aug 23, 2023
yutongzhang-microsoft added a commit that referenced this pull request Aug 23, 2023
…02012 (#9590)

Description of PR
Cherry pick conflict #9523 and #9312

Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
wangxin pushed a commit that referenced this pull request Aug 28, 2023
AharonMalkin pushed a commit to AharonMalkin/sonic-mgmt that referenced this pull request Jan 25, 2024
Description of PR
PR sonic-net#9312 will try to get DATAACL in running config in fixture recover_acl_rule. But if param enable_data_acl is set false when deploying minigraph, DATAACL will not appear in running config. Which may cause key error in fixture recover_acl_rule. In this PR, we fix this issue.

What is the motivation for this PR?
PR sonic-net#9312 will try to get DATAACL in running config in fixture recover_acl_rule. But if param enable_data_acl is set false when deploying minigraph, DATAACL will not appear in running config. Which may cause key error in fixture recover_acl_rule. In this PR, we fix this issue.

How did you do it?
Run TC on testbed which enable_data_acl is false when deploying minigraph.

Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
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.

6 participants