From 3afefecc8a596baf56e8278e39d3e485c8fa5e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Gr=C3=A4tz?= Date: Wed, 12 Oct 2022 21:33:17 +0200 Subject: [PATCH] Doc behaviour of default and interruptible NodeSelector and Tolerations --- go/tasks/plugins/k8s/spark/spark.go | 3 ++- go/tasks/plugins/k8s/spark/spark_test.go | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/go/tasks/plugins/k8s/spark/spark.go b/go/tasks/plugins/k8s/spark/spark.go index 358c9f11e..5b6f5c00f 100755 --- a/go/tasks/plugins/k8s/spark/spark.go +++ b/go/tasks/plugins/k8s/spark/spark.go @@ -240,7 +240,8 @@ func (sparkResourceHandler) BuildResource(ctx context.Context, taskCtx pluginsCo j.Spec.MainClass = &sparkJob.MainClass } - // Add Tolerations/NodeSelector to only Executor pods. + // Add Interruptible Tolerations/NodeSelector to only Executor pods. + // The Interruptible NodeSelector takes precedence over the DefaultNodeSelector if taskCtx.TaskExecutionMetadata().IsInterruptible() { j.Spec.Executor.Tolerations = append(j.Spec.Executor.Tolerations, config.GetK8sPluginConfig().InterruptibleTolerations...) j.Spec.Executor.NodeSelector = config.GetK8sPluginConfig().InterruptibleNodeSelector diff --git a/go/tasks/plugins/k8s/spark/spark_test.go b/go/tasks/plugins/k8s/spark/spark_test.go index 4c61864ee..af0816659 100755 --- a/go/tasks/plugins/k8s/spark/spark_test.go +++ b/go/tasks/plugins/k8s/spark/spark_test.go @@ -495,7 +495,10 @@ func TestBuildResourceSpark(t *testing.T) { assert.Equal(t, defaultPodHostNetwork, *sparkApp.Spec.Executor.HostNetwork) assert.Equal(t, defaultPodHostNetwork, *sparkApp.Spec.Driver.HostNetwork) - // Validate Interruptible Toleration and NodeSelector set for Executor but not Driver. + // Validate + // * Interruptible Toleration and NodeSelector set for Executor but not Driver. + // * Validate Default NodeSelector set for Driver but overwritten with Interruptible NodeSelector for Executor. + // * Default Tolerations set for both Driver and Executor. assert.Equal(t, 1, len(sparkApp.Spec.Driver.Tolerations)) assert.Equal(t, 1, len(sparkApp.Spec.Driver.NodeSelector)) assert.Equal(t, defaultNodeSelector, sparkApp.Spec.Driver.NodeSelector) @@ -589,6 +592,7 @@ func TestBuildResourceSpark(t *testing.T) { assert.True(t, ok) // Validate Interruptible Toleration and NodeSelector not set for both Driver and Executors. + // Validate that the default Toleration and NodeSelector are set for both Driver and Executors. assert.Equal(t, 1, len(sparkApp.Spec.Driver.Tolerations)) assert.Equal(t, 1, len(sparkApp.Spec.Driver.NodeSelector)) assert.Equal(t, defaultNodeSelector, sparkApp.Spec.Driver.NodeSelector)