Skip to content

Commit 8fb26f7

Browse files
committed
ServerGroup: Tighten adoption filter
Include the immutable Policy field in the client-side adoption filter to prevent adopting a server group with the wrong scheduling policy (e.g. affinity vs anti-affinity).
1 parent 578eccc commit 8fb26f7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

internal/controllers/servergroup/actuator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups"
2424
corev1 "k8s.io/api/core/v1"
25+
"k8s.io/utils/ptr"
2526
ctrl "sigs.k8s.io/controller-runtime"
2627

2728
orcv1alpha1 "github.com/k-orc/openstack-resource-controller/v2/api/v1alpha1"
@@ -75,7 +76,7 @@ func (actuator servergroupActuator) ListOSResourcesForAdoption(ctx context.Conte
7576
filters := []osclients.ResourceFilter[osResourceT]{
7677
func(f *servergroups.ServerGroup) bool {
7778
name := getResourceName(orcObject)
78-
return f.Name == name
79+
return f.Name == name && ptr.Deref(f.Policy, "") == string(resourceSpec.Policy)
7980
},
8081
}
8182
listOpts := servergroups.ListOpts{}

0 commit comments

Comments
 (0)