Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Commit 7f7cdc5

Browse files
authored
Merge pull request #763 from mumoshu/fix-ca-scheduling
Fix node labeling to allow scheduling cluster-autoscaler to workers
2 parents 2960930 + 346e267 commit 7f7cdc5

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

core/nodepool/config/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,14 @@ func (c ProvidedConfig) Config() (*ComputedConfig, error) {
267267
return &config, nil
268268
}
269269

270+
func (c ProvidedConfig) NodeLabels() model.NodeLabels {
271+
labels := c.NodeSettings.NodeLabels
272+
if c.ClusterAutoscalerSupport.Enabled {
273+
labels["kube-aws.coreos.com/cluster-autoscaler-supported"] = "true"
274+
}
275+
return labels
276+
}
277+
270278
func (c ProvidedConfig) WorkerDeploymentSettings() WorkerDeploymentSettings {
271279
return WorkerDeploymentSettings{
272280
WorkerNodePoolConfig: c.WorkerNodePoolConfig,
@@ -380,14 +388,6 @@ type WorkerDeploymentSettings struct {
380388
DeploymentSettings
381389
}
382390

383-
func (c WorkerDeploymentSettings) NodeLabels() model.NodeLabels {
384-
labels := c.NodeSettings.NodeLabels
385-
if c.ClusterAutoscalerSupport.Enabled {
386-
labels["kube-aws.coreos.com/cluster-autoscaler-supported"] = "true"
387-
}
388-
return labels
389-
}
390-
391391
func (c WorkerDeploymentSettings) WorkerSecurityGroupRefs() []string {
392392
refs := []string{}
393393

model/controller.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ func NewDefaultController() Controller {
3535
},
3636
Tenancy: "default",
3737
},
38-
NodeSettings: NodeSettings{
39-
NodeLabels: NodeLabels{},
40-
Taints: Taints{},
41-
},
38+
NodeSettings: newNodeSettings(),
4239
}
4340
}
4441

model/node_pool_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func NewDefaultNodePoolConfig() NodePoolConfig {
4646
},
4747
Tenancy: "default",
4848
},
49+
NodeSettings: newNodeSettings(),
4950
SecurityGroupIds: []string{},
5051
Gpu: newDefaultGpu(),
5152
}

model/node_settings.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ type NodeSettings struct {
55
Taints Taints `yaml:"taints"`
66
}
77

8+
func newNodeSettings() NodeSettings {
9+
return NodeSettings{
10+
NodeLabels: NodeLabels{},
11+
Taints: Taints{},
12+
}
13+
}
14+
815
func (s NodeSettings) Validate() error {
916
if err := s.Taints.Valid(); err != nil {
1017
return err

test/integration/maincluster_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,9 +1397,10 @@ worker:
13971397
}
13981398

13991399
expectedNodeLabels := model.NodeLabels{
1400-
"kube-aws.coreos.com/role": "worker",
1400+
"kube-aws.coreos.com/cluster-autoscaler-supported": "true",
1401+
"kube-aws.coreos.com/role": "worker",
14011402
}
1402-
actualNodeLabels := c.NodePools[0].NodeLabels
1403+
actualNodeLabels := c.NodePools[0].NodeLabels()
14031404
if !reflect.DeepEqual(expectedNodeLabels, actualNodeLabels) {
14041405
t.Errorf("worker node labels didn't match: expected=%v, actual=%v", expectedNodeLabels, actualNodeLabels)
14051406
}

0 commit comments

Comments
 (0)