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

[VCenter] IP addresses marked as orphan when VM is turned off #192

Closed
rizlas opened this issue May 18, 2022 · 20 comments
Closed

[VCenter] IP addresses marked as orphan when VM is turned off #192

rizlas opened this issue May 18, 2022 · 20 comments
Labels
awaiting reply Awaiting reply from issue owner bug Something isn't working
Milestone

Comments

@rizlas
Copy link
Contributor

rizlas commented May 18, 2022

Hi,
I recently noted that if a VM is turned off the IPs synced in NetBox are marked as orphans. This could lead to a misunderstanding in IPAM documentation because after "orphans cleanup/deletion" that IPs are marked as "free to use" in NetBox but actually they aren't.

Currently running v1.2.3

@rizlas rizlas changed the title [VCenter] IP addresses marked as orphan, but nic is only disconnected [VCenter] IP addresses marked as orphan when VM is turned off May 18, 2022
@bb-Ricardo bb-Ricardo added this to the 1.3.0 milestone May 18, 2022
@bb-Ricardo
Copy link
Owner

Hi, I have a look. This is not meant to happen.

@rizlas
Copy link
Contributor Author

rizlas commented May 18, 2022

Yeah thank you, in the meantime I'll try to do some other tests.

@bb-Ricardo
Copy link
Owner

Hey @rizlas,

I just checked and figured this is the default. If the VM is stopped, the IP address is not visible via the VMWare API.
The IP address was initially found on this interface and added via netbox-sync. Now the IP address can't be found anymore and therefore marked orphaned.

@bb-Ricardo bb-Ricardo removed this from the 1.3.0 milestone May 18, 2022
@rizlas
Copy link
Contributor Author

rizlas commented May 19, 2022

Unlucky, thank you for digging into this. Sorry also about the issue.

@bb-Ricardo
Copy link
Owner

Unlucky, thank you for digging into this. Sorry also about the issue.

Don't be sorry about opening an issue. It usually is an "issue" or "unwanted behaviour".

I also thought about this. It seems a bit difficult to implement but:
If an IP address belongs to a VM which is currently only "inactive" then we should refrain from marking it as orphan. This is a totally valid use case.

@bb-Ricardo bb-Ricardo added this to the 1.3.0 milestone May 19, 2022
@bb-Ricardo bb-Ricardo added the bug Something isn't working label May 19, 2022
@rizlas
Copy link
Contributor Author

rizlas commented May 20, 2022

Good point! Maybe netbox-sync can change only the status of the IpAddress to Reserverd when a VM has an offline status? Just an idea..

@bb-Ricardo
Copy link
Owner

Hi, i JUST implemented this. Now the IP address will not be marked orphaned if it belongs to a device/vm object which is present but not in status "active".

@rizlas
Copy link
Contributor Author

rizlas commented May 20, 2022

Amazing! Thank you!

@bb-Ricardo
Copy link
Owner

fix is pushed to "development" branch. Can you please test it out?

@bb-Ricardo bb-Ricardo added the awaiting reply Awaiting reply from issue owner label May 20, 2022
@rizlas
Copy link
Contributor Author

rizlas commented May 24, 2022

So i tried:

  • if delete orphan is set to 0, IP will be deleted anyway
  • Cleaning the tag before run. After run no tag added
    - Raised delete orphan > 0. Tag is NOT removed

@bb-Ricardo
Copy link
Owner

Hi, I don't really know what are the preconditions to your findings. Unfortunately I won't be able to test it by myself.

here is the relevant code:

if isinstance(this_object, NBIPAddress):
device_vm_object = this_object.get_device_vm()
if device_vm_object is not None and \
grab(device_vm_object, "data.status") is not None and \
"active" not in str(grab(device_vm_object, "data.status")):
log.debug2(f"{device_vm_object.name} '{device_vm_object.get_display_name()}' has IP "
f"'{this_object.get_display_name()}' assigned but is in status "
f"{grab(device_vm_object, 'data.status')}. "
f"IP address will not marked as orphaned.")
continue

Enabling or disabling prune_enabled and changing prune_delay_in_days has no effect on tagging objects as orphaned.

Does this information help?

@rizlas
Copy link
Contributor Author

rizlas commented May 25, 2022

Preconditions are: VM has state set to Offline, IP address bonded to that VM is already been tagged has orphan.

@rizlas
Copy link
Contributor Author

rizlas commented May 29, 2022

A better explanation.. Currently the update works, but it's is not backward compatible especially if a tag is already there it is not cleaned.

@rizlas
Copy link
Contributor Author

rizlas commented Jul 21, 2022

This is still ongoing?

@bb-Ricardo
Copy link
Owner

Hi, yes this is still ongoing. Need to take care of it when syncing from NetBox. Only did the part with syncing to NetBox.

Currently on holidays and will have a look once I'm back.

1 similar comment
@bb-Ricardo
Copy link
Owner

Hi, yes this is still ongoing. Need to take care of it when syncing from NetBox. Only did the part with syncing to NetBox.

Currently on holidays and will have a look once I'm back.

@rizlas
Copy link
Contributor Author

rizlas commented Jul 22, 2022

Ah don't worry. It was only for information. Enjoy your holiday 👍🏻

@bb-Ricardo
Copy link
Owner

Hi @rizlas,

sorry for the long wait. I'm back again and I just pushed another change to development. Would you mind testing it? This should solve your issue.

You can close the ticket if the issue is resolved.

@rizlas
Copy link
Contributor Author

rizlas commented Aug 25, 2022

Hi, thank you. It is working.

Test:

  • Turn off a Vm
  • Sync
  • IP not removed nor tagged as orphan

@rizlas rizlas closed this as completed Aug 25, 2022
@bb-Ricardo
Copy link
Owner

Thank you for testing

andreiKuznets0v pushed a commit to andreiKuznets0v/netbox-sync_try_vcloud that referenced this issue Feb 27, 2023
andreiKuznets0v pushed a commit to andreiKuznets0v/netbox-sync_try_vcloud that referenced this issue Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reply Awaiting reply from issue owner bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants