Skip to content

Commit

Permalink
fix aws cluster update with secondary control plane load balancer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeysofin committed Dec 11, 2024
1 parent dc86e24 commit e609129
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
18 changes: 9 additions & 9 deletions api/v1beta2/awscluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,16 @@ func (r *AWSCluster) validateControlPlaneLoadBalancerUpdate(oldlb, newlb *AWSLoa
newlb.Name, "field is immutable"),
)
}
}

// Block the update for Protocol :
// - if it was not set in old spec but added in new spec
// - if it was set in old spec but changed in new spec
if !cmp.Equal(newlb.HealthCheckProtocol, oldlb.HealthCheckProtocol) {
allErrs = append(allErrs,
field.Invalid(field.NewPath("spec", "controlPlaneLoadBalancer", "healthCheckProtocol"),
newlb.HealthCheckProtocol, "field is immutable once set"),
)
// Block the update for Protocol :
// - if it was not set in old spec but added in new spec
// - if it was set in old spec but changed in new spec
if !cmp.Equal(newlb.HealthCheckProtocol, oldlb.HealthCheckProtocol) {
allErrs = append(allErrs,
field.Invalid(field.NewPath("spec", "controlPlaneLoadBalancer", "healthCheckProtocol"),
newlb.HealthCheckProtocol, "field is immutable once set"),
)
}
}

return allErrs
Expand Down
14 changes: 14 additions & 0 deletions api/v1beta2/awscluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,20 @@ func TestAWSClusterValidateUpdate(t *testing.T) {
},
wantErr: true,
},
{
name: "Should pass if old secondary lb is absent",
oldCluster: &AWSCluster{
Spec: AWSClusterSpec{},
},
newCluster: &AWSCluster{
Spec: AWSClusterSpec{
SecondaryControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
Name: ptr.To("test-lb"),
},
},
},
wantErr: false,
},
{
name: "Should pass if controlPlaneLoadBalancer healthcheckprotocol is same after update",
oldCluster: &AWSCluster{
Expand Down

0 comments on commit e609129

Please sign in to comment.