mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #95559 from prameshj/elb-update
Do not skip externalLB update if some nodes are not found.
This commit is contained in:
commit
6d3ccd8e6c
@ -561,7 +561,11 @@ func (g *Cloud) getInstancesByNames(names []string) ([]*gceInstance, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(foundInstances) != len(names) {
|
if len(foundInstances) != len(names) {
|
||||||
return nil, cloudprovider.InstanceNotFound
|
if len(foundInstances) == 0 {
|
||||||
|
// return error so the TargetPool nodecount does not drop to 0 unexpectedly.
|
||||||
|
return nil, cloudprovider.InstanceNotFound
|
||||||
|
}
|
||||||
|
klog.Warningf("getFoundInstanceByNames - input instances %d, found %d. Continuing LoadBalancer Update", len(names), len(foundInstances))
|
||||||
}
|
}
|
||||||
return foundInstances, nil
|
return foundInstances, nil
|
||||||
}
|
}
|
||||||
|
@ -372,6 +372,24 @@ func TestUpdateExternalLoadBalancer(t *testing.T) {
|
|||||||
[]string{fmt.Sprintf("/zones/%s/instances/%s", vals.ZoneName, nodeName)},
|
[]string{fmt.Sprintf("/zones/%s/instances/%s", vals.ZoneName, nodeName)},
|
||||||
pool.Instances,
|
pool.Instances,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
anotherNewNodeName := "test-node-3"
|
||||||
|
newNodes, err = createAndInsertNodes(gce, []string{nodeName, newNodeName, anotherNewNodeName}, vals.ZoneName)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
// delete one of the existing nodes, but include it in the list
|
||||||
|
err = gce.DeleteInstance(gce.ProjectID(), vals.ZoneName, nodeName)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// The update should ignore the reference to non-existent node "test-node-1", but update target pool with rest of the valid nodes.
|
||||||
|
err = gce.updateExternalLoadBalancer(vals.ClusterName, svc, newNodes)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
pool, err = gce.GetTargetPool(lbName, gce.region)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
namePrefix := fmt.Sprintf("/zones/%s/instances/", vals.ZoneName)
|
||||||
|
assert.ElementsMatch(t, pool.Instances, []string{namePrefix + newNodeName, namePrefix + anotherNewNodeName})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEnsureExternalLoadBalancerDeleted(t *testing.T) {
|
func TestEnsureExternalLoadBalancerDeleted(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user