Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion providers/gce/gce_loadbalancer_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,8 @@ func (g *Cloud) ensureInternalInstanceGroups(name string, nodes []*v1.Node) ([]s
parts := strings.Split(ins.Instance, "/")
groupInstances.Insert(parts[len(parts)-1])
}
if names.HasAll(groupInstances.UnsortedList()...) {
groupInstanceNames := groupInstances.UnsortedList()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the code as is, but since this is looking like it will be a long term carry, a comment as to why we have these conditions will help reduce issue archeology in the future.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The motivation was included in the commit message. I just brushed up again.

Do you think that works or we also need an in-code comment?

if names.HasAll(groupInstanceNames...) || g.allHaveNodePrefix(groupInstanceNames) {
igLinks = append(igLinks, ig.SelfLink)
skip.Insert(groupInstances.UnsortedList()...)
}
Expand All @@ -695,6 +696,15 @@ func (g *Cloud) candidateExternalInstanceGroups(zone string) ([]*compute.Instanc
return g.ListInstanceGroupsWithPrefix(zone, g.externalInstanceGroupsPrefix)
}

func (g *Cloud) allHaveNodePrefix(instances []string) bool {
for _, instance := range instances {
if !strings.HasPrefix(instance, g.nodeInstancePrefix) {
return false
}
}
return true
}

func (g *Cloud) ensureInternalInstanceGroupsDeleted(name string) error {
// List of nodes isn't available here - fetch all zones in region and try deleting this cluster's ig
zones, err := g.ListZonesInRegion(g.region)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.