From 2e17adc17769fd54989417668a020be12a872277 Mon Sep 17 00:00:00 2001 From: Daniel Rammer Date: Tue, 2 May 2023 18:33:20 -0500 Subject: [PATCH] added environment variables to ExecutionConfig and propagated to taskExecutionMetadata Signed-off-by: Daniel Rammer --- .../flyteworkflow/v1alpha1/execution_config.go | 2 ++ pkg/controller/nodes/task/taskexec_context.go | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/apis/flyteworkflow/v1alpha1/execution_config.go b/pkg/apis/flyteworkflow/v1alpha1/execution_config.go index 878df4768..0068b7a63 100644 --- a/pkg/apis/flyteworkflow/v1alpha1/execution_config.go +++ b/pkg/apis/flyteworkflow/v1alpha1/execution_config.go @@ -32,6 +32,8 @@ type ExecutionConfig struct { Interruptible *bool // Defines whether a workflow should skip all its cached results and re-compute its output, overwriting any already stored data. OverwriteCache bool + // Defines a map of environment varable name / value pairs that are applied to all tasks. + EnvironmentVariables map[string]string } type TaskPluginOverride struct { diff --git a/pkg/controller/nodes/task/taskexec_context.go b/pkg/controller/nodes/task/taskexec_context.go index 9e8296b3c..7abfd2599 100644 --- a/pkg/controller/nodes/task/taskexec_context.go +++ b/pkg/controller/nodes/task/taskexec_context.go @@ -59,10 +59,11 @@ func (te taskExecutionID) GetGeneratedNameWith(minLength, maxLength int) (string type taskExecutionMetadata struct { handler.NodeExecutionMetadata - taskExecID taskExecutionID - o pluginCore.TaskOverrides - maxAttempts uint32 - platformResources *v1.ResourceRequirements + taskExecID taskExecutionID + o pluginCore.TaskOverrides + maxAttempts uint32 + platformResources *v1.ResourceRequirements + environmentVariables map[string]string } func (t taskExecutionMetadata) GetTaskExecutionID() pluginCore.TaskExecutionID { @@ -81,6 +82,10 @@ func (t taskExecutionMetadata) GetPlatformResources() *v1.ResourceRequirements { return t.platformResources } +func (t taskExecutionMetadata) GetEnvironmentVariables() map[string]string { + return t.environmentVariables +} + type taskExecutionContext struct { handler.NodeExecutionContext tm taskExecutionMetadata @@ -289,6 +294,7 @@ func (t *Handler) newTaskExecutionContext(ctx context.Context, nCtx handler.Node o: nCtx.Node(), maxAttempts: maxAttempts, platformResources: convertTaskResourcesToRequirements(nCtx.ExecutionContext().GetExecutionConfig().TaskResources), + environmentVariables: nCtx.ExecutionContext().GetExecutionConfig().EnvironmentVariables, }, rm: resourcemanager.GetTaskResourceManager( t.resourceManager, resourceNamespacePrefix, id),