Skip to content

Conversation

@ntnx-cpranava
Copy link

Summary:

On update_subnet() in ntnx_subnets_v2.py, previously remove_empty_ip_config(current_spec) was always invoked—even when current_spec.ip_config was None, which triggers errors when subnet does not IPAM features enabled. This commit ensures we only perform this clean‑up when ip_config actually exists.

Changes

  • Wrapped the call to remove_empty_ip_config(current_spec) in an if current_spec.to_dict()['ip_config'] is not None: guard.
  • Removed the unconditional call from the previous implementation.
  • No new logic added beyond safety check, so behavior should remain identical in valid cases.

subnets = get_subnet_api_instance(module)
current_spec = get_subnet(module, subnets, ext_id=ext_id)
remove_empty_ip_config(current_spec)
if current_spec.to_dict()['ip_config'] is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can we move this check inside remove_empty_ip_config.

Copy link
Author

Choose a reason for hiding this comment

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

if empty_ipv6 and empty_ipv4:
ip_config.remove(item)
setattr(obj, "ip_config", ip_config)
if obj.to_dict()['ip_config'] is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

What will happen if ip_config is not present in obj?

if empty_ipv6 and empty_ipv4:
ip_config.remove(item)
setattr(obj, "ip_config", ip_config)
if obj.to_dict()['ip_config'] is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if obj.to_dict()['ip_config'] is not None:
ip_config = obj.to_dict().get("ip_config", [])
if len(ip_config)!=0:

"$dataItemDiscriminator",
]

ip_config = obj.to_dict().get("ip_config", [])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this, if you are using the above suggested change.

@abhinavbansal29
Copy link
Collaborator

abhinavbansal29 commented Sep 15, 2025

Hi @ntnx-cpranava , Can you please have a look to the mentioned comments?
Do we have a issue created for this? If not please create one.
Thanks

@abhinavbansal29 abhinavbansal29 added the bug Something isn't working label Sep 15, 2025
@abhinavbansal29
Copy link
Collaborator

Hi @ntnx-cpranava , Can you please have a look to the above mentioned comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working v2.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants