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

FlyteAdmin will always add base_exec_id unless it is already added #616

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pkg/manager/impl/execution_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@
if err != nil {
return nil, nil, err
}
labels = m.addBaseExecutionLabel(ctx, workflowExecutionID.Name, labels)

var annotations map[string]string
if executionConfig.Annotations != nil {
Expand Down Expand Up @@ -810,6 +811,8 @@
if err != nil {
return nil, nil, err
}
labels = m.addBaseExecutionLabel(ctx, workflowExecutionID.Name, labels)

annotations, err := resolveStringMap(executionConfig.GetAnnotations(), launchPlan.Spec.Annotations, "annotations", m.config.RegistrationValidationConfiguration().GetMaxAnnotationEntries())
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -1687,6 +1690,19 @@
return initialLabels, nil
}

// Adds base execution label to execution labels. Base execution label is ignored if a corresponding label is set on the execution already.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Adds base execution label to execution labels. Base execution label is ignored if a corresponding label is set on the execution already.
// addBaseExecutionLabel adds base execution label to execution labels. Base execution label is ignored if a corresponding label is set on the execution already.

// An execution label will exist if Flytepropeller launches a child workflow execution, as it will copy the parent execution's labels.
// This label can later be used to retrieve all executions that were launched from a given execution, no matter how deep in the recursion tree.
func (m *ExecutionManager) addBaseExecutionLabel(_ context.Context, execID string, initialLabels map[string]string) map[string]string {
if initialLabels == nil {
initialLabels = make(map[string]string)
}

Check warning on line 1699 in pkg/manager/impl/execution_manager.go

View check run for this annotation

Codecov / codecov/patch

pkg/manager/impl/execution_manager.go#L1698-L1699

Added lines #L1698 - L1699 were not covered by tests
if _, ok := initialLabels[shared.BaseExecutionIDLabelKey]; !ok {
initialLabels[shared.BaseExecutionIDLabelKey] = execID
}
return initialLabels
}

func addStateFilter(filters []common.InlineFilter) ([]common.InlineFilter, error) {
var stateFilterExists bool
for _, inlineFilter := range filters {
Expand Down
10 changes: 6 additions & 4 deletions pkg/manager/impl/execution_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,9 @@ func TestCreateExecutionDynamicLabelsAndAnnotations(t *testing.T) {
mockExecutor := workflowengineMocks.WorkflowExecutor{}
mockExecutor.OnExecuteMatch(mock.Anything, mock.MatchedBy(func(executionData workflowengineInterfaces.ExecutionData) bool {
assert.EqualValues(t, map[string]string{
"dynamiclabel1": "dynamic1",
"dynamiclabel2": "dynamic2",
"dynamiclabel1": "dynamic1",
"dynamiclabel2": "dynamic2",
shared.BaseExecutionIDLabelKey: "name",
}, executionData.ExecutionParameters.Labels)
assert.EqualValues(t, map[string]string{
"dynamicannotation3": "dynamic3",
Expand Down Expand Up @@ -3834,8 +3835,9 @@ func TestCreateExecution_LegacyClient(t *testing.T) {
mockExecutor := workflowengineMocks.WorkflowExecutor{}
mockExecutor.OnExecuteMatch(mock.Anything, mock.MatchedBy(func(execData workflowengineInterfaces.ExecutionData) bool {
assert.EqualValues(t, map[string]string{
"label1": "1",
"label2": "2",
"label1": "1",
"label2": "2",
shared.BaseExecutionIDLabelKey: "name",
}, execData.ExecutionParameters.Labels)
assert.EqualValues(t, map[string]string{
"annotation3": "3",
Expand Down
7 changes: 5 additions & 2 deletions pkg/manager/impl/shared/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const (
Attributes = "attributes"
MatchingAttributes = "matching_attributes"
// Parent of a node execution in the node executions table
ParentID = "parent_id"
WorkflowClosure = "workflow_closure"
ParentID = "parent_id"
WorkflowClosure = "workflow_closure"
BaseExecutionIDLabelKey = "base_exec_id"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call it parent_exec_id? just to keep names consistent... I understand that for "self" execution that will sound weird... 🤷🏽 or maybe keep them as two separate labels?

// BaseExecutionIDLabelKey is the label key for the base execution ID and is globally known. The UI, CLI and potentially
// other components use this label key to identify the base execution ID, so DO NOT CHANGE THIS VALUE.
)
Loading