Skip to content

Commit

Permalink
UPSTREAM: <carry>: openshift: add fixes for node autodiscovery
Browse files Browse the repository at this point in the history
This change add a few necessary changes to ensure that the upstream node
autodiscovery patch works.

* Add logic to `newNodeGroupFromScalableResource` to detect condition
  where a node group is capable of scaling from zero.
* Change `clusterNameLabel` to match the openshift label.
* Fix TestNodeGroupTemplateNodeInfo unit test to use new create test
  config functions.
  • Loading branch information
elmiko committed Nov 30, 2020
1 parent 71ef9a5 commit bf74515
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ func newNodeGroupFromScalableResource(controller *machineController, unstructure
return nil, err
}

// We don't scale from 0 so nodes must belong to a nodegroup
// that has a scale size of at least 1.
if found && replicas == 0 {
// Ensure that if the nodegroup has 0 replicas it is capable
// of scaling before adding it.
if found && replicas == 0 && !scalableResource.CanScaleFromZero() {
return nil, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1210,15 +1210,15 @@ func TestNodeGroupTemplateNodeInfo(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Run("MachineSet", func(t *testing.T) {
test(t, createMachineSetTestConfig(testNamespace, RandomString(6), 10, cloudprovider.JoinStringMaps(enableScaleAnnotations, tc.nodeGroupAnnotations)),
test(t, createMachineSetTestConfig(testNamespace, RandomString(6), RandomString(6), 10, cloudprovider.JoinStringMaps(enableScaleAnnotations, tc.nodeGroupAnnotations)),
tc.config,
)
})

t.Run("MachineDeployment", func(t *testing.T) {
test(
t,
createMachineDeploymentTestConfig(testNamespace, RandomString(6), 10, cloudprovider.JoinStringMaps(enableScaleAnnotations, tc.nodeGroupAnnotations)),
createMachineDeploymentTestConfig(testNamespace, RandomString(6), RandomString(6), 10, cloudprovider.JoinStringMaps(enableScaleAnnotations, tc.nodeGroupAnnotations)),
tc.config,
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
const (
nodeGroupMinSizeAnnotationKey = "machine.openshift.io/cluster-api-autoscaler-node-group-min-size"
nodeGroupMaxSizeAnnotationKey = "machine.openshift.io/cluster-api-autoscaler-node-group-max-size"
clusterNameLabel = "cluster.x-k8s.io/cluster-name"
clusterNameLabel = "machine.openshift.io/cluster-name"
deprecatedClusterNameLabel = "cluster.k8s.io/cluster-name"

cpuKey = "machine.openshift.io/vCPU"
Expand Down

0 comments on commit bf74515

Please sign in to comment.