From e3d88c0f3884673d9c7b3066b5b755315f27faec Mon Sep 17 00:00:00 2001 From: Maximilian Geberl Date: Fri, 24 Jul 2026 09:26:56 +0200 Subject: [PATCH 1/2] Add more details for load balancers in error state --- pkg/ccm/loadbalancer.go | 13 ++++++++++- pkg/ccm/loadbalancer_test.go | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/pkg/ccm/loadbalancer.go b/pkg/ccm/loadbalancer.go index 8605c88b..3f43ddd5 100644 --- a/pkg/ccm/loadbalancer.go +++ b/pkg/ccm/loadbalancer.go @@ -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) diff --git a/pkg/ccm/loadbalancer_test.go b/pkg/ccm/loadbalancer_test.go index b741ddf5..8300a056 100644 --- a/pkg/ccm/loadbalancer_test.go +++ b/pkg/ccm/loadbalancer_test.go @@ -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 keep DisableTargetSecurityGroupAssignment as true when it is initially true", + []loadbalancer.LoadBalancerError{}, + "the load balancer is in an error state", + ), + Entry("should not set DisableTargetSecurityGroupAssignment to true when it is initially false", + []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() { From ed3880da65dba7c99b87ea66cd99aca95b0f76d7 Mon Sep 17 00:00:00 2001 From: Maximilian Geberl Date: Tue, 28 Jul 2026 10:55:17 +0200 Subject: [PATCH 2/2] Add PR Review suggestions --- pkg/ccm/loadbalancer_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/ccm/loadbalancer_test.go b/pkg/ccm/loadbalancer_test.go index 8300a056..32afd022 100644 --- a/pkg/ccm/loadbalancer_test.go +++ b/pkg/ccm/loadbalancer_test.go @@ -466,11 +466,11 @@ var _ = Describe("LoadBalancer", func() { Expect(err).To(MatchError(wantedErrorString)) }, - Entry("should keep DisableTargetSecurityGroupAssignment as true when it is initially true", + Entry("should return an error without specific errors", []loadbalancer.LoadBalancerError{}, "the load balancer is in an error state", ), - Entry("should not set DisableTargetSecurityGroupAssignment to true when it is initially false", + Entry("should return an error with specific errors", []loadbalancer.LoadBalancerError{ { Type: new(loadbalancer.LOADBALANCERERRORTYPE_TYPE_UNSPECIFIED),