Skip to content

dcnm_vrf: VRF Deletion Failure Fix #451

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

Merged
merged 3 commits into from
Jul 22, 2025
Merged

Conversation

AKDRG
Copy link
Collaborator

@AKDRG AKDRG commented Jul 1, 2025

Fix for invalid TOP_DOWN_VRF_VLAN resource being attempted to get deleted.

Issue:
#450

Fix:
When TOP_DOWN_VRF_VLAN resources are being populated in delete_ids list (release_orphaned_resources function), some resources IDs with invalid IP, switch name are sent to the controller for deletion, causing failure.

TOP_DOWN_VRF_VLAN Resources in NDFC.

[
    {
        "id": 2553,
        "resourcePool": {
            "id": 0,
            "poolName": "TOP_DOWN_VRF_VLAN",
            "fabricName": "AK-Test",
            "vrfName": null,
            "poolType": "ID_POOL",
            "dynamicSubnetRange": null,
            "targetSubnet": 0,
            "overlapAllowed": false,
            "hierarchicalKey": "AK-Test"
        },
        "entityType": "Device",
        "entityName": "ansible-vrf-int1",
        "allocatedIp": "500",
        "allocatedOn": 1751290494585,
        "allocatedFlag": true,
        "allocatedScopeValue": "ABCDEFGGJJ",
        "ipAddress": "192.168.1.2",
        "switchName": "spine",
        "hierarchicalKey": "0"
    },
    {
        "id": 2555,
        "resourcePool": {
            "id": 0,
            "poolName": "TOP_DOWN_VRF_VLAN",
            "fabricName": "AK-Test",
            "vrfName": null,
            "poolType": "ID_POOL",
            "dynamicSubnetRange": null,
            "targetSubnet": 0,
            "overlapAllowed": false,
            "hierarchicalKey": "AK-Test"
        },
        "entityType": "Device",
        "entityName": "ansible-vrf-int1",
        "allocatedIp": "500",
        "allocatedOn": 1751290505463,
        "allocatedFlag": false,
        "allocatedScopeValue": "ABCDEFGGJJ",
        "ipAddress": "192.168.1.3",
        "switchName": "leaf2",
        "hierarchicalKey": "0"
    },
    {
        "id": 2554,
        "resourcePool": {
            "id": 0,
            "poolName": "TOP_DOWN_VRF_VLAN",
            "fabricName": "AK-Test",
            "vrfName": null,
            "poolType": "ID_POOL",
            "dynamicSubnetRange": null,
            "targetSubnet": 0,
            "overlapAllowed": false,
            "hierarchicalKey": "AK-Test"
        },
        "entityType": "Device",
        "entityName": "ansible-vrf-int1",
        "allocatedIp": "500",
        "allocatedOn": 1751290494655,
        "allocatedFlag": true,
        "allocatedScopeValue": "ABCDEFGGJT",
        "ipAddress": "192.168.1.4",
        "switchName": "leaf1",
        "hierarchicalKey": "0"
    },
    {
        "id": 1744,
        "resourcePool": {
            "id": 0,
            "poolName": "TOP_DOWN_VRF_VLAN",
            "fabricName": "AK-Test",
            "vrfName": null,
            "poolType": "ID_POOL",
            "dynamicSubnetRange": null,
            "targetSubnet": 0,
            "overlapAllowed": false,
            "hierarchicalKey": "AK-Test"
        },
        "entityType": "Device",
        "entityName": "Tenant-2",
        "allocatedIp": "502",
        "allocatedOn": 1736348121214,
        "allocatedFlag": false,
        "allocatedScopeValue": "AK-Test",
        "ipAddress": "",
        "switchName": "",
        "hierarchicalKey": "0"
    },
    {
        "id": 1746,
        "resourcePool": {
            "id": 0,
            "poolName": "TOP_DOWN_VRF_VLAN",
            "fabricName": "AK-Test",
            "vrfName": null,
            "poolType": "ID_POOL",
            "dynamicSubnetRange": null,
            "targetSubnet": 0,
            "overlapAllowed": false,
            "hierarchicalKey": "AK-Test"
        },
        "entityType": "Device",
        "entityName": "Tenant-1",
        "allocatedIp": "501",
        "allocatedOn": 1736348121789,
        "allocatedFlag": false,
        "allocatedScopeValue": "AK-Test",
        "ipAddress": "",
        "switchName": "",
        "hierarchicalKey": "0"
    },
    {
        "id": 1747,
        "resourcePool": {
            "id": 0,
            "poolName": "TOP_DOWN_VRF_VLAN",
            "fabricName": "AK-Test",
            "vrfName": null,
            "poolType": "ID_POOL",
            "dynamicSubnetRange": null,
            "targetSubnet": 0,
            "overlapAllowed": false,
            "hierarchicalKey": "AK-Test"
        },
        "entityType": "Device",
        "entityName": "ansible-vrf-int1",
        "allocatedIp": "500",
        "allocatedOn": 1736348121976,
        "allocatedFlag": false,
        "allocatedScopeValue": "AK-Test",
        "ipAddress": "",
        "switchName": "",
        "hierarchicalKey": "0"
    }
]

NDFC Response:

  {
    "RETURN_CODE": 500,
    "METHOD": "DELETE",
    "REQUEST_PATH": "https://192.168.1.1:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/resource-manager/resources?id=2551,1747",
    "MESSAGE": "Internal Server Error",
    "DATA": {
      "successList": [2551],
      "invalidList": [1747]
    }
  }

@AKDRG AKDRG requested review from allenrobel and mikewiebe July 1, 2025 08:37
@allenrobel
Copy link
Collaborator

allenrobel commented Jul 4, 2025

UPDATE 2025-07-15: Mike and I agreed that the Pedantic integration would go into a dcnm_vrf_v2 module rather than the current dcnm_vrf module. Hence, the below request no longer applies.


Hi Akshay, let's not make any changes to dcnm_vrf.py. This file no longer exists after dcnm-vrf-pydantic-integration branch is merged.

If you'd like to checkout dcnm-vrf-pydantic-integration branch to apply your fixes there, let me know and I can stop work on it for you to make changes, and then pull your changes and continue work on it.

Thanks!
Allen

@mikewiebe mikewiebe changed the title DCNM_VRF: VRF Deletion Failure Fix dcnm_vrf: VRF Deletion Failure Fix Jul 14, 2025
@mikewiebe mikewiebe self-assigned this Jul 15, 2025
Copy link
Collaborator

@allenrobel allenrobel left a comment

Choose a reason for hiding this comment

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

LGTM once @mikewiebe comments are addressed. Thank you @AKDRG for finding this issue and implementing the fix!

@AKDRG
Copy link
Collaborator Author

AKDRG commented Jul 17, 2025

Hi @mikewiebe and @allenrobel,
I've addressed the comments, please let me know if there are any changes to be made further.

Thanks,
Akshay

Copy link
Collaborator

@allenrobel allenrobel left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@mikewiebe mikewiebe added the ready for review PR is ready to be reviewed label Jul 22, 2025
@mikewiebe mikewiebe merged commit faeae9b into CiscoDevNet:develop Jul 22, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dcnm_vrf: Error while deleting VRF, 'NoneType' object is not iterable
3 participants