Skip to content

Commit 1e3f7ce

Browse files
authored
fix: Do not return error if serviceLoadBalancer field is not set (#611)
**What problem does this PR solve?**: I noticed that the error handling was incorrect. I also noticed that the field tag did not get updated in #604, so I made that update here.
1 parent d9eeebe commit 1e3f7ce

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

api/v1alpha1/addon_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type Addons struct {
7272
// +kubebuilder:validation:Optional
7373
CSIProviders *CSI `json:"csi,omitempty"`
7474

75-
// +optional
75+
// +kubebuilder:validation:Optional
7676
ServiceLoadBalancer *ServiceLoadBalancer `json:"serviceLoadBalancer,omitempty"`
7777
}
7878

pkg/handlers/generic/lifecycle/serviceloadbalancer/handler.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,20 @@ func (c *ServiceLoadBalancerHandler) AfterControlPlaneInitialized(
6969
)
7070

7171
varMap := variables.ClusterVariablesToVariablesMap(req.Cluster.Spec.Topology.Variables)
72-
7372
slb, err := variables.Get[v1alpha1.ServiceLoadBalancer](
7473
varMap,
7574
c.variableName,
7675
c.variablePath...)
7776
if err != nil {
77+
if variables.IsNotFoundError(err) {
78+
log.
79+
Info(
80+
"Skipping ServiceLoadBalancer, field is not specified",
81+
"error",
82+
err,
83+
)
84+
return
85+
}
7886
log.Error(
7987
err,
8088
"failed to read ServiceLoadBalancer provider from cluster definition",

0 commit comments

Comments
 (0)