Skip to content

Commit

Permalink
Merge pull request #3057 from JoelSpeed/external-node-ids
Browse files Browse the repository at this point in the history
CAPI: Do not normalize Node IDs outside of CAPI provider
  • Loading branch information
k8s-ci-robot authored May 27, 2020
2 parents 0255c11 + 5e0126a commit 0f504d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ func TestControllerMachineSetNodeNamesUsingProviderID(t *testing.T) {
})

for i := range testConfig.nodes {
if nodeNames[i].Id != string(normalizedProviderString(testConfig.nodes[i].Spec.ProviderID)) {
if nodeNames[i].Id != testConfig.nodes[i].Spec.ProviderID {
t.Fatalf("expected %q, got %q", testConfig.nodes[i].Spec.ProviderID, nodeNames[i].Id)
}
}
Expand Down Expand Up @@ -1035,7 +1035,7 @@ func TestControllerMachineSetNodeNamesUsingStatusNodeRefName(t *testing.T) {
})

for i := range testConfig.nodes {
if nodeNames[i].Id != string(normalizedProviderString(testConfig.nodes[i].Spec.ProviderID)) {
if nodeNames[i].Id != testConfig.nodes[i].Spec.ProviderID {
t.Fatalf("expected %q, got %q", testConfig.nodes[i].Spec.ProviderID, nodeNames[i].Id)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,14 @@ func (ng *nodegroup) Nodes() ([]cloudprovider.Instance, error) {
return nil, err
}

// Nodes do not have normalized IDs, so do not normalize the ID here.
// The IDs returned here are used to check if a node is registered or not and
// must match the ID on the Node object itself.
// https://github.com/kubernetes/autoscaler/blob/a973259f1852303ba38a3a61eeee8489cf4e1b13/cluster-autoscaler/clusterstate/clusterstate.go#L967-L985
instances := make([]cloudprovider.Instance, len(nodes))
for i := range nodes {
instances[i] = cloudprovider.Instance{
Id: string(normalizedProviderString(nodes[i])),
Id: nodes[i],
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ func TestNodeGroupDeleteNodes(t *testing.T) {
})

for i := 0; i < len(nodeNames); i++ {
if nodeNames[i].Id != string(normalizedProviderString(testConfig.nodes[i].Spec.ProviderID)) {
if nodeNames[i].Id != testConfig.nodes[i].Spec.ProviderID {
t.Fatalf("expected %q, got %q", testConfig.nodes[i].Spec.ProviderID, nodeNames[i].Id)
}
}
Expand Down Expand Up @@ -844,7 +844,7 @@ func TestNodeGroupDeleteNodesTwice(t *testing.T) {
})

for i := 0; i < len(nodeNames); i++ {
if nodeNames[i].Id != string(normalizedProviderString(testConfig.nodes[i].Spec.ProviderID)) {
if nodeNames[i].Id != testConfig.nodes[i].Spec.ProviderID {
t.Fatalf("expected %q, got %q", testConfig.nodes[i].Spec.ProviderID, nodeNames[i].Id)
}
}
Expand Down Expand Up @@ -998,7 +998,7 @@ func TestNodeGroupWithFailedMachine(t *testing.T) {
nodeIndex = i
}

if nodeNames[i].Id != string(normalizedProviderString(testConfig.nodes[nodeIndex].Spec.ProviderID)) {
if nodeNames[i].Id != testConfig.nodes[nodeIndex].Spec.ProviderID {
t.Fatalf("expected %q, got %q", testConfig.nodes[nodeIndex].Spec.ProviderID, nodeNames[i].Id)
}
}
Expand Down

0 comments on commit 0f504d3

Please sign in to comment.