Skip to content

Commit

Permalink
Review feedback: corrected pointer comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
pebrc committed Apr 11, 2024
1 parent 84a1faf commit 749e878
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/controller/common/service_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func needsRecreate(expected, reconciled *corev1.Service) bool {
}

// LoadBalancerClass is immutable once set if target type is load balancer
if expected.Spec.Type == corev1.ServiceTypeLoadBalancer && expected.Spec.LoadBalancerClass != reconciled.Spec.LoadBalancerClass {
if expected.Spec.Type == corev1.ServiceTypeLoadBalancer && !reflect.DeepEqual(expected.Spec.LoadBalancerClass, reconciled.Spec.LoadBalancerClass) {
return true
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/controller/common/service_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ func Test_needsRecreate(t *testing.T) {
},
want: false,
},
{
name: "No need to recreate if LoadBalancerClass has not changed",
args: args{
expected: corev1.Service{Spec: corev1.ServiceSpec{
Type: corev1.ServiceTypeLoadBalancer,
LoadBalancerClass: ptr.To("my-customer/lb"),
}},
reconciled: corev1.Service{Spec: corev1.ServiceSpec{
Type: corev1.ServiceTypeLoadBalancer,
LoadBalancerClass: ptr.To("my-customer/lb"),
}},
},
want: false,
},
{
name: "Needs recreate if LoadBalancerClass is changed",
args: args{
Expand Down

0 comments on commit 749e878

Please sign in to comment.