small fixes in loadbalancer tasks

This commit is contained in:
Leïla MARABESE 2023-04-18 11:59:13 +02:00
parent 7616f138ec
commit 375dc1e4ae
4 changed files with 14 additions and 2 deletions

View File

@ -435,6 +435,10 @@ func (s *scwCloudImplementation) DeleteLoadBalancer(loadBalancer *lb.LB) error {
Zone: s.zone,
})
if err != nil {
if is404Error(err) {
klog.V(8).Infof("Load-balancer %q (%s) was already deleted", loadBalancer.Name, loadBalancer.ID)
return nil
}
return fmt.Errorf("waiting for load-balancer: %w", err)
}
err = s.lbAPI.DeleteLB(&lb.ZonedAPIDeleteLBRequest{

View File

@ -54,6 +54,10 @@ func (l *LBBackend) Find(context *fi.CloudupContext) (*LBBackend, error) {
cloud := context.T.Cloud.(scaleway.ScwCloud)
lbService := cloud.LBService()
if l.LoadBalancer.LBID == nil {
return nil, nil
}
backendResponse, err := lbService.ListBackends(&lb.ZonedAPIListBackendsRequest{
Zone: scw.Zone(cloud.Zone()),
LBID: fi.ValueOf(l.LoadBalancer.LBID),

View File

@ -51,6 +51,10 @@ func (l *LBFrontend) Find(context *fi.CloudupContext) (*LBFrontend, error) {
cloud := context.T.Cloud.(scaleway.ScwCloud)
lbService := cloud.LBService()
if l.LoadBalancer.LBID == nil {
return nil, nil
}
frontendResponse, err := lbService.ListFrontends(&lb.ZonedAPIListFrontendsRequest{
Zone: scw.Zone(cloud.Zone()),
LBID: fi.ValueOf(l.LoadBalancer.LBID),

View File

@ -142,7 +142,7 @@ func (l *LoadBalancer) RenderScw(t *scaleway.ScwAPITarget, actual, expected, cha
if actual != nil {
klog.Infof("Updating existing load-balancer with name %q", expected.Name)
klog.Infof("Updating existing load-balancer with name %q", fi.ValueOf(expected.Name))
// We update the tags
if changes != nil || len(actual.Tags) != len(expected.Tags) {
@ -164,7 +164,7 @@ func (l *LoadBalancer) RenderScw(t *scaleway.ScwAPITarget, actual, expected, cha
} else {
klog.Infof("Creating new load-balancer with name %q", expected.Name)
klog.Infof("Creating new load-balancer with name %q", fi.ValueOf(expected.Name))
lbCreated, err := lbService.CreateLB(&lb.ZonedAPICreateLBRequest{
Zone: scw.Zone(fi.ValueOf(expected.Zone)),