Skip to content

Commit

Permalink
refactor: let flyte backend generate ID
Browse files Browse the repository at this point in the history
Signed-off-by: wayner0628 <[email protected]>
  • Loading branch information
wayner0628 committed Aug 12, 2024
1 parent 33fc45b commit 058baf7
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions flytectl/cmd/create/execution_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import (
"context"
"fmt"
"io/ioutil"
"strings"

cmdCore "github.com/flyteorg/flyte/flytectl/cmd/core"
cmdGet "github.com/flyteorg/flyte/flytectl/cmd/get"
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin"
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flytestdlib/logger"
"github.com/google/uuid"
"sigs.k8s.io/yaml"
)

Expand Down Expand Up @@ -53,7 +51,7 @@ func createExecutionRequestForWorkflow(ctx context.Context, workflowName, projec
}
}

return createExecutionRequest(lp.Id, inputs, envs, securityContext, authRole, targetExecName, executionConfig.TargetExecutionCluster), nil
return createExecutionRequest(lp.Id, inputs, envs, securityContext, authRole, executionConfig.TargetExecutionCluster), nil
}

func createExecutionRequestForTask(ctx context.Context, taskName string, project string, domain string,
Expand Down Expand Up @@ -101,7 +99,7 @@ func createExecutionRequestForTask(ctx context.Context, taskName string, project
Version: task.Id.Version,
}

return createExecutionRequest(id, inputs, envs, securityContext, authRole, targetExecName, executionConfig.TargetExecutionCluster), nil
return createExecutionRequest(id, inputs, envs, securityContext, authRole, executionConfig.TargetExecutionCluster), nil
}

func relaunchExecution(ctx context.Context, executionName string, project string, domain string,
Expand Down Expand Up @@ -147,11 +145,8 @@ func recoverExecution(ctx context.Context, executionName string, project string,
return nil
}

func createExecutionRequest(ID *core.Identifier, inputs *core.LiteralMap, envs *admin.Envs, securityContext *core.SecurityContext, authRole *admin.AuthRole, targetExecName string, targetExecutionCluster string) *admin.ExecutionCreateRequest {
func createExecutionRequest(ID *core.Identifier, inputs *core.LiteralMap, envs *admin.Envs, securityContext *core.SecurityContext, authRole *admin.AuthRole, targetExecutionCluster string) *admin.ExecutionCreateRequest {

if len(targetExecName) == 0 {
targetExecName = "f" + strings.ReplaceAll(uuid.New().String(), "-", "")[:19]
}
var clusterAssignment *admin.ClusterAssignment
if executionConfig.ClusterPool != "" {
clusterAssignment = &admin.ClusterAssignment{ClusterPoolName: executionConfig.ClusterPool}
Expand All @@ -163,7 +158,6 @@ func createExecutionRequest(ID *core.Identifier, inputs *core.LiteralMap, envs *
return &admin.ExecutionCreateRequest{
Project: executionConfig.TargetProject,
Domain: executionConfig.TargetDomain,
Name: targetExecName,
Spec: &admin.ExecutionSpec{
LaunchPlan: ID,
Metadata: &admin.ExecutionMetadata{
Expand Down

0 comments on commit 058baf7

Please sign in to comment.