Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
PodSpec NodeSelectors overwrite the default k8s plugin settings (#303)
Browse files Browse the repository at this point in the history
* PodSpec NodeSelectors overwrite the default k8s plugin settings

Signed-off-by: Dan Rammer <[email protected]>

* added unit test

Signed-off-by: Dan Rammer <[email protected]>

* better node selector value

Signed-off-by: Dan Rammer <[email protected]>

* fixed issue with unionmaps where k8s plugin overrides labels

Signed-off-by: Dan Rammer <[email protected]>

Signed-off-by: Dan Rammer <[email protected]>
  • Loading branch information
hamersaw authored Dec 27, 2022
1 parent 2859755 commit 8efeda7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go/tasks/pluginmachinery/flytek8s/pod_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func UpdatePod(taskExecutionMetadata pluginsCore.TaskExecutionMetadata,
if len(podSpec.SchedulerName) == 0 {
podSpec.SchedulerName = config.GetK8sPluginConfig().SchedulerName
}
podSpec.NodeSelector = utils.UnionMaps(podSpec.NodeSelector, config.GetK8sPluginConfig().DefaultNodeSelector)
podSpec.NodeSelector = utils.UnionMaps(config.GetK8sPluginConfig().DefaultNodeSelector, podSpec.NodeSelector)
if taskExecutionMetadata.IsInterruptible() {
podSpec.NodeSelector = utils.UnionMaps(podSpec.NodeSelector, config.GetK8sPluginConfig().InterruptibleNodeSelector)
}
Expand Down
2 changes: 1 addition & 1 deletion go/tasks/pluginmachinery/flytek8s/pod_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func toK8sPodInterruptible(t *testing.T) {
assert.Len(t, p.Tolerations, 2)
assert.Equal(t, "x/flyte", p.Tolerations[1].Key)
assert.Equal(t, "interruptible", p.Tolerations[1].Value)
assert.Equal(t, 1, len(p.NodeSelector))
assert.Equal(t, 2, len(p.NodeSelector))
assert.Equal(t, "true", p.NodeSelector["x/interruptible"])
assert.EqualValues(
t,
Expand Down
2 changes: 2 additions & 0 deletions go/tasks/pluginmachinery/flytek8s/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ plugins:
- FLYTE_AWS_ENDPOINT: "http://minio.flyte:9000"
- FLYTE_AWS_ACCESS_KEY_ID: minio
- FLYTE_AWS_SECRET_ACCESS_KEY: miniostorage
default-node-selector:
user: 'default'
default-pod-security-context:
runAsUser: 1000
runAsGroup: 3000
Expand Down
2 changes: 1 addition & 1 deletion go/tasks/plugins/array/k8s/subtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func addMetadata(stCtx SubTaskExecutionContext, cfg *Config, k8sPluginCfg *confi

pod.SetNamespace(namespace)
pod.SetAnnotations(utils.UnionMaps(k8sPluginCfg.DefaultAnnotations, pod.GetAnnotations(), utils.CopyMap(taskExecutionMetadata.GetAnnotations())))
pod.SetLabels(utils.UnionMaps(pod.GetLabels(), utils.CopyMap(taskExecutionMetadata.GetLabels()), k8sPluginCfg.DefaultLabels))
pod.SetLabels(utils.UnionMaps(k8sPluginCfg.DefaultLabels, pod.GetLabels(), utils.CopyMap(taskExecutionMetadata.GetLabels())))
pod.SetName(taskExecutionMetadata.GetTaskExecutionID().GetGeneratedName())

if !cfg.RemoteClusterConfig.Enabled {
Expand Down

0 comments on commit 8efeda7

Please sign in to comment.