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

Commit

Permalink
Save execution namespace in system metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Katrina Rogan <[email protected]>
  • Loading branch information
katrogan committed May 22, 2023
1 parent 313ac29 commit 9e9d6c4
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/cloudevents/sdk-go/v2 v2.8.0
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/evanphx/json-patch v4.12.0+incompatible
github.com/flyteorg/flyteidl v1.5.5
github.com/flyteorg/flyteidl v1.5.7-0.20230522164738-0484cf8e75cc
github.com/flyteorg/flyteplugins v1.0.56
github.com/flyteorg/flytepropeller v1.1.87
github.com/flyteorg/flytestdlib v1.0.15
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/flyteorg/flyteidl v1.5.5 h1:tNNhuXPog4atAMSGE2kyAg6JzYy1TvjqrrQeh1EZVHs=
github.com/flyteorg/flyteidl v1.5.5/go.mod h1:EtE/muM2lHHgBabjYcxqe9TWeJSL0kXwbI0RgVwI4Og=
github.com/flyteorg/flyteidl v1.5.7-0.20230522164738-0484cf8e75cc h1:PDvp09skGb7AEN2L5OSi11Fb0/ttRDAbsm8ZkKPsBGM=
github.com/flyteorg/flyteidl v1.5.7-0.20230522164738-0484cf8e75cc/go.mod h1:EtE/muM2lHHgBabjYcxqe9TWeJSL0kXwbI0RgVwI4Og=
github.com/flyteorg/flyteplugins v1.0.56 h1:kBTDgTpdSi7wcptk4cMwz5vfh1MU82VaUMMboe1InXw=
github.com/flyteorg/flyteplugins v1.0.56/go.mod h1:aFCKSn8TPzxSAILIiogHtUnHlUCN9+y6Vf+r9R4KZDU=
github.com/flyteorg/flytepropeller v1.1.87 h1:Px7ASDjrWyeVrUb15qXmhw9QK7xPcFjL5Yetr2P6iGM=
Expand Down
2 changes: 2 additions & 0 deletions pkg/manager/impl/execution_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ func (m *ExecutionManager) launchSingleTaskExecution(
UserInputsURI: userInputsURI,
SecurityContext: executionConfig.SecurityContext,
LaunchEntity: taskIdentifier.ResourceType,
Namespace: namespace,
})
if err != nil {
logger.Infof(ctx, "Failed to create execution model in transformer for id: [%+v] with err: %v",
Expand Down Expand Up @@ -905,6 +906,7 @@ func (m *ExecutionManager) launchExecutionAndPrepareModel(
UserInputsURI: userInputsURI,
SecurityContext: executionConfig.SecurityContext,
LaunchEntity: launchPlan.Id.ResourceType,
Namespace: namespace,
})
if err != nil {
logger.Infof(ctx, "Failed to create execution model in transformer for id: [%+v] with err: %v",
Expand Down
1 change: 1 addition & 0 deletions pkg/manager/impl/execution_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ func TestCreateExecution(t *testing.T) {
assert.Equal(t, rawOutput, spec.RawOutputDataConfig.OutputLocationPrefix)
assert.True(t, proto.Equal(spec.ClusterAssignment, &clusterAssignment))
assert.Equal(t, "launch_plan", input.LaunchEntity)
assert.Equal(t, spec.GetMetadata().GetSystemMetadata().Namespace, "project-domain")
return nil
})
setDefaultLpCallbackForExecTest(repository)
Expand Down
2 changes: 2 additions & 0 deletions pkg/repositories/transformers/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type CreateExecutionModelInput struct {
UserInputsURI storage.DataReference
SecurityContext *core.SecurityContext
LaunchEntity core.ResourceType
Namespace string
}

type ExecutionTransformerOptions struct {
Expand All @@ -63,6 +64,7 @@ func CreateExecutionModel(input CreateExecutionModelInput) (*models.Execution, e
}
requestSpec.Metadata.SystemMetadata = &admin.SystemMetadata{
ExecutionCluster: input.Cluster,
Namespace: input.Namespace,
}
requestSpec.SecurityContext = input.SecurityContext
spec, err := proto.Marshal(requestSpec)
Expand Down
3 changes: 3 additions & 0 deletions pkg/repositories/transformers/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func TestCreateExecutionModel(t *testing.T) {
IamRole: "iam_role",
},
}
namespace := "ns"
execution, err := CreateExecutionModel(CreateExecutionModelInput{
WorkflowExecutionID: core.WorkflowExecutionIdentifier{
Project: "project",
Expand All @@ -89,6 +90,7 @@ func TestCreateExecutionModel(t *testing.T) {
Cluster: cluster,
SecurityContext: securityCtx,
LaunchEntity: core.ResourceType_LAUNCH_PLAN,
Namespace: namespace,
})
assert.NoError(t, err)
assert.Equal(t, "project", execution.Project)
Expand All @@ -106,6 +108,7 @@ func TestCreateExecutionModel(t *testing.T) {
expectedSpec.Metadata.Principal = principal
expectedSpec.Metadata.SystemMetadata = &admin.SystemMetadata{
ExecutionCluster: cluster,
Namespace: namespace,
}
expectedSpec.SecurityContext = securityCtx
expectedSpecBytes, _ := proto.Marshal(expectedSpec)
Expand Down

0 comments on commit 9e9d6c4

Please sign in to comment.