Skip to content

Commit

Permalink
fix(gce): dont return error for nodes without providerID
Browse files Browse the repository at this point in the history
  • Loading branch information
mweibel committed Nov 11, 2020
1 parent da455d5 commit 94749d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cluster-autoscaler/cloudprovider/gce/gce_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func (gce *GceCloudProvider) NodeGroups() []cloudprovider.NodeGroup {

// NodeGroupForNode returns the node group for the given node.
func (gce *GceCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.NodeGroup, error) {
if node.Spec.ProviderID == "" {
klog.V(6).Infof("Skipping the search for node group for the node '%s' because it has no spec.ProviderID", node.ObjectMeta.Name)
return nil, nil
}
ref, err := GceRefFromProviderId(node.Spec.ProviderID)
if err != nil {
klog.Errorf("Error extracting node.Spec.ProviderID for node %v: %v", node.Name, err)
Expand Down
10 changes: 10 additions & 0 deletions cluster-autoscaler/cloudprovider/gce/gce_cloud_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ func TestNodeGroupForNode(t *testing.T) {
mock.AssertExpectationsForObjects(t, gceManagerMock)
}

func TestNodeGroupForNodeWithNoProviderId(t *testing.T) {
gce := &GceCloudProvider{}
n := BuildTestNode("n1", 1000, 1000)
n.Spec.ProviderID = ""

nodeGroup, err := gce.NodeGroupForNode(n)
assert.NoError(t, err)
assert.Nil(t, nodeGroup)
}

func TestGetResourceLimiter(t *testing.T) {
gceManagerMock := &gceManagerMock{}
resourceLimiter := cloudprovider.NewResourceLimiter(
Expand Down

0 comments on commit 94749d1

Please sign in to comment.