Skip to content

fix: do not adopt a same-named cluster another source keeps in a different site - #557

Open
semx wants to merge 2 commits into
developmentfrom
fix/cluster-matching-other-source
Open

fix: do not adopt a same-named cluster another source keeps in a different site#557
semx wants to merge 2 commits into
developmentfrom
fix/cluster-matching-other-source

Conversation

@semx

@semx semx commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Fixes #501

With two vCenters that use the same datacenter and cluster names, add_cluster() falls back to a name-only match and adopts the cluster the other source created. The second source then tries to move that cluster to its own site, which NetBox rejects because the first vCenter's hosts live in the other site (4 devices are assigned as hosts for this cluster but are not in site SR1), and its hosts end up attached to the wrong cluster. Setting set_source_name_as_cluster_group does not help, the name-only fallback still wins.

A same-named candidate is now skipped when this source assigns a site, the candidate is scoped to a different site, and it is maintained by another configured source (the source that touched it in this run, or its source tag for objects read from NetBox). Everything else is unchanged: a single source still re-scopes its own cluster, adopts a cluster from a renamed source, and adopts a site-less cluster (covered by tests that pass before and after).

Reproduced end to end with two vcsim instances carrying identical datacenter/cluster names: before, one cluster with scope_id flipping between the sites and the second vCenter's hosts on the first cluster; after, two clusters with their own hosts. Tests: tests/test_vmware_cluster_matching.py, 3 cases fail on development and pass here, 3 guard cases pass on both. Full suite: 88 passed.

Rebased on current development. #566 landed in the meantime and also touches add_cluster(), putting the site object into scope_id instead of a dict; the two sit next to each other without conflict and get_site_name() still resolves the candidate's site in the object form this check relies on. Suite 149 with both in.

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.

1 participant