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

vyos.ifconfig: T7018: drop 'iftype' class attribute #4280

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

c-po
Copy link
Member

@c-po c-po commented Jan 5, 2025

Under very rare cases we can run into a race condition where interfaces are still in creation phase but are already referenced..

This can trigger:

  File "/usr/libexec/vyos/conf_mode/system_conntrack.py", line 270, in <module>
    apply(c)
  File "/usr/libexec/vyos/conf_mode/system_conntrack.py", line 249, in apply
    call_dependents()
  File "/usr/lib/python3/dist-packages/vyos/configdep.py", line 147, in call_dependents
    f()
  File "/usr/lib/python3/dist-packages/vyos/configdep.py", line 118, in func_impl
    run_config_mode_script(script, config)
  File "/usr/lib/python3/dist-packages/vyos/configdep.py", line 106, in run_config_mode_script
    mod.verify(c)
  File "/usr/libexec/vyos//conf_mode/service_conntrack-sync.py", line 72, in verify
    if len(get_ipv4(interface)) < 1:
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/template.py", line 458, in get_ipv4
    return Interface(interface).get_addr_v4()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 334, in __init__
    if not self.iftype:
    ^^^^^^^^^^^

  AttributeError: 'Interface' object has no attribute 'iftype'

This commit removes the code path in question and the class attribute check. The reason for the iftype attribute in the past was a common _create() method serving for all interface types. As we already have a lot of derived implementations and not all honor the classes iftype/type member - or even worse honor it only in 50% of the occurrences it's time to drop it.

Change summary

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

How to test / Smoketest result

image

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

Under very rare cases we can run into a race condition where interfaces are
still in creation phase but are already referenced..

This can trigger:

  File "/usr/libexec/vyos/conf_mode/system_conntrack.py", line 270, in <module>
    apply(c)
  File "/usr/libexec/vyos/conf_mode/system_conntrack.py", line 249, in apply
    call_dependents()
  File "/usr/lib/python3/dist-packages/vyos/configdep.py", line 147, in call_dependents
    f()
  File "/usr/lib/python3/dist-packages/vyos/configdep.py", line 118, in func_impl
    run_config_mode_script(script, config)
  File "/usr/lib/python3/dist-packages/vyos/configdep.py", line 106, in run_config_mode_script
    mod.verify(c)
  File "/usr/libexec/vyos//conf_mode/service_conntrack-sync.py", line 72, in verify
    if len(get_ipv4(interface)) < 1:
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/template.py", line 458, in get_ipv4
    return Interface(interface).get_addr_v4()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 334, in __init__
    if not self.iftype:
    ^^^^^^^^^^^

  AttributeError: 'Interface' object has no attribute 'iftype'

This commit removes the code path in question and the class attribute check.
The reason for the iftype attribute in the past was a common _create() method
serving for all interface types. As we already have a lot of derived
implementations and not all honor the classes iftype/type member - or even
worse honor it only in 50% of the occurrences it's time to drop it.
Copy link

github-actions bot commented Jan 5, 2025

👍
No issues in PR Title / Commit Title

Copy link

github-actions bot commented Jan 5, 2025

CI integration ❌ failed!

Details

CI logs

  • CLI Smoketests (no interfaces) ❌ failed
  • CLI Smoketests (interfaces only) 👍 passed
  • Config tests 👍 passed
  • RAID1 tests 👍 passed
  • TPM tests 👍 passed

@c-po
Copy link
Member Author

c-po commented Jan 5, 2025

Unrelated ddclient error

image

@sever-sever sever-sever merged commit 08c0054 into vyos:current Jan 7, 2025
14 of 16 checks passed
@c-po c-po deleted the no-iftype branch January 7, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants