Skip to content

Commit f985077

Browse files
authored
Merge pull request #5248 from alexeysofin/secondary-lb
🐛 fix(awscluster): update with secondary control plane load balancer
2 parents 239e19c + e609129 commit f985077

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

api/v1beta2/awscluster_webhook.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,16 @@ func (r *AWSCluster) validateControlPlaneLoadBalancerUpdate(oldlb, newlb *AWSLoa
180180
newlb.Name, "field is immutable"),
181181
)
182182
}
183-
}
184183

185-
// Block the update for Protocol :
186-
// - if it was not set in old spec but added in new spec
187-
// - if it was set in old spec but changed in new spec
188-
if !cmp.Equal(newlb.HealthCheckProtocol, oldlb.HealthCheckProtocol) {
189-
allErrs = append(allErrs,
190-
field.Invalid(field.NewPath("spec", "controlPlaneLoadBalancer", "healthCheckProtocol"),
191-
newlb.HealthCheckProtocol, "field is immutable once set"),
192-
)
184+
// Block the update for Protocol :
185+
// - if it was not set in old spec but added in new spec
186+
// - if it was set in old spec but changed in new spec
187+
if !cmp.Equal(newlb.HealthCheckProtocol, oldlb.HealthCheckProtocol) {
188+
allErrs = append(allErrs,
189+
field.Invalid(field.NewPath("spec", "controlPlaneLoadBalancer", "healthCheckProtocol"),
190+
newlb.HealthCheckProtocol, "field is immutable once set"),
191+
)
192+
}
193193
}
194194

195195
return allErrs

api/v1beta2/awscluster_webhook_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,20 @@ func TestAWSClusterValidateUpdate(t *testing.T) {
984984
},
985985
wantErr: true,
986986
},
987+
{
988+
name: "Should pass if old secondary lb is absent",
989+
oldCluster: &AWSCluster{
990+
Spec: AWSClusterSpec{},
991+
},
992+
newCluster: &AWSCluster{
993+
Spec: AWSClusterSpec{
994+
SecondaryControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
995+
Name: ptr.To("test-lb"),
996+
},
997+
},
998+
},
999+
wantErr: false,
1000+
},
9871001
{
9881002
name: "Should pass if controlPlaneLoadBalancer healthcheckprotocol is same after update",
9891003
oldCluster: &AWSCluster{

0 commit comments

Comments
 (0)