Fix wrongful use of GetDependency - #911
Merged
Merged
Conversation
…rcesForAdoption ListOSResourcesForAdoption is a read-only lookup to check if an existing OpenStack resource matches the spec for adoption. It should not add finalizers to dependency objects. Replace serviceDependency.GetDependency() and regionDependency.GetDependency() with dependency.FetchDependency(), which performs a lightweight lookup without finalizer side effects. This matches the pattern used by all other controllers (router, network, securitygroup, subnet, group, floatingip, limit, role).
Reuse the existing create dependency lists (RequiredCreateDependencies and OptionalCreateDependencies) to generate FetchDependency calls in ListOSResourcesForAdoption. Adoption dependencies typically match create dependencies, and any controller-specific differences can be customized after scaffolding. Required create deps use address-of (&resourceSpec.XxxRef) for value-type refs, while optional ones use the pointer directly (resourceSpec.XxxRef) and are guarded by a nil check. This follows the pattern established by controllers like router, network, securitygroup, subnet, and limit, which all use FetchDependency in their adoption methods.
Add a note in the FetchDependency section clarifying that ListOSResourcesForAdoption must always use FetchDependency, never GetDependency from a DeletionGuardDependency, since adoption is a read-only check that should not add finalizers.
winiciusallan
approved these changes
Sep 15, 2026
| "github.com/k-orc/openstack-resource-controller/v2/internal/logging" | ||
| "github.com/k-orc/openstack-resource-controller/v2/internal/osclients" | ||
| {{- if len .ImportDependencies }} | ||
| {{- if or (len .ImportDependencies) (len .AllCreateDependencies) }} |
Member
There was a problem hiding this comment.
I did not know go template uses polish notation for logical operands. Cool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The endpoint controller wrongfully used
GetDependencyinstead ofFetchDependencywhich added a finalizer to dependency objects as a side effect.Also add the snippet to the
ListOSResourcesForAdoption()function in the scaffolding.