Skip to content

Commit

Permalink
Added enableSchedule option on registration and linked missing docs (f…
Browse files Browse the repository at this point in the history
…lyteorg#324)

* Added enableSchedule option on registration

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Added docs and linked missing docs

Signed-off-by: Prafulla Mahindrakar <[email protected]>
  • Loading branch information
pmahindrakar-oss authored May 19, 2022
1 parent 5250230 commit 5a17906
Show file tree
Hide file tree
Showing 69 changed files with 125 additions and 6 deletions.
4 changes: 4 additions & 0 deletions cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ var completionCmd = &cobra.Command{
To load completions for each session:
- Linux
::
$ flytectl completion bash > /etc/bash_completion.d/flytectl
- macOS
::
$ flytectl completion bash > /usr/local/etc/bash_completion.d/flytectl
Expand All @@ -61,6 +63,7 @@ var completionCmd = &cobra.Command{
Start a new shell for this setup to take effect.
- fish
::
$ flytectl completion fish | source
Expand All @@ -72,6 +75,7 @@ var completionCmd = &cobra.Command{
$ flytectl completion fish > ~/.config/fish/completions/flytectl.fish
- PowerShell
::
PS> flytectl completion powershell | Out-String | Invoke-Expression
Expand Down
1 change: 1 addition & 0 deletions cmd/config/subcommand/register/files_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type FilesConfig struct {
DeprecatedSourceUploadPath string `json:"sourceUploadPath" pflag:",Deprecated: Update flyte admin to avoid having to configure storage access from flytectl."`
DestinationDirectory string `json:"destinationDirectory" pflag:",Location of source code in container."`
DryRun bool `json:"dryRun" pflag:",Execute command without making any modifications."`
EnableSchedule bool `json:"enableSchedule" pflag:",Enable the schedule if the files contain schedulable launchplan."`
}

func GetConfig() *FilesConfig {
Expand Down
1 change: 1 addition & 0 deletions cmd/config/subcommand/register/filesconfig_flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions cmd/config/subcommand/register/filesconfig_flags_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/get/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ var hundredChars = 100
var executionColumns = []printer.Column{
{Header: "Name", JSONPath: "$.id.name"},
{Header: "Launch Plan Name", JSONPath: "$.spec.launchPlan.name"},
{Header: "Version", JSONPath: "$.spec.launchPlan.version"},
{Header: "Type", JSONPath: "$.spec.launchPlan.resourceType"},
{Header: "Phase", JSONPath: "$.closure.phase"},
{Header: "Scheduled Time", JSONPath: "$.spec.metadata.scheduledAt"},
Expand Down
6 changes: 6 additions & 0 deletions cmd/register/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ Override Destination dir of source code in container during registration:
::
flytectl register file _pb_output/* -d development -p flytesnacks --continueOnError --version v2 --destinationDirectory "/root"
Enable schedule for the launchplans part of the serialized protobuf files:
::
flytectl register file _pb_output/* -d development -p flytesnacks --version v2 --enableSchedule
Usage
`
Expand Down
6 changes: 5 additions & 1 deletion cmd/register/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestRegisterFromFiles(t *testing.T) {
s.MockAdminClient.OnCreateTaskMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnCreateWorkflowMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnUpdateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
err := registerFromFilesFunc(s.Ctx, args, s.CmdCtx)
assert.Nil(t, err)
})
Expand All @@ -52,7 +53,7 @@ func TestRegisterFromFiles(t *testing.T) {
s.MockAdminClient.OnCreateTaskMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnCreateWorkflowMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)

s.MockAdminClient.OnUpdateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
mockDataProxy := s.MockClient.DataProxyClient().(*mocks.DataProxyServiceClient)
mockDataProxy.OnCreateUploadLocationMatch(s.Ctx, mock.Anything).Return(&service.CreateUploadLocationResponse{}, nil)

Expand All @@ -75,6 +76,7 @@ func TestRegisterFromFiles(t *testing.T) {
s.MockAdminClient.OnCreateTaskMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnCreateWorkflowMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnUpdateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockClient.DataProxyClient().(*mocks.DataProxyServiceClient).OnCreateUploadLocationMatch(mock.Anything, mock.Anything).Return(&service.CreateUploadLocationResponse{}, nil)
err = Register(s.Ctx, args, config.GetConfig(), s.CmdCtx)
assert.Nil(t, err)
Expand All @@ -95,6 +97,7 @@ func TestRegisterFromFiles(t *testing.T) {
s.MockAdminClient.OnCreateTaskMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnCreateWorkflowMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnUpdateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
err = registerFromFilesFunc(s.Ctx, args, s.CmdCtx)
assert.NotNil(t, err)
})
Expand Down Expand Up @@ -163,6 +166,7 @@ func TestRegisterFromFiles(t *testing.T) {
s.MockAdminClient.OnCreateTaskMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnCreateWorkflowMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockAdminClient.OnUpdateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil)
s.MockClient.DataProxyClient().(*mocks.DataProxyServiceClient).OnCreateUploadLocationMatch(mock.Anything, mock.Anything).Return(&service.CreateUploadLocationResponse{}, nil)
err = registerFromFilesFunc(s.Ctx, args, s.CmdCtx)
assert.Nil(t, err)
Expand Down
22 changes: 19 additions & 3 deletions cmd/register/register_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func unMarshalContents(ctx context.Context, fileContents []byte, fname string) (

}

func register(ctx context.Context, message proto.Message, cmdCtx cmdCore.CommandContext, dryRun bool) error {
func register(ctx context.Context, message proto.Message, cmdCtx cmdCore.CommandContext, dryRun, enableSchedule bool) error {
switch v := message.(type) {
case *admin.LaunchPlan:
launchPlan := message.(*admin.LaunchPlan)
Expand All @@ -144,7 +144,23 @@ func register(ctx context.Context, message proto.Message, cmdCtx cmdCore.Command
},
Spec: launchPlan.Spec,
})
return err
if err != nil {
return err
}
// Activate the launchplan
if enableSchedule {
_, err = cmdCtx.AdminClient().UpdateLaunchPlan(ctx, &admin.LaunchPlanUpdateRequest{
Id: &core.Identifier{
Project: config.GetConfig().Project,
Domain: config.GetConfig().Domain,
Name: launchPlan.Id.Name,
Version: launchPlan.Id.Version,
},
State: admin.LaunchPlanState_ACTIVE,
})
return err
}
return nil
case *admin.WorkflowSpec:
workflowSpec := message.(*admin.WorkflowSpec)
if dryRun {
Expand Down Expand Up @@ -581,7 +597,7 @@ func registerFile(ctx context.Context, fileName string, registerResults []Result
registerResults = append(registerResults, registerResult)
return registerResults, err
}
if err := register(ctx, spec, cmdCtx, config.DryRun); err != nil {
if err := register(ctx, spec, cmdCtx, config.DryRun, config.EnableSchedule); err != nil {
// If error is AlreadyExists then dont consider this to be an error but just a warning state
if grpcError := status.Code(err); grpcError == codes.AlreadyExists {
registerResult = Result{Name: fileName, Status: "Success", Info: fmt.Sprintf("%v", grpcError.String())}
Expand Down
3 changes: 2 additions & 1 deletion cmd/register/register_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func registerFilesSetup() {
rconfig.DefaultFilesConfig.AssumableIamRole = ""
rconfig.DefaultFilesConfig.K8sServiceAccount = ""
rconfig.DefaultFilesConfig.OutputLocationPrefix = ""
rconfig.DefaultFilesConfig.EnableSchedule = true
}

func TestGetSortedArchivedFileWithParentFolderList(t *testing.T) {
Expand Down Expand Up @@ -476,7 +477,7 @@ func TestRegister(t *testing.T) {
s := setup()
registerFilesSetup()
node := &admin.NodeExecution{}
err := register(s.Ctx, node, s.CmdCtx, rconfig.DefaultFilesConfig.DryRun)
err := register(s.Ctx, node, s.CmdCtx, rconfig.DefaultFilesConfig.DryRun, rconfig.DefaultFilesConfig.EnableSchedule)
assert.NotNil(t, err)
})
}
Expand Down
1 change: 1 addition & 0 deletions docs/source/config.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/execution.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/gen/flytectl.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/source/gen/flytectl_completion.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/gen/flytectl_config.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/gen/flytectl_config_discover.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/gen/flytectl_config_docs.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/source/gen/flytectl_config_init.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/gen/flytectl_config_validate.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/gen/flytectl_create.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/gen/flytectl_create_execution.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/gen/flytectl_create_project.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/gen/flytectl_delete.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5a17906

Please sign in to comment.