@@ -30,6 +30,7 @@ import (
3030 infranetworkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1"
3131 condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
3232 "github.com/openstack-k8s-operators/lib-common/modules/common/helper"
33+ "github.com/openstack-k8s-operators/lib-common/modules/common/labels"
3334 "github.com/openstack-k8s-operators/lib-common/modules/common/util"
3435 dataplanev1 "github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1"
3536)
@@ -296,10 +297,11 @@ func EnsureIPSets(ctx context.Context, helper *helper.Helper,
296297func cleanupStaleReservations (ctx context.Context , helper * helper.Helper ,
297298 instance * dataplanev1.OpenStackDataPlaneNodeSet ) error {
298299 ipSetList := & infranetworkv1.IPSetList {}
299- labelSelectorMap := map [string ]string {IPSetOwnershipLabelKey : instance .Name }
300+ labelSelector := labels .GetLabels (instance ,
301+ labels .GetGroupLabel (NodeSetLabel ), map [string ]string {})
300302 listOpts := []client.ListOption {
301303 client .InNamespace (instance .Namespace ),
302- client .MatchingLabels (labelSelectorMap ),
304+ client .MatchingLabels (labelSelector ),
303305 }
304306
305307 err := helper .GetClient ().List (ctx , ipSetList , listOpts ... )
@@ -367,8 +369,8 @@ func reserveIPs(ctx context.Context, helper *helper.Helper,
367369 },
368370 }
369371 _ , err := controllerutil .CreateOrPatch (ctx , helper .GetClient (), ipSet , func () error {
370- ipSet . Labels = util . MergeStringMaps ( ipSet . Labels ,
371- map [ string ] string { IPSetOwnershipLabelKey : instance . Name } )
372+ ownerLabels := labels . GetLabels ( instance , labels . GetGroupLabel ( NodeSetLabel ), map [ string ] string {})
373+ ipSet . Labels = util . MergeStringMaps ( ipSet . GetLabels (), ownerLabels )
372374 ipSet .Spec .Networks = nets
373375 // Set controller reference to the DataPlaneNode object
374376 err := controllerutil .SetControllerReference (
0 commit comments