Skip to content

Commit 896c15d

Browse files
committed
WiP: Some small fixes
1 parent f5b969b commit 896c15d

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

pkg/cloud/services/networking/network.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/external"
2626
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/networks"
2727
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/subnets"
28+
"k8s.io/apimachinery/pkg/api/equality"
2829
"k8s.io/utils/ptr"
2930

3031
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1"
@@ -258,16 +259,11 @@ func (s *Service) updateSubnetDNSNameservers(openStackCluster *infrav1.OpenStack
258259
desiredNameservers := openStackCluster.Spec.ManagedSubnets[0].DNSNameservers
259260
currentNameservers := subnet.DNSNameservers
260261

261-
needsUpdate := false
262+
var needsUpdate bool
262263
if len(desiredNameservers) != len(currentNameservers) {
263264
needsUpdate = true
264265
} else {
265-
for i, ns := range desiredNameservers {
266-
if i >= len(currentNameservers) || ns != currentNameservers[i] {
267-
needsUpdate = true
268-
break
269-
}
270-
}
266+
needsUpdate = !equality.Semantic.DeepEqual(currentNameservers, desiredNameservers)
271267
}
272268

273269
if needsUpdate {

pkg/webhooks/openstackcluster_webhook.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222
"reflect"
2323

24+
"k8s.io/apimachinery/pkg/api/equality"
2425
"k8s.io/apimachinery/pkg/runtime"
2526
"k8s.io/apimachinery/pkg/util/validation/field"
2627
"k8s.io/utils/ptr"
@@ -165,7 +166,7 @@ func (*openStackClusterWebhook) ValidateUpdate(_ context.Context, oldObjRaw, new
165166
}
166167

167168
// Check if AllocationPools have changed
168-
if !reflect.DeepEqual(oldSubnet.AllocationPools, newSubnet.AllocationPools) {
169+
if !equality.Semantic.DeepEqual(oldSubnet.AllocationPools, newSubnet.AllocationPools) {
169170
allErrs = append(allErrs, field.Forbidden(
170171
field.NewPath("spec", "managedSubnets").Child("allocationPools"),
171172
"cannot modify allocation pools in existing subnet",

0 commit comments

Comments
 (0)