FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[release-v1.36] Add more details for load balancers in error state by stackit-ske · Pull Request #1443 · stackitcloud/cloud-provider-stackit · GitHub

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

Filter by extension

Filter by extension .go  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
13 changes: 12 additions & 1 deletion pkg/ccm/loadbalancer.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,18 @@ func (l *LoadBalancer) EnsureLoadBalancer( //nolint:gocyclo // not really comple
}

if lb.Status != nil && *lb.Status == loadbalancer.LOADBALANCERSTATUS_STATUS_ERROR {
return nil, fmt.Errorf("the load balancer is in an error state")
errorsList := lb.GetErrors()

if len(errorsList) == 0 {
return nil, fmt.Errorf("the load balancer is in an error state")
}

var errMessages []string
for _, lbErr := range errorsList {
errMessages = append(errMessages, fmt.Sprintf("[%s] %s", lbErr.GetType(), lbErr.GetDescription()))
}

return nil, fmt.Errorf("the load balancer is in an error state: %s", strings.Join(errMessages, "; "))
}
if lb.Status == nil || *lb.Status != loadbalancer.LOADBALANCERSTATUS_STATUS_READY {
return nil, api.NewRetryError("waiting for load balancer to become ready. This error is normal while the load balancer starts.", retryDuration)
Expand Down
45 changes: 45 additions & 0 deletions pkg/ccm/loadbalancer_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,51 @@ var _ = Describe("LoadBalancer", func() {
// Expect UpdateLoadBalancer to have been called.
// Expect DeleteCredentials to have been called.
})

DescribeTable("return error when LoadBalancer is in error state",
func(lbErrors []loadbalancer.LoadBalancerError, wantedErrorString string) {
svc := minimalLoadBalancerService()
spec, _, err := lbSpecFromService(svc, []*corev1.Node{}, lbOpts, nil)
Expect(err).NotTo(HaveOccurred())
myLb := &loadbalancer.LoadBalancer{
Errors: lbErrors,
ExternalAddress: spec.ExternalAddress,
PlanId: spec.PlanId,
Listeners: spec.Listeners,
Name: spec.Name,
Networks: spec.Networks,
Options: spec.Options,
PrivateAddress: spec.PrivateAddress,
Status: new(loadbalancer.LOADBALANCERSTATUS_STATUS_ERROR),
TargetPools: spec.TargetPools,
Version: new("current-version"),
}

mockClient.EXPECT().GetLoadBalancer(gomock.Any(), gomock.Any()).Return(myLb, nil)

_, err = loadBalancer.EnsureLoadBalancer(context.Background(), clusterName, svc, []*corev1.Node{})
Expect(err).To(HaveOccurred())
Expect(err).To(MatchError(wantedErrorString))

},
Entry("should return an error without specific errors",
[]loadbalancer.LoadBalancerError{},
"the load balancer is in an error state",
),
Entry("should return an error with specific errors",
[]loadbalancer.LoadBalancerError{
{
Type: new(loadbalancer.LOADBALANCERERRORTYPE_TYPE_UNSPECIFIED),
Description: new("more details"),
},
{
Type: new(loadbalancer.LOADBALANCERERRORTYPE_TYPE_UNSPECIFIED),
Description: new("even more details"),
},
},
"the load balancer is in an error state: [TYPE_UNSPECIFIED] more details; [TYPE_UNSPECIFIED] even more details",
),
)
})

Describe("EnsureLoadBalancerDeleted", func() {
Expand Down

Back | FazBrowse Home | New Git URL