From 7db30142721fba905142bbf5c580f4c53be692f3 Mon Sep 17 00:00:00 2001 From: Catalin Toda Date: Thu, 1 Oct 2020 14:03:51 -0700 Subject: [PATCH] Set labels in workflow metadata --- go.mod | 4 ++-- go.sum | 3 +++ pkg/manager/impl/execution_manager.go | 7 +++++++ pkg/workflowengine/impl/propeller_executor.go | 2 ++ pkg/workflowengine/interfaces/executor.go | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 957e352b4..f495a5e88 100644 --- a/go.mod +++ b/go.mod @@ -25,8 +25,8 @@ require ( github.com/jinzhu/gorm v1.9.12 github.com/kelseyhightower/envconfig v1.4.0 // indirect github.com/lib/pq v1.3.0 - github.com/lyft/flyteidl v0.18.6 - github.com/lyft/flytepropeller v0.3.17 + github.com/lyft/flyteidl v0.18.7 + github.com/lyft/flytepropeller v0.4.2-0.20201001203502-c9d4b2a9b8dd github.com/lyft/flytestdlib v0.3.9 github.com/magiconair/properties v1.8.1 github.com/mitchellh/mapstructure v1.1.2 diff --git a/go.sum b/go.sum index 068f8cf07..bfcf30760 100644 --- a/go.sum +++ b/go.sum @@ -464,9 +464,12 @@ github.com/lyft/flyteidl v0.17.0/go.mod h1:/zQXxuHO11u/saxTTZc8oYExIGEShXB+xCB1/ github.com/lyft/flyteidl v0.18.0/go.mod h1:/zQXxuHO11u/saxTTZc8oYExIGEShXB+xCB1/F1Cu20= github.com/lyft/flyteidl v0.18.6 h1:HGbxHI8avEDvoPqcO2+/BoJVcP9sjOj4qwJ/wNRWuoA= github.com/lyft/flyteidl v0.18.6/go.mod h1:/zQXxuHO11u/saxTTZc8oYExIGEShXB+xCB1/F1Cu20= +github.com/lyft/flyteidl v0.18.7/go.mod h1:/zQXxuHO11u/saxTTZc8oYExIGEShXB+xCB1/F1Cu20= github.com/lyft/flyteplugins v0.5.1/go.mod h1:8zhqFG9BzbHNQGEXzGYltTJLD+KTmQZkanxXgeFI25c= github.com/lyft/flytepropeller v0.3.17 h1:a2PVqWjnn8oNEeayAqNizMAtEixl/F3S4vd8z4kbiqI= github.com/lyft/flytepropeller v0.3.17/go.mod h1:T8Utxqv7B5USAX9c/Qh0lBbKXHFSgOwwaISOd9h36P4= +github.com/lyft/flytepropeller v0.4.2-0.20201001203502-c9d4b2a9b8dd h1:8sJkOTTVM1jnQtn1xYiVM1gP4L9zEUBr0OGCWs2czxQ= +github.com/lyft/flytepropeller v0.4.2-0.20201001203502-c9d4b2a9b8dd/go.mod h1:TIiWv/ZP1KOI0mqeUbiMqSn2XuY8O8kn8fQc5tWcaLA= github.com/lyft/flytestdlib v0.3.0 h1:nIkX4MlyYdcLLzaF35RI2P5BhARt+qMgHoFto8eVNzU= github.com/lyft/flytestdlib v0.3.0/go.mod h1:LJPPJlkFj+wwVWMrQT3K5JZgNhZi2mULsCG4ZYhinhU= github.com/lyft/flytestdlib v0.3.9 h1:NaKp9xkeWWwhVvqTOcR/FqlASy1N2gu/kN7PVe4S7YI= diff --git a/pkg/manager/impl/execution_manager.go b/pkg/manager/impl/execution_manager.go index 202050579..2a4763684 100644 --- a/pkg/manager/impl/execution_manager.go +++ b/pkg/manager/impl/execution_manager.go @@ -619,6 +619,12 @@ func (m *ExecutionManager) launchExecutionAndPrepareModel( return nil, nil, err } + projectLabels := make(map[string]string) + project, err := m.db.ProjectRepo().Get(ctx, request.Project) + if err != nil { + projectLabels = project.labels.values + } + // TODO: Reduce CRD size and use offloaded input URI to blob store instead. executeWorkflowInputs := workflowengineInterfaces.ExecuteWorkflowInput{ ExecutionID: &workflowExecutionID, @@ -627,6 +633,7 @@ func (m *ExecutionManager) launchExecutionAndPrepareModel( Reference: *launchPlan, AcceptedAt: requestedAt, QueueingBudget: qualityOfService.QueuingBudget, + ProjectLabels: projectLabels, } err = m.addLabelsAndAnnotations(request.Spec, &executeWorkflowInputs) if err != nil { diff --git a/pkg/workflowengine/impl/propeller_executor.go b/pkg/workflowengine/impl/propeller_executor.go index f95229311..c91a73f5e 100644 --- a/pkg/workflowengine/impl/propeller_executor.go +++ b/pkg/workflowengine/impl/propeller_executor.go @@ -136,6 +136,7 @@ func (c *FlytePropeller) ExecuteWorkflow(ctx context.Context, input interfaces.E labels := addMapValues(input.Labels, flyteWf.Labels) flyteWf.Labels = labels + flyteWf.WorkflowMeta.ProjectLabels = labels annotations := addMapValues(input.Annotations, flyteWf.Annotations) flyteWf.Annotations = annotations addExecutionOverrides(input.TaskPluginOverrides, flyteWf) @@ -218,6 +219,7 @@ func (c *FlytePropeller) ExecuteTask(ctx context.Context, input interfaces.Execu labels := addMapValues(input.Labels, flyteWf.Labels) flyteWf.Labels = labels + flyteWf.WorkflowMeta.ProjectLabels = input.ProjectLabels annotations := addMapValues(input.Annotations, flyteWf.Annotations) flyteWf.Annotations = annotations diff --git a/pkg/workflowengine/interfaces/executor.go b/pkg/workflowengine/interfaces/executor.go index bd468ba28..073ed128a 100644 --- a/pkg/workflowengine/interfaces/executor.go +++ b/pkg/workflowengine/interfaces/executor.go @@ -19,6 +19,7 @@ type ExecuteWorkflowInput struct { Annotations map[string]string QueueingBudget time.Duration TaskPluginOverrides []*admin.PluginOverride + ProjectLabels map[string]string } type ExecuteTaskInput struct {