Skip to content

Commit

Permalink
internal lb do not remove nodes with empty string in the zone field
Browse files Browse the repository at this point in the history
  • Loading branch information
08volt committed Aug 30, 2024
1 parent 1de8477 commit 37b5fb0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions providers/gce/gce_loadbalancer_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ func (g *Cloud) ensureInternalHealthCheck(name string, svcName types.NamespacedN
return hc, nil
}

func (g *Cloud) ensureInternalInstanceGroup(name, zone string, nodes []*v1.Node) (string, error) {
func (g *Cloud) ensureInternalInstanceGroup(name, zone string, nodes []*v1.Node, emptyZoneNodes []*v1.Node) (string, error) {
klog.V(2).Infof("ensureInternalInstanceGroup(%v, %v): checking group that it contains %v nodes [node names limited, total number of nodes: %d]", name, zone, loggableNodeNames(nodes), len(nodes))
ig, err := g.GetInstanceGroup(name, zone)
if err != nil && !isNotFound(err) {
Expand All @@ -615,6 +615,11 @@ func (g *Cloud) ensureInternalInstanceGroup(name, zone string, nodes []*v1.Node)
kubeNodes.Insert(n.Name)
}

emptyZoneNodesNames := sets.NewString()
for _, n := range emptyZoneNodes {
emptyZoneNodesNames.Insert(n.Name)
}

// Individual InstanceGroup has a limit for 1000 instances in it.
// As a result, it's not possible to add more to it.
// Given that the long-term fix (AlphaFeatureILBSubsets) is already in-progress,
Expand Down Expand Up @@ -650,7 +655,7 @@ func (g *Cloud) ensureInternalInstanceGroup(name, zone string, nodes []*v1.Node)
}
}

removeNodes := gceNodes.Difference(kubeNodes).List()
removeNodes := gceNodes.Difference(kubeNodes).Difference(emptyZoneNodesNames).List()
addNodes := kubeNodes.Difference(gceNodes).List()

if len(removeNodes) != 0 {
Expand Down Expand Up @@ -691,6 +696,9 @@ func (g *Cloud) ensureInternalInstanceGroups(name string, nodes []*v1.Node) ([]s
klog.V(2).Infof("ensureInternalInstanceGroups(%v): %d nodes over %d zones in region %v", name, len(nodes), len(zonedNodes), g.region)
var igLinks []string
for zone, nodes := range zonedNodes {
if zone == "" {
continue // skip ensuring nodes with empty zone
}
if g.AlphaFeatureGate.Enabled(AlphaFeatureSkipIGsManagement) {
igs, err := g.FilterInstanceGroupsByNamePrefix(name, zone)
if err != nil {
Expand All @@ -700,7 +708,7 @@ func (g *Cloud) ensureInternalInstanceGroups(name string, nodes []*v1.Node) ([]s
igLinks = append(igLinks, ig.SelfLink)
}
} else {
igLink, err := g.ensureInternalInstanceGroup(name, zone, nodes)
igLink, err := g.ensureInternalInstanceGroup(name, zone, nodes, zonedNodes[""])
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 37b5fb0

Please sign in to comment.