Skip to content

Commit

Permalink
fix forward listener delete error
Browse files Browse the repository at this point in the history
  • Loading branch information
gujingit committed Mar 19, 2021
1 parent cf3535b commit 93e9dad
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions cloud-controller-manager/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,23 @@ func EnsureListenersDeleted(

for _, loc := range local {
for _, rem := range remote {
if !isManagedByMyService(service, rem) {
continue
}
hasUserNode, err := rem.listenerHasUserManagedNode(ctx)
if err != nil {
return fmt.Errorf("check if listener has user managed node, error: %s", err.Error())
}
if hasUserNode {
klog.Infof("%s port %d vgroup has user managed node, skip", rem.NamedKey, rem.Port)
continue
}

if loc.Port == rem.Port {
err := loc.Remove(ctx)

if !isManagedByMyService(service, rem) {
continue
}

hasUserNode, err := rem.listenerHasUserManagedNode(ctx)
if err != nil {
return fmt.Errorf("check if listener has user managed node, error: %s", err.Error())
}
if hasUserNode {
klog.Infof("%s port %d vgroup has user managed node, skip", rem.NamedKey, rem.Port)
continue
}

err = loc.Remove(ctx)
if err != nil {
return fmt.Errorf("ensure listener: %s", err.Error())
}
Expand Down Expand Up @@ -1499,6 +1503,10 @@ func (n *Listener) listenerHasUserManagedNode(ctx context.Context) (bool, error)
return false, err
}

if n.VServerGroupId == "" {
return false, nil
}

remoteVg, err := n.Client.DescribeVServerGroupAttribute(
ctx,
&slb.DescribeVServerGroupAttributeArgs{
Expand Down

0 comments on commit 93e9dad

Please sign in to comment.