Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #61 from hello2mao/delete-annotation-after-delete-…
Browse files Browse the repository at this point in the history
…lb-service

delete annotation after delete lb service
  • Loading branch information
hello2mao authored Mar 26, 2019
2 parents b46b977 + b28a666 commit 43ec4dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion pkg/cloud-provider/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,17 @@ func (bc *Baiducloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName

// delete EIP
if result.LoadBalancerInternalVpc == "true" {
if service.Annotations != nil {
delete(service.Annotations, ServiceAnnotationLoadBalancerId)
}
glog.V(3).Infof("[%v %v] EnsureLoadBalancerDeleted: use LoadBalancerInternalVpc, no EIP to delete", service.Namespace, service.Name, lb.Address)
glog.V(2).Infof("[%v %v] EnsureLoadBalancerDeleted: delete %v FINISH", serviceName, clusterName, serviceName)
return nil
}
if len(service.Spec.LoadBalancerIP) != 0 {
if service.Annotations != nil {
delete(service.Annotations, ServiceAnnotationLoadBalancerId)
}
glog.V(3).Infof("[%v %v] EnsureLoadBalancerDeleted: LoadBalancerIP is set, not delete EIP.", serviceName, clusterName)
glog.V(2).Infof("[%v %v] EnsureLoadBalancerDeleted: delete %v FINISH", serviceName, clusterName, serviceName)
return nil
Expand All @@ -187,7 +193,9 @@ func (bc *Baiducloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName
if err != nil {
return err
}

if service.Annotations != nil {
delete(service.Annotations, ServiceAnnotationLoadBalancerId)
}
glog.V(2).Infof("[%v %v] EnsureLoadBalancerDeleted: delete %v FINISH", serviceName, clusterName, serviceName)
return nil
}
9 changes: 6 additions & 3 deletions pkg/cloud-provider/load_balancer_blb.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,15 @@ func (bc *Baiducloud) waitForLoadBalancer(lb *blb.LoadBalancer) (*blb.LoadBalanc
return newlb, err
}
if !exist {
glog.V(3).Infof("getBCELoadBalancer not exist: %s", lb.BlbId)
return newlb, fmt.Errorf("BLB not exists:%s", lb.BlbId)
glog.V(3).Infof("getBCELoadBalancer not exist: %s, retry", lb.BlbId)
if index >= 9 {
return newlb, fmt.Errorf("BLB not exists:%s", lb.BlbId)
}
continue
}
lb = newlb
glog.V(3).Infof("BLB status is : %s", lb.Status)
if index == 9 && lb.Status != "available" {
if index >= 9 && lb.Status != "available" {
return nil, fmt.Errorf("waitForLoadBalancer failed after retry")
}
}
Expand Down

0 comments on commit 43ec4dd

Please sign in to comment.