Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving from flyteadmin - FlyteAdmin will always add base_exec_id unless it is already added #4140

Closed
wants to merge 3 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 flyteadmin/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.
// 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 flyteadmin/pkg/manager/impl/execution_manager.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/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 flyteadmin/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 flyteadmin/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"
// 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