Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading