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

Fixes: #409 #410

Merged
merged 4 commits into from
Jul 2, 2024
Merged

Fixes: #409 #410

merged 4 commits into from
Jul 2, 2024

Conversation

TafkaMax
Copy link
Contributor

@TafkaMax TafkaMax commented Jul 1, 2024

SUMMARY
GitHub Issues

List the GitHub issues impacted by this PR. If no Github issues are affected, please indicate this with "N/A".

GitHub Issue #
#409
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

sonic_l2_interfaces

OUTPUT
changed: [sonic-dell-test-02] => {
    "after": [
        {
            "access": {
                "vlan": 12
            },
            "name": "Ethernet4"
        }
    ],
    "before": [],
    "changed": true,
    "commands": [
        {
            "access": {
                "vlan": 12
            },
            "name": "Ethernet4",
            "state": "merged"
        }
    ],
    "diff": [
        "*** before",
        "--- after",
        "***************",
        "*** 1 ****",
        "! []",
        "--- 1,8 ----",
        "! [",
        "!     {",
        "!         'access': {",
        "!             'vlan': 12",
        "!         },",
        "!         'name': 'Ethernet4'",
        "!     }",
        "! ]"
    ],
    "invocation": {
        "module_args": {
            "config": [
                {
                    "access": {
                        "vlan": 12
                    },
                    "name": "Ethernet4",
                    "trunk": null
                }
            ],
            "state": "merged"
        }
    }
}
ADDITIONAL INFORMATION

Checklist:
  • I have performed a self-review of my own code to ensure there are no formatting, linting, or security issues
  • I have verified that new and existing unit tests pass locally with my changes
  • I have not allowed coverage numbers to degenerate
  • I have maintained at least 90% code coverage
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have maintained backward compatibility or have provided any relevant "breaking_changes" descriptions in a "fragment" file in the "changelogs/fragments" directory of this repository.
  • I have provided a summary for this PR in valid "fragment" file format in the "changelogs/fragments" directory of this repository branch. Reference : Ansible Change Log Document
How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Copy link
Collaborator

@kerry-meyer kerry-meyer left a comment

Choose a reason for hiding this comment

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

Thank you for notifying us of this problem and for taking the additional initiative to provide a fix for the problem.

Although this situation should never occur with a hardware switch (or any switch), regardless of the initial state, we have seen a similar problem occur in the past with GNS3 'interfaces' configuration due to invalid GNS3 output for some of the interfaces in a bulk REST 'GET' of 'interfaces' configuration. (There is a bug in the GNS3 drivers related to this, because any interface that exists, should at least have configuration containing the 'name' of the interface, but this is sometimes absent for GNS3 switches.)

This looks like a related cause.

Because there is another direct access to a dict member that could, theoretically, not exist in the first instruction of the 'for intf in interfaces:' loop, we should add protection there along with the protection that you have proposed in this PR.

Please add this as well by also changing the following instructions from:

       for intf in interfaces:  
           name = intf['name']

to:

        for intf in interfaces:  
            name = intf.get('name')
            if not name:
                continue

I have one additional request to make the content of this PR conformant to the criteria enforced by our 'sanity' checks that must pass before merging for each PR:

Please add a 'changelog' fragment for this fix. This is a file containing two lines describing the fix category and what the fix does. It is needed in the 'changelogs/fragments' directory of the repo. It generates a corresponding entry in our release notes when we include the fix in our next release. You can see other examples that have already been placed in that directory for reference on the format of the changelog file.

For this fix, it would be fine to put the following content in the "410-sonic_l2_interfaces-fix-facts-exception.yaml" file:

---   
bugfixes:
  - sonic_l2_interfaces - Fix exception when gathering facts (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/410).

          

@TafkaMax
Copy link
Contributor Author

TafkaMax commented Jul 2, 2024

Added the changes.

Thank you for the quick response! I was thinking this was a GNS3 or the Virtual Switch related, because it seemed to be such a weird bug.

EDIT: Also ran my playbook with the last changes as well to verify it was still OK.

Copy link
Collaborator

@kerry-meyer kerry-meyer left a comment

Choose a reason for hiding this comment

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

Thank you for making these incremental changes.

The current proposed code changes and corresponding sanity test results look good.

Thank you very much for your help in identifying this problem and providing the fix for it.

Approved.

@kerry-meyer kerry-meyer merged commit 59d321e into ansible-collections:main Jul 2, 2024
15 checks passed
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 this pull request may close these issues.

2 participants