Skip to content

Commit

Permalink
Inherit execution cluster label from source execution (#5431)
Browse files Browse the repository at this point in the history
Signed-off-by: Vinayak Agarwal <[email protected]>
  • Loading branch information
va6996 authored Jun 20, 2024
1 parent 297cdf8 commit 16e7780
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions flyteadmin/pkg/manager/impl/execution_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ func (m *ExecutionManager) getInheritedExecMetadata(ctx context.Context, request
} else {
requestSpec.Metadata.Nesting = 1
}

// If the source execution has a cluster label, inherit it.
if sourceExecution.Spec.ExecutionClusterLabel != nil {
logger.Infof(ctx, "Inherited execution label from source execution [%+v]", sourceExecution.Spec.ExecutionClusterLabel.Value)
requestSpec.ExecutionClusterLabel = sourceExecution.Spec.ExecutionClusterLabel
}
return parentNodeExecutionID, sourceExecutionID, nil
}

Expand Down
3 changes: 3 additions & 0 deletions flyteadmin/pkg/manager/impl/execution_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ func TestCreateExecutionFromWorkflowNode(t *testing.T) {
)

getExecutionCalled := false
var clusterLabel = &admin.ExecutionClusterLabel{Value: executionClusterLabel}
repository.ExecutionRepo().(*repositoryMocks.MockExecutionRepo).SetGetCallback(
func(ctx context.Context, input interfaces.Identifier) (models.Execution, error) {
assert.EqualValues(t, input.Project, parentNodeExecutionID.ExecutionId.Project)
Expand All @@ -437,6 +438,7 @@ func TestCreateExecutionFromWorkflowNode(t *testing.T) {
Metadata: &admin.ExecutionMetadata{
Nesting: 1,
},
ExecutionClusterLabel: clusterLabel,
}
specBytes, _ := proto.Marshal(spec)
getExecutionCalled = true
Expand All @@ -462,6 +464,7 @@ func TestCreateExecutionFromWorkflowNode(t *testing.T) {
assert.EqualValues(t, input.SourceExecutionID, 2)
assert.Equal(t, 2, int(spec.Metadata.Nesting))
assert.Equal(t, principal, spec.Metadata.Principal)
assert.Equal(t, executionClusterLabel, spec.ExecutionClusterLabel.Value)
assert.Equal(t, principal, input.User)
return nil
},
Expand Down

0 comments on commit 16e7780

Please sign in to comment.