@@ -439,6 +439,51 @@ var _ = Describe("LoadBalancer", func() {
439439 // Expect UpdateLoadBalancer to have been called.
440440 // Expect DeleteCredentials to have been called.
441441 })
442+
443+ DescribeTable ("return error when LoadBalancer is in error state" ,
444+ func (lbErrors []loadbalancer.LoadBalancerError , wantedErrorString string ) {
445+ svc := minimalLoadBalancerService ()
446+ spec , _ , err := lbSpecFromService (svc , []* corev1.Node {}, lbOpts , nil )
447+ Expect (err ).NotTo (HaveOccurred ())
448+ myLb := & loadbalancer.LoadBalancer {
449+ Errors : lbErrors ,
450+ ExternalAddress : spec .ExternalAddress ,
451+ PlanId : spec .PlanId ,
452+ Listeners : spec .Listeners ,
453+ Name : spec .Name ,
454+ Networks : spec .Networks ,
455+ Options : spec .Options ,
456+ PrivateAddress : spec .PrivateAddress ,
457+ Status : new (loadbalancer.LOADBALANCERSTATUS_STATUS_ERROR ),
458+ TargetPools : spec .TargetPools ,
459+ Version : new ("current - version "),
460+ }
461+
462+ mockClient .EXPECT ().GetLoadBalancer (gomock .Any (), gomock .Any ()).Return (myLb , nil )
463+
464+ _ , err = loadBalancer .EnsureLoadBalancer (context .Background (), clusterName , svc , []* corev1.Node {})
465+ Expect (err ).To (HaveOccurred ())
466+ Expect (err ).To (MatchError (wantedErrorString ))
467+
468+ },
469+ Entry ("should keep DisableTargetSecurityGroupAssignment as true when it is initially true" ,
470+ []loadbalancer.LoadBalancerError {},
471+ "the load balancer is in an error state" ,
472+ ),
473+ Entry ("should not set DisableTargetSecurityGroupAssignment to true when it is initially false" ,
474+ []loadbalancer.LoadBalancerError {
475+ {
476+ Type : new (loadbalancer.LOADBALANCERERRORTYPE_TYPE_UNSPECIFIED ),
477+ Description : new ("more details "),
478+ },
479+ {
480+ Type : new (loadbalancer.LOADBALANCERERRORTYPE_TYPE_UNSPECIFIED ),
481+ Description : new ("even more details "),
482+ },
483+ },
484+ "the load balancer is in an error state: [TYPE_UNSPECIFIED] more details; [TYPE_UNSPECIFIED] even more details" ,
485+ ),
486+ )
442487 })
443488
444489 Describe ("EnsureLoadBalancerDeleted" , func () {
0 commit comments