From 829f5ead05c61721a30f0a42118e17fb6f93ea26 Mon Sep 17 00:00:00 2001 From: Patrick Dillon Date: Sat, 3 Aug 2024 06:55:05 -0400 Subject: [PATCH] Vendoring local changes (?) --- .../providers/gce/gce_loadbalancer.go | 4 ++-- .../gce/gce_loadbalancer_internal.go | 21 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/vendor/k8s.io/cloud-provider-gcp/providers/gce/gce_loadbalancer.go b/vendor/k8s.io/cloud-provider-gcp/providers/gce/gce_loadbalancer.go index d28b8fb6f4..af3e5765ef 100644 --- a/vendor/k8s.io/cloud-provider-gcp/providers/gce/gce_loadbalancer.go +++ b/vendor/k8s.io/cloud-provider-gcp/providers/gce/gce_loadbalancer.go @@ -166,7 +166,7 @@ func (g *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, svc return nil, err } - klog.V(4).Infof("EnsureLoadBalancer(%v, %v, %v, %v, %v): ensure %v loadbalancer", clusterName, svc.Namespace, svc.Name, loadBalancerName, g.region, desiredScheme) + klog.V(4).Infof("debug EnsureLoadBalancer(%v, %v, %v, %v, %v): ensure %v loadbalancer", clusterName, svc.Namespace, svc.Name, loadBalancerName, g.region, desiredScheme) existingFwdRule, err := g.GetRegionForwardingRule(loadBalancerName, g.region) if err != nil && !isNotFound(err) { @@ -203,7 +203,7 @@ func (g *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, svc status, err = g.ensureExternalLoadBalancer(clusterName, clusterID, svc, existingFwdRule, nodes) } if err != nil { - klog.Errorf("Failed to EnsureLoadBalancer(%s, %s, %s, %s, %s), err: %v", clusterName, svc.Namespace, svc.Name, loadBalancerName, g.region, err) + klog.Errorf("DEBUG Failed to EnsureLoadBalancer(%s, %s, %s, %s, %s), err: %v", clusterName, svc.Namespace, svc.Name, loadBalancerName, g.region, err) return status, err } klog.V(4).Infof("EnsureLoadBalancer(%s, %s, %s, %s, %s): done ensuring loadbalancer.", clusterName, svc.Namespace, svc.Name, loadBalancerName, g.region) diff --git a/vendor/k8s.io/cloud-provider-gcp/providers/gce/gce_loadbalancer_internal.go b/vendor/k8s.io/cloud-provider-gcp/providers/gce/gce_loadbalancer_internal.go index 1c493abdbd..742f560fb3 100644 --- a/vendor/k8s.io/cloud-provider-gcp/providers/gce/gce_loadbalancer_internal.go +++ b/vendor/k8s.io/cloud-provider-gcp/providers/gce/gce_loadbalancer_internal.go @@ -80,7 +80,7 @@ func (g *Cloud) ensureInternalLoadBalancer(clusterName, clusterID string, svc *v }() loadBalancerName := g.GetLoadBalancerName(context.TODO(), clusterName, svc) - klog.V(2).Infof("ensureInternalLoadBalancer(%v): Attaching %q finalizer", loadBalancerName, ILBFinalizerV1) + klog.V(2).Infof("DEBUG ensureInternalLoadBalancer(%v): Attaching %q finalizer", loadBalancerName, ILBFinalizerV1) if err := addFinalizer(svc, g.client.CoreV1(), ILBFinalizerV1); err != nil { klog.Errorf("Failed to attach finalizer '%s' on service %s/%s - %v", ILBFinalizerV1, svc.Namespace, svc.Name, err) return nil, err @@ -147,7 +147,7 @@ func (g *Cloud) ensureInternalLoadBalancer(clusterName, clusterID string, svc *v // or specified in the Service spec, then requestedIP = "". ipToUse := ilbIPToUse(svc, existingFwdRule, subnetworkURL) - klog.V(2).Infof("ensureInternalLoadBalancer(%v): Using subnet %s for LoadBalancer IP %s", loadBalancerName, options.SubnetName, ipToUse) + klog.V(2).Infof("DEBUG ensureInternalLoadBalancer(%v): Using subnet %s for LoadBalancer IP %s", loadBalancerName, options.SubnetName, ipToUse) var addrMgr *addressManager // If the network is not a legacy network, use the address manager @@ -554,7 +554,7 @@ func (g *Cloud) ensureInternalHealthCheck(name string, svcName types.NamespacedN } func (g *Cloud) ensureInternalInstanceGroup(name, zone string, nodes []string) (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, nodes, len(nodes)) + klog.V(2).Infof("DEBUG ensureInternalInstanceGroup(%v, %v): checking group that it contains %v nodes [node names limited, total number of nodes: %d]", name, zone, nodes, len(nodes)) ig, err := g.GetInstanceGroup(name, zone) if err != nil && !isNotFound(err) { return "", err @@ -623,7 +623,7 @@ func (g *Cloud) ensureInternalInstanceGroup(name, zone string, nodes []string) ( // where a K8s node exists. It also ensures that each node belongs to an instance group func (g *Cloud) ensureInternalInstanceGroups(name string, nodes []*v1.Node) ([]string, error) { zonedNodes := splitNodesByZone(nodes) - klog.V(2).Infof("ensureInternalInstanceGroups(%v): %d nodes over %d zones in region %v", name, len(nodes), len(zonedNodes), g.region) + klog.V(2).Infof("DEBUG ensureInternalInstanceGroups(%v): %d nodes over %d zones in region %v", name, len(nodes), len(zonedNodes), g.region) var igLinks []string gceZonedNodes := map[string][]string{} @@ -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() + if names.HasAll(groupInstanceNames...) || g.allHaveNodePrefix(groupInstanceNames) { igLinks = append(igLinks, ig.SelfLink) skip.Insert(groupInstances.UnsortedList()...) } @@ -677,6 +678,7 @@ func (g *Cloud) ensureInternalInstanceGroups(name string, nodes []*v1.Node) ([]s gceZonedNodes[zone] = remaining } } + klog.V(2).Infof("DEBUG gceZonedNodes: %v", gceZonedNodes) for zone, gceNodes := range gceZonedNodes { igLink, err := g.ensureInternalInstanceGroup(name, zone, gceNodes) if err != nil { @@ -695,6 +697,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)