Skip to content

Handle non-resolvable deferred interfaces in dcnm_interface#663

Open
dacasti2mx wants to merge 1 commit intoCiscoDevNet:developfrom
dacasti2mx:fix/deletable-false-underlaypolicies-null
Open

Handle non-resolvable deferred interfaces in dcnm_interface#663
dacasti2mx wants to merge 1 commit intoCiscoDevNet:developfrom
dacasti2mx:fix/deletable-false-underlaypolicies-null

Conversation

@dacasti2mx
Copy link
Copy Markdown

Fixes #658

Summary

This change fixes a crash in dcnm_interface during state=overridden when the module processes non-deletable Ethernet interfaces returned by NDFC without a resolvable underlay policy source.

Problem

In the deferred override flow, the module assumes that every non-deletable Ethernet interface has:

underlayPolicies[0]["source"]

That is not always true.

With NDFC 4.2, ISN and External fabrics can return physical Ethernet interfaces with:

  • deletable: false
  • underlayPolicies: null

When those interfaces enter the deferred path, the module crashes with:

TypeError: 'NoneType' object is not subscriptable

Root Cause

The deferred flow treats all deletable=false Ethernet interfaces as if they were resolvable later via underlayPolicies[].source.

That assumption is invalid for protected or unmanaged Ethernet interfaces in ISN and External fabrics.

Changes

  • Added a helper to safely extract a usable underlay policy source
  • Added a helper to record non-resolvable deferred interfaces under diff.skipped
  • Updated the override flow so that Ethernet interfaces are only added to deferred when:
    • deletable == false, and
    • a valid underlayPolicies[].source exists
  • Added a defensive check in the deferred loop to avoid direct indexing of underlayPolicies[0]["source"]
  • Added a unit test that covers:
    • state=overridden
    • physical Ethernet
    • deletable=false
    • underlayPolicies=None

Behavior After This Change

For non-deletable Ethernet interfaces without a resolvable policy source, the module now:

  • does not crash
  • does not add them to deferred
  • reports them in diff.skipped
  • leaves them untouched

This preserves the existing deferred behavior for interfaces that do have a valid source.

Validation

Manual validation:

  • NDFC 4.2
  • ISN fabric: remove flow completed successfully
  • External fabric: remove flow completed successfully
  • Problematic physical Ethernet interfaces were reported under skipped
  • No NoneType or subscriptable failure was observed

Unit validation:

  • Added coverage for deletable=false plus underlayPolicies=None in test_dcnm_intf.py

@dacasti2mx
Copy link
Copy Markdown
Author

Hi @mikewiebe, when you have time, could you please provide feedback for this PR?
thanks.

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.

dcnm_interface: overridden crashes when deferred non-deletable interfaces have null underlayPolicies

1 participant