Skip to content

Commit

Permalink
fix: Do not return error if serviceLoadBalancer field is not set (#611)
Browse files Browse the repository at this point in the history
**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.
  • Loading branch information
dlipovetsky authored May 6, 2024
1 parent d9eeebe commit 1e3f7ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type Addons struct {
// +kubebuilder:validation:Optional
CSIProviders *CSI `json:"csi,omitempty"`

// +optional
// +kubebuilder:validation:Optional
ServiceLoadBalancer *ServiceLoadBalancer `json:"serviceLoadBalancer,omitempty"`
}

Expand Down
10 changes: 9 additions & 1 deletion pkg/handlers/generic/lifecycle/serviceloadbalancer/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,20 @@ func (c *ServiceLoadBalancerHandler) AfterControlPlaneInitialized(
)

varMap := variables.ClusterVariablesToVariablesMap(req.Cluster.Spec.Topology.Variables)

slb, err := variables.Get[v1alpha1.ServiceLoadBalancer](
varMap,
c.variableName,
c.variablePath...)
if err != nil {
if variables.IsNotFoundError(err) {
log.
Info(
"Skipping ServiceLoadBalancer, field is not specified",
"error",
err,
)
return
}
log.Error(
err,
"failed to read ServiceLoadBalancer provider from cluster definition",
Expand Down

0 comments on commit 1e3f7ce

Please sign in to comment.