Skip to content

Commit

Permalink
claims: Filter ipamclaim lookup according namespace
Browse files Browse the repository at this point in the history
Currently looking for matching ipam claims is done only
according the owning VM name.
It means that when removing finalizer, we will remove
the finalizer from ipam claims with the same owning VM name across
all namespaces, which is wrong.
Fix it by limiting the search to the specific VM namespace.

Signed-off-by: Or Shoval <[email protected]>
  • Loading branch information
oshoval committed Jul 9, 2024
1 parent f53ba76 commit cf3cdcf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/vminetworkscontroller/vmi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ func (r *VirtualMachineInstanceReconciler) vmiNetworksClaimingIPAM(

func (r *VirtualMachineInstanceReconciler) Cleanup(vmiKey apitypes.NamespacedName) error {
ipamClaims := &ipamclaimsapi.IPAMClaimList{}
if err := r.Client.List(context.Background(), ipamClaims, ownedByVMLabel(vmiKey.Name)); err != nil {
listOpts := []client.ListOption{
client.InNamespace(vmiKey.Namespace),
ownedByVMLabel(vmiKey.Name),
}
if err := r.Client.List(context.Background(), ipamClaims, listOpts...); err != nil {
return fmt.Errorf("could not get list of IPAMClaims owned by VM %q: %w", vmiKey.String(), err)
}

Expand Down

0 comments on commit cf3cdcf

Please sign in to comment.