diff --git a/internal/temporalcli/commands.activity.go b/internal/temporalcli/commands.activity.go index e00e50047..0ab6cf305 100644 --- a/internal/temporalcli/commands.activity.go +++ b/internal/temporalcli/commands.activity.go @@ -173,6 +173,9 @@ func (c *TemporalActivityUpdateOptionsCommand) run(cctx *CommandContext, args [] } if exec != nil { + if c.ActivityId == "" { + return fmt.Errorf("either --activity-id and --workflow-id, or --query must be set") + } result, err := cl.WorkflowService().UpdateActivityOptions(cctx, &workflowservice.UpdateActivityOptionsRequest{ Namespace: c.Parent.Namespace, Execution: &common.WorkflowExecution{ @@ -208,21 +211,13 @@ func (c *TemporalActivityUpdateOptionsCommand) run(cctx *CommandContext, args [] } else { updateActivitiesOperation := &batch.BatchOperationUpdateActivityOptions{ Identity: c.Parent.Identity, - Activity: &batch.BatchOperationUpdateActivityOptions_Type{Type: c.ActivityType}, + Activity: &batch.BatchOperationUpdateActivityOptions_MatchAll{MatchAll: true}, UpdateMask: &fieldmaskpb.FieldMask{ Paths: updatePath, }, RestoreOriginal: c.RestoreOriginalOptions, } - if c.ActivityType != "" { - updateActivitiesOperation.Activity = &batch.BatchOperationUpdateActivityOptions_Type{Type: c.ActivityType} - } else if c.MatchAll { - updateActivitiesOperation.Activity = &batch.BatchOperationUpdateActivityOptions_MatchAll{MatchAll: true} - } else { - return fmt.Errorf("either Activity Type must be provided or MatchAll must be set to true") - } - batchReq.Operation = &workflowservice.StartBatchOperationRequest_UpdateActivityOptionsOperation{ UpdateActivityOptionsOperation: updateActivitiesOperation, } @@ -235,6 +230,10 @@ func (c *TemporalActivityUpdateOptionsCommand) run(cctx *CommandContext, args [] } func (c *TemporalActivityPauseCommand) run(cctx *CommandContext, args []string) error { + if c.ActivityId == "" { + return fmt.Errorf("Activity Id must be specified") + } + cl, err := dialClient(cctx, &c.Parent.ClientOptions) if err != nil { return err @@ -249,19 +248,12 @@ func (c *TemporalActivityPauseCommand) run(cctx *CommandContext, args []string) }, Identity: c.Identity, Reason: c.Reason, + Activity: &workflowservice.PauseActivityRequest_Id{Id: c.ActivityId}, } if request.Identity == "" { request.Identity = c.Parent.Identity } - if c.ActivityId != "" && c.ActivityType != "" { - return fmt.Errorf("either Activity Type or Activity Id, but not both") - } else if c.ActivityType != "" { - request.Activity = &workflowservice.PauseActivityRequest_Type{Type: c.ActivityType} - } else if c.ActivityId != "" { - request.Activity = &workflowservice.PauseActivityRequest_Id{Id: c.ActivityId} - } - _, err = cl.WorkflowService().PauseActivity(cctx, request) if err != nil { return fmt.Errorf("unable to pause Activity: %w", err) @@ -294,6 +286,10 @@ func (c *TemporalActivityUnpauseCommand) run(cctx *CommandContext, args []string } if exec != nil { // single workflow operation + if c.ActivityId == "" { + return fmt.Errorf("either --activity-id and --workflow-id, or --query must be set") + } + request := &workflowservice.UnpauseActivityRequest{ Namespace: c.Parent.Namespace, Execution: &common.WorkflowExecution{ @@ -304,14 +300,7 @@ func (c *TemporalActivityUnpauseCommand) run(cctx *CommandContext, args []string ResetHeartbeat: c.ResetHeartbeats, Jitter: durationpb.New(c.Jitter.Duration()), Identity: c.Parent.Identity, - } - - if c.ActivityId != "" && c.ActivityType != "" { - return fmt.Errorf("either Activity Type or Activity Id, but not both") - } else if c.ActivityType != "" { - request.Activity = &workflowservice.UnpauseActivityRequest_Type{Type: c.ActivityType} - } else if c.ActivityId != "" { - request.Activity = &workflowservice.UnpauseActivityRequest_Id{Id: c.ActivityId} + Activity: &workflowservice.UnpauseActivityRequest_Id{Id: c.ActivityId}, } _, err = cl.WorkflowService().UnpauseActivity(cctx, request) @@ -324,13 +313,7 @@ func (c *TemporalActivityUnpauseCommand) run(cctx *CommandContext, args []string ResetAttempts: c.ResetAttempts, ResetHeartbeat: c.ResetHeartbeats, Jitter: durationpb.New(c.Jitter.Duration()), - } - if c.ActivityType != "" { - unpauseActivitiesOperation.Activity = &batch.BatchOperationUnpauseActivities_Type{Type: c.ActivityType} - } else if c.MatchAll { - unpauseActivitiesOperation.Activity = &batch.BatchOperationUnpauseActivities_MatchAll{MatchAll: true} - } else { - return fmt.Errorf("either Activity Type must be provided or MatchAll must be set to true") + Activity: &batch.BatchOperationUnpauseActivities_MatchAll{MatchAll: true}, } batchReq.Operation = &workflowservice.StartBatchOperationRequest_UnpauseActivitiesOperation{ @@ -369,7 +352,12 @@ func (c *TemporalActivityResetCommand) run(cctx *CommandContext, args []string) } if exec != nil { // single workflow operation + if c.ActivityId == "" { + return fmt.Errorf("either --activity-id and --workflow-id, or --query must be set") + } + request := &workflowservice.ResetActivityRequest{ + Activity: &workflowservice.ResetActivityRequest_Id{Id: c.ActivityId}, Namespace: c.Parent.Namespace, Execution: &common.WorkflowExecution{ WorkflowId: c.WorkflowId, @@ -380,16 +368,6 @@ func (c *TemporalActivityResetCommand) run(cctx *CommandContext, args []string) ResetHeartbeat: c.ResetHeartbeats, } - if c.ActivityId != "" && c.ActivityType != "" { - return fmt.Errorf("either Activity Type or Activity Id, but not both") - } else if c.ActivityType != "" { - request.Activity = &workflowservice.ResetActivityRequest_Type{Type: c.ActivityType} - } else if c.ActivityId != "" { - request.Activity = &workflowservice.ResetActivityRequest_Id{Id: c.ActivityId} - } else { - return fmt.Errorf("either Activity Type or Activity Id must be provided") - } - resp, err := cl.WorkflowService().ResetActivity(cctx, request) if err != nil { return fmt.Errorf("unable to reset an Activity: %w", err) @@ -414,13 +392,7 @@ func (c *TemporalActivityResetCommand) run(cctx *CommandContext, args []string) KeepPaused: c.KeepPaused, Jitter: durationpb.New(c.Jitter.Duration()), RestoreOriginalOptions: c.RestoreOriginalOptions, - } - if c.ActivityType != "" { - resetActivitiesOperation.Activity = &batch.BatchOperationResetActivities_Type{Type: c.ActivityType} - } else if c.MatchAll { - resetActivitiesOperation.Activity = &batch.BatchOperationResetActivities_MatchAll{MatchAll: true} - } else { - return fmt.Errorf("either Activity Type must be provided or MatchAll must be set to true") + Activity: &batch.BatchOperationResetActivities_MatchAll{MatchAll: true}, } batchReq.Operation = &workflowservice.StartBatchOperationRequest_ResetActivitiesOperation{ diff --git a/internal/temporalcli/commands.activity_test.go b/internal/temporalcli/commands.activity_test.go index 28ff7a13b..5b12f7495 100644 --- a/internal/temporalcli/commands.activity_test.go +++ b/internal/temporalcli/commands.activity_test.go @@ -18,9 +18,8 @@ import ( ) const ( - activityId string = "dev-activity-id" - activityType string = "DevActivity" - identity string = "MyIdentity" + activityId string = "dev-activity-id" + identity string = "MyIdentity" ) func (s *SharedServerSuite) TestActivity_Complete() { @@ -227,33 +226,35 @@ func (s *SharedServerSuite) TestActivityPauseUnpause() { }, 5*time.Second, 100*time.Millisecond) } -func (s *SharedServerSuite) TestActivityPauseUnpauseByType() { +func (s *SharedServerSuite) TestActivityCommandFailed_NoActivityId() { run := s.waitActivityStarted() - res := sendActivityCommand("pause", run, s, "--activity-type", activityType) - s.NoError(res.Err) - - res = sendActivityCommand("unpause", run, s, "--activity-type", activityType, "--reset-attempts") - s.NoError(res.Err) -} -func (s *SharedServerSuite) TestActivityCommandFailed_NoActivityTpeOrId() { - run := s.waitActivityStarted() + // pause is single-workflow only + res := sendActivityCommand("pause", run, s) + s.ErrorContains(res.Err, "Activity Id must be specified") - commands := []string{"pause", "unpause", "reset"} - for _, command := range commands { - // should fail because both activity-id and activity-type are not provided - res := sendActivityCommand(command, run, s) - s.Error(res.Err) + // unpause and reset support both single-workflow and batch modes + for _, command := range []string{"unpause", "reset"} { + res = sendActivityCommand(command, run, s) + s.ErrorContains(res.Err, "either --activity-id and --workflow-id, or --query must be set") } } -func (s *SharedServerSuite) TestActivityCommandFailed_BothActivityTpeOrId() { +func (s *SharedServerSuite) TestActivityCommandFailed_BothWorkflowIdAndQuery() { run := s.waitActivityStarted() - commands := []string{"pause", "unpause", "reset"} + // unpause and reset support both single-workflow (--workflow-id) and batch + // (--query) modes; providing both at once should fail. + commands := []string{"unpause", "reset"} for _, command := range commands { - res := sendActivityCommand(command, run, s, "--activity-id", activityId, "--activity-type", activityType) - s.Error(res.Err) + res := s.Execute( + "activity", command, + "--workflow-id", run.GetID(), + "--query", "WorkflowType='DevWorkflow'", + "--activity-id", activityId, + "--address", s.Address(), + ) + s.ErrorContains(res.Err, "cannot set query when workflow ID is set") } } @@ -423,7 +424,7 @@ func (s *SharedServerSuite) TestUnpauseActivity_BatchSuccess() { "--address", s.Address(), "--query", query, "--reason", "unpause-test", - "--yes", "--match-all", + "--yes", ) s.NoError(cmdRes.Err) s.NotEmpty(startBatchRequest.JobId) @@ -507,7 +508,7 @@ func (s *SharedServerSuite) TestResetActivity_BatchSuccess() { "--address", s.Address(), "--query", query, "--reason", "unpause-test", - "--yes", "--match-all", + "--yes", ) s.NoError(cmdRes.Err) s.NotEmpty(startBatchRequest.JobId) diff --git a/internal/temporalcli/commands.gen.go b/internal/temporalcli/commands.gen.go index 9033584b4..ad01d3083 100644 --- a/internal/temporalcli/commands.gen.go +++ b/internal/temporalcli/commands.gen.go @@ -498,10 +498,9 @@ type TemporalActivityPauseCommand struct { Parent *TemporalActivityCommand Command cobra.Command WorkflowReferenceOptions - ActivityId string - ActivityType string - Identity string - Reason string + ActivityId string + Identity string + Reason string } func NewTemporalActivityPauseCommand(cctx *CommandContext, parent *TemporalActivityCommand) *TemporalActivityPauseCommand { @@ -511,13 +510,12 @@ func NewTemporalActivityPauseCommand(cctx *CommandContext, parent *TemporalActiv s.Command.Use = "pause [flags]" s.Command.Short = "Pause an Activity" if hasHighlighting { - s.Command.Long = "Pause an Activity.\n\nIf the Activity is not currently running (e.g. because it previously\nfailed), it will not be run again until it is unpaused.\n\nHowever, if the Activity is currently running, it will run until the next\ntime it fails, completes, or times out, at which point the pause will kick in.\n\nIf the Activity is on its last retry attempt and fails, the failure will\nbe returned to the caller, just as if the Activity had not been paused.\n\nActivities should be specified either by their Activity ID or Activity Type.\n\nFor example, specify the Activity and Workflow IDs like this:\n\n\x1b[1mtemporal activity pause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\x1b[0m\n\nTo later unpause the activity, see unpause. You may also want to\nreset the activity to unpause it while also starting it from the beginning." + s.Command.Long = "Pause an Activity.\n\nIf the Activity is not currently running (e.g. because it previously\nfailed), it will not be run again until it is unpaused.\n\nHowever, if the Activity is currently running, it will run until the next\ntime it fails, completes, or times out, at which point the pause will kick in.\n\nIf the Activity is on its last retry attempt and fails, the failure will\nbe returned to the caller, just as if the Activity had not been paused.\n\nSpecify the Activity and Workflow IDs:\n\n\x1b[1mtemporal activity pause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\x1b[0m\n\nTo later unpause the activity, see unpause. You may also want to\nreset the activity to unpause it while also starting it from the beginning." } else { - s.Command.Long = "Pause an Activity.\n\nIf the Activity is not currently running (e.g. because it previously\nfailed), it will not be run again until it is unpaused.\n\nHowever, if the Activity is currently running, it will run until the next\ntime it fails, completes, or times out, at which point the pause will kick in.\n\nIf the Activity is on its last retry attempt and fails, the failure will\nbe returned to the caller, just as if the Activity had not been paused.\n\nActivities should be specified either by their Activity ID or Activity Type.\n\nFor example, specify the Activity and Workflow IDs like this:\n\n```\ntemporal activity pause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n```\n\nTo later unpause the activity, see unpause. You may also want to\nreset the activity to unpause it while also starting it from the beginning." + s.Command.Long = "Pause an Activity.\n\nIf the Activity is not currently running (e.g. because it previously\nfailed), it will not be run again until it is unpaused.\n\nHowever, if the Activity is currently running, it will run until the next\ntime it fails, completes, or times out, at which point the pause will kick in.\n\nIf the Activity is on its last retry attempt and fails, the failure will\nbe returned to the caller, just as if the Activity had not been paused.\n\nSpecify the Activity and Workflow IDs:\n\n```\ntemporal activity pause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n```\n\nTo later unpause the activity, see unpause. You may also want to\nreset the activity to unpause it while also starting it from the beginning." } s.Command.Args = cobra.NoArgs - s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to pause. Either `activity-id` or `activity-type` must be provided, but not both.") - s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of the given `activity-type` will be paused. Mutually exclusive with `activity-id`. Note: Pausing Activity by Type is an experimental feature and may change in the future.") + s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to pause. Required.") s.Command.Flags().StringVar(&s.Identity, "identity", "", "The identity of the user or client submitting this request.") s.Command.Flags().StringVar(&s.Reason, "reason", "", "Reason for pausing the Activity.") s.WorkflowReferenceOptions.BuildFlags(s.Command.Flags()) @@ -534,11 +532,9 @@ type TemporalActivityResetCommand struct { Command cobra.Command SingleActivityOrBatchOptions ActivityId string - ActivityType string KeepPaused bool ResetAttempts bool ResetHeartbeats bool - MatchAll bool Jitter cliext.FlagDuration RestoreOriginalOptions bool } @@ -550,17 +546,15 @@ func NewTemporalActivityResetCommand(cctx *CommandContext, parent *TemporalActiv s.Command.Use = "reset [flags]" s.Command.Short = "Reset an Activity" if hasHighlighting { - s.Command.Long = "Reset an activity. This restarts the activity as if it were first being\nscheduled. That is, it will reset both the number of attempts and the\nactivity timeout, as well as, optionally, the\nheartbeat details.\n\nIf the activity may be executing (i.e. it has not yet timed out), the\nreset will take effect the next time it fails, heartbeats, or times out.\nIf is waiting for a retry (i.e. has failed or timed out), the reset\nwill apply immediately.\n\nIf the activity is already paused, it will be unpaused by default.\nYou can specify \x1b[1mkeep_paused\x1b[0m to prevent this.\n\nIf the activity is paused and the \x1b[1mkeep_paused\x1b[0m flag is not provided,\nit will be unpaused. If the activity is paused and \x1b[1mkeep_paused\x1b[0m flag\nis provided - it will stay paused.\n\nActivities can be specified by their Activity ID or Activity Type.\n\n### Resetting activities that heartbeat {#reset-heartbeats}\n\nActivities that heartbeat will receive a Canceled failure\nthe next time they heartbeat after a reset.\n\nIf, in your Activity, you need to do any cleanup when an Activity is\nreset, handle this error and then re-throw it when you've cleaned up.\n\nIf the \x1b[1mreset_heartbeats\x1b[0m flag is set, the heartbeat details will also be cleared.\n\nSpecify the Activity Type of ID and Workflow IDs:\n\n\x1b[1mtemporal activity reset \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --keep-paused\n --reset-heartbeats\x1b[0m\n\nEither \x1b[1mactivity-id\x1b[0m, \x1b[1mactivity-type\x1b[0m, or \x1b[1m--match-all\x1b[0m must be specified.\n\nActivities can be reset in bulk with a visibility query list filter.\nFor example, if you want to reset activities of type Foo:\n\n\x1b[1mtemporal activity reset \\\n --query 'TemporalResetInfo=\"property:activityType=Foo\"'\x1b[0m" + s.Command.Long = "Reset an activity. This restarts the activity as if it were first being\nscheduled. That is, it will reset both the number of attempts and the\nactivity timeout, as well as, optionally, the\nheartbeat details.\n\nIf the activity may be executing (i.e. it has not yet timed out), the\nreset will take effect the next time it fails, heartbeats, or times out.\nIf is waiting for a retry (i.e. has failed or timed out), the reset\nwill apply immediately.\n\nIf the activity is already paused, it will be unpaused by default.\nYou can specify \x1b[1mkeep_paused\x1b[0m to prevent this.\n\nIf the activity is paused and the \x1b[1mkeep_paused\x1b[0m flag is not provided,\nit will be unpaused. If the activity is paused and \x1b[1mkeep_paused\x1b[0m flag\nis provided - it will stay paused.\n\nEither \x1b[1m--activity-id\x1b[0m (with \x1b[1m--workflow-id\x1b[0m) or \x1b[1m--query\x1b[0m must be specified.\n\n### Resetting activities that heartbeat {#reset-heartbeats}\n\nActivities that heartbeat will receive a Canceled failure\nthe next time they heartbeat after a reset.\n\nIf, in your Activity, you need to do any cleanup when an Activity is\nreset, handle this error and then re-throw it when you've cleaned up.\n\nIf the \x1b[1mreset_heartbeats\x1b[0m flag is set, the heartbeat details will also be cleared.\n\nSpecify the Activity and Workflow IDs:\n\n\x1b[1mtemporal activity reset \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --keep-paused\n --reset-heartbeats\x1b[0m\n\nActivities can be reset in bulk with a visibility query list filter:\n\n\x1b[1mtemporal activity reset \\\n --query 'WorkflowType=\"YourWorkflow\"'\x1b[0m" } else { - s.Command.Long = "Reset an activity. This restarts the activity as if it were first being\nscheduled. That is, it will reset both the number of attempts and the\nactivity timeout, as well as, optionally, the\nheartbeat details.\n\nIf the activity may be executing (i.e. it has not yet timed out), the\nreset will take effect the next time it fails, heartbeats, or times out.\nIf is waiting for a retry (i.e. has failed or timed out), the reset\nwill apply immediately.\n\nIf the activity is already paused, it will be unpaused by default.\nYou can specify `keep_paused` to prevent this.\n\nIf the activity is paused and the `keep_paused` flag is not provided,\nit will be unpaused. If the activity is paused and `keep_paused` flag\nis provided - it will stay paused.\n\nActivities can be specified by their Activity ID or Activity Type.\n\n### Resetting activities that heartbeat {#reset-heartbeats}\n\nActivities that heartbeat will receive a Canceled failure\nthe next time they heartbeat after a reset.\n\nIf, in your Activity, you need to do any cleanup when an Activity is\nreset, handle this error and then re-throw it when you've cleaned up.\n\nIf the `reset_heartbeats` flag is set, the heartbeat details will also be cleared.\n\nSpecify the Activity Type of ID and Workflow IDs:\n\n```\ntemporal activity reset \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --keep-paused\n --reset-heartbeats\n```\n\nEither `activity-id`, `activity-type`, or `--match-all` must be specified.\n\nActivities can be reset in bulk with a visibility query list filter.\nFor example, if you want to reset activities of type Foo:\n\n```\ntemporal activity reset \\\n --query 'TemporalResetInfo=\"property:activityType=Foo\"'\n```" + s.Command.Long = "Reset an activity. This restarts the activity as if it were first being\nscheduled. That is, it will reset both the number of attempts and the\nactivity timeout, as well as, optionally, the\nheartbeat details.\n\nIf the activity may be executing (i.e. it has not yet timed out), the\nreset will take effect the next time it fails, heartbeats, or times out.\nIf is waiting for a retry (i.e. has failed or timed out), the reset\nwill apply immediately.\n\nIf the activity is already paused, it will be unpaused by default.\nYou can specify `keep_paused` to prevent this.\n\nIf the activity is paused and the `keep_paused` flag is not provided,\nit will be unpaused. If the activity is paused and `keep_paused` flag\nis provided - it will stay paused.\n\nEither `--activity-id` (with `--workflow-id`) or `--query` must be specified.\n\n### Resetting activities that heartbeat {#reset-heartbeats}\n\nActivities that heartbeat will receive a Canceled failure\nthe next time they heartbeat after a reset.\n\nIf, in your Activity, you need to do any cleanup when an Activity is\nreset, handle this error and then re-throw it when you've cleaned up.\n\nIf the `reset_heartbeats` flag is set, the heartbeat details will also be cleared.\n\nSpecify the Activity and Workflow IDs:\n\n```\ntemporal activity reset \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --keep-paused\n --reset-heartbeats\n```\n\nActivities can be reset in bulk with a visibility query list filter:\n\n```\ntemporal activity reset \\\n --query 'WorkflowType=\"YourWorkflow\"'\n```" } s.Command.Args = cobra.NoArgs - s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to reset. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified.") - s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of the given `activity-type` will be reset. Mutually exclusive with --match-all and `activity-id`. Note: Resetting Activity by Type is an experimental feature and may change in the future.") + s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to reset. Mutually exclusive with `--query`. Requires `--workflow-id` to be specified.") s.Command.Flags().BoolVar(&s.KeepPaused, "keep-paused", false, "If the activity was paused, it will stay paused.") s.Command.Flags().BoolVar(&s.ResetAttempts, "reset-attempts", false, "Reset the activity attempts.") s.Command.Flags().BoolVar(&s.ResetHeartbeats, "reset-heartbeats", false, "Reset the Activity's heartbeats.") - s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every activity should be reset. Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`. Note: This is an experimental feature and may change in the future.") s.Jitter = 0 s.Command.Flags().Var(&s.Jitter, "jitter", "The activity will reset at random a time within the specified duration. Can only be used with --query.") s.Command.Flags().BoolVar(&s.RestoreOriginalOptions, "restore-original-options", false, "Restore the original options of the activity.") @@ -578,10 +572,8 @@ type TemporalActivityUnpauseCommand struct { Command cobra.Command SingleActivityOrBatchOptions ActivityId string - ActivityType string ResetAttempts bool ResetHeartbeats bool - MatchAll bool Jitter cliext.FlagDuration } @@ -592,16 +584,14 @@ func NewTemporalActivityUnpauseCommand(cctx *CommandContext, parent *TemporalAct s.Command.Use = "unpause [flags]" s.Command.Short = "Unpause an Activity" if hasHighlighting { - s.Command.Long = "Re-schedule a previously-paused Activity for execution.\n\nIf the Activity is not running and is past its retry timeout, it will be\nscheduled immediately. Otherwise, it will be scheduled after its retry\ntimeout expires.\n\nUse \x1b[1m--reset-attempts\x1b[0m to reset the number of previous run attempts to\nzero. For example, if an Activity is near the maximum number of attempts\nN specified in its retry policy, \x1b[1m--reset-attempts\x1b[0m will allow the\nActivity to be retried another N times after unpausing.\n\nUse \x1b[1m--reset-heartbeat\x1b[0m to reset the Activity's heartbeats.\n\nActivities can be specified by their Activity ID or Activity Type.\nOne of those parameters must be provided.\n\nSpecify the Activity ID or Type and Workflow IDs:\n\n\x1b[1mtemporal activity unpause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --reset-attempts\n --reset-heartbeats\x1b[0m\n\nActivities can be unpaused in bulk via a visibility Query list filter.\nFor example, if you want to unpause activities of type Foo that you\npreviously paused, do:\n\n\x1b[1mtemporal activity unpause \\\n --query 'TemporalPauseInfo=\"property:activityType=Foo\"'\x1b[0m" + s.Command.Long = "Re-schedule a previously-paused Activity for execution.\n\nIf the Activity is not running and is past its retry timeout, it will be\nscheduled immediately. Otherwise, it will be scheduled after its retry\ntimeout expires.\n\nUse \x1b[1m--reset-attempts\x1b[0m to reset the number of previous run attempts to\nzero. For example, if an Activity is near the maximum number of attempts\nN specified in its retry policy, \x1b[1m--reset-attempts\x1b[0m will allow the\nActivity to be retried another N times after unpausing.\n\nUse \x1b[1m--reset-heartbeat\x1b[0m to reset the Activity's heartbeats.\n\nEither \x1b[1m--activity-id\x1b[0m (with \x1b[1m--workflow-id\x1b[0m) or \x1b[1m--query\x1b[0m must be specified.\n\nSpecify the Activity and Workflow IDs:\n\n\x1b[1mtemporal activity unpause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --reset-attempts\n --reset-heartbeats\x1b[0m\n\nActivities can be unpaused in bulk via a visibility Query list filter:\n\n\x1b[1mtemporal activity unpause \\\n --query 'TemporalPauseInfo IS NOT NULL'\x1b[0m" } else { - s.Command.Long = "Re-schedule a previously-paused Activity for execution.\n\nIf the Activity is not running and is past its retry timeout, it will be\nscheduled immediately. Otherwise, it will be scheduled after its retry\ntimeout expires.\n\nUse `--reset-attempts` to reset the number of previous run attempts to\nzero. For example, if an Activity is near the maximum number of attempts\nN specified in its retry policy, `--reset-attempts` will allow the\nActivity to be retried another N times after unpausing.\n\nUse `--reset-heartbeat` to reset the Activity's heartbeats.\n\nActivities can be specified by their Activity ID or Activity Type.\nOne of those parameters must be provided.\n\nSpecify the Activity ID or Type and Workflow IDs:\n\n```\ntemporal activity unpause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --reset-attempts\n --reset-heartbeats\n```\n\nActivities can be unpaused in bulk via a visibility Query list filter.\nFor example, if you want to unpause activities of type Foo that you\npreviously paused, do:\n\n```\ntemporal activity unpause \\\n --query 'TemporalPauseInfo=\"property:activityType=Foo\"'\n```" + s.Command.Long = "Re-schedule a previously-paused Activity for execution.\n\nIf the Activity is not running and is past its retry timeout, it will be\nscheduled immediately. Otherwise, it will be scheduled after its retry\ntimeout expires.\n\nUse `--reset-attempts` to reset the number of previous run attempts to\nzero. For example, if an Activity is near the maximum number of attempts\nN specified in its retry policy, `--reset-attempts` will allow the\nActivity to be retried another N times after unpausing.\n\nUse `--reset-heartbeat` to reset the Activity's heartbeats.\n\nEither `--activity-id` (with `--workflow-id`) or `--query` must be specified.\n\nSpecify the Activity and Workflow IDs:\n\n```\ntemporal activity unpause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --reset-attempts\n --reset-heartbeats\n```\n\nActivities can be unpaused in bulk via a visibility Query list filter:\n\n```\ntemporal activity unpause \\\n --query 'TemporalPauseInfo IS NOT NULL'\n```" } s.Command.Args = cobra.NoArgs - s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to unpause. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified.") - s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of the given `activity-type` will be unpaused. Mutually exclusive with `activity-id` and --match-all. Note: Unpausing Activity by Type is an experimental feature and may change in the future.") + s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to unpause. Mutually exclusive with `--query`. Requires `--workflow-id` to be specified.") s.Command.Flags().BoolVar(&s.ResetAttempts, "reset-attempts", false, "Reset the activity attempts.") s.Command.Flags().BoolVar(&s.ResetHeartbeats, "reset-heartbeats", false, "Reset the Activity's heartbeats.") - s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every paused activity should be unpaused. This flag is ignored if activity-type is provided. Note: This is an experimental feature and may change in the future.") s.Jitter = 0 s.Command.Flags().Var(&s.Jitter, "jitter", "The activity will start at random a time within the specified duration. Can only be used with --query.") s.SingleActivityOrBatchOptions.BuildFlags(s.Command.Flags()) @@ -618,8 +608,6 @@ type TemporalActivityUpdateOptionsCommand struct { Command cobra.Command SingleActivityOrBatchOptions ActivityId string - ActivityType string - MatchAll bool TaskQueue string ScheduleToCloseTimeout cliext.FlagDuration ScheduleToStartTimeout cliext.FlagDuration @@ -639,14 +627,12 @@ func NewTemporalActivityUpdateOptionsCommand(cctx *CommandContext, parent *Tempo s.Command.Use = "update-options [flags]" s.Command.Short = "Update Activity options" if hasHighlighting { - s.Command.Long = "Update the options of a running Activity that were passed into it from\na Workflow. Updates are incremental, only changing the specified options.\n\nFor example:\n\n\x1b[1mtemporal activity update-options \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --task-queue NewTaskQueueName \\\n --schedule-to-close-timeout DURATION \\\n --schedule-to-start-timeout DURATION \\\n --start-to-close-timeout DURATION \\\n --heartbeat-timeout DURATION \\\n --retry-initial-interval DURATION \\\n --retry-maximum-interval DURATION \\\n --retry-backoff-coefficient NewBackoffCoefficient \\\n --retry-maximum-attempts NewMaximumAttempts\x1b[0m\n\nYou may follow this command with \x1b[1mtemporal activity reset\x1b[0m, and the new values will apply after the reset.\n\nEither \x1b[1mactivity-id\x1b[0m, \x1b[1mactivity-type\x1b[0m, or \x1b[1m--match-all\x1b[0m must be specified.\n\nActivity options can be updated in bulk with a visibility query list filter.\nFor example, if you want to reset for activities of type Foo, do:\n\n\x1b[1mtemporal activity update-options \\\n --query 'TemporalPauseInfo=\"property:activityType=Foo\"'\n ...\x1b[0m" + s.Command.Long = "Update the options of a running Activity that were passed into it from\na Workflow. Updates are incremental, only changing the specified options.\n\nFor example:\n\n\x1b[1mtemporal activity update-options \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --task-queue NewTaskQueueName \\\n --schedule-to-close-timeout DURATION \\\n --schedule-to-start-timeout DURATION \\\n --start-to-close-timeout DURATION \\\n --heartbeat-timeout DURATION \\\n --retry-initial-interval DURATION \\\n --retry-maximum-interval DURATION \\\n --retry-backoff-coefficient NewBackoffCoefficient \\\n --retry-maximum-attempts NewMaximumAttempts\x1b[0m\n\nYou may follow this command with \x1b[1mtemporal activity reset\x1b[0m, and the new values will apply after the reset.\n\nEither \x1b[1m--activity-id\x1b[0m or \x1b[1m--query\x1b[0m must be specified.\n\nActivity options can be updated in bulk with a visibility query list filter:\n\n\x1b[1mtemporal activity update-options \\\n --query 'WorkflowType=\"YourWorkflow\"' \\\n --task-queue NewTaskQueueName\x1b[0m" } else { - s.Command.Long = "Update the options of a running Activity that were passed into it from\na Workflow. Updates are incremental, only changing the specified options.\n\nFor example:\n\n```\ntemporal activity update-options \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --task-queue NewTaskQueueName \\\n --schedule-to-close-timeout DURATION \\\n --schedule-to-start-timeout DURATION \\\n --start-to-close-timeout DURATION \\\n --heartbeat-timeout DURATION \\\n --retry-initial-interval DURATION \\\n --retry-maximum-interval DURATION \\\n --retry-backoff-coefficient NewBackoffCoefficient \\\n --retry-maximum-attempts NewMaximumAttempts\n```\n\nYou may follow this command with `temporal activity reset`, and the new values will apply after the reset.\n\nEither `activity-id`, `activity-type`, or `--match-all` must be specified.\n\nActivity options can be updated in bulk with a visibility query list filter.\nFor example, if you want to reset for activities of type Foo, do:\n\n```\ntemporal activity update-options \\\n --query 'TemporalPauseInfo=\"property:activityType=Foo\"'\n ...\n```" + s.Command.Long = "Update the options of a running Activity that were passed into it from\na Workflow. Updates are incremental, only changing the specified options.\n\nFor example:\n\n```\ntemporal activity update-options \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --task-queue NewTaskQueueName \\\n --schedule-to-close-timeout DURATION \\\n --schedule-to-start-timeout DURATION \\\n --start-to-close-timeout DURATION \\\n --heartbeat-timeout DURATION \\\n --retry-initial-interval DURATION \\\n --retry-maximum-interval DURATION \\\n --retry-backoff-coefficient NewBackoffCoefficient \\\n --retry-maximum-attempts NewMaximumAttempts\n```\n\nYou may follow this command with `temporal activity reset`, and the new values will apply after the reset.\n\nEither `--activity-id` or `--query` must be specified.\n\nActivity options can be updated in bulk with a visibility query list filter:\n\n```\ntemporal activity update-options \\\n --query 'WorkflowType=\"YourWorkflow\"' \\\n --task-queue NewTaskQueueName\n```" } s.Command.Args = cobra.NoArgs - s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to update options. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified.") - s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of this Type will be updated. Mutually exclusive with `--match-all` and `activity-id`. Note: Updating Activity options by Type is an experimental feature and may change in the future.") - s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`. Note: This is an experimental feature and may change in the future.") + s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to update options. Mutually exclusive with `--query`. Requires `--workflow-id` to be specified.") s.Command.Flags().StringVar(&s.TaskQueue, "task-queue", "", "Name of the task queue for the Activity.") s.ScheduleToCloseTimeout = 0 s.Command.Flags().Var(&s.ScheduleToCloseTimeout, "schedule-to-close-timeout", "Indicates how long the caller is willing to wait for an activity completion. Limits how long retries will be attempted.") diff --git a/internal/temporalcli/commands.yaml b/internal/temporalcli/commands.yaml index 166fa6280..5f4294f8f 100644 --- a/internal/temporalcli/commands.yaml +++ b/internal/temporalcli/commands.yaml @@ -260,32 +260,21 @@ commands: You may follow this command with `temporal activity reset`, and the new values will apply after the reset. - Either `activity-id`, `activity-type`, or `--match-all` must be specified. + Either `--activity-id` or `--query` must be specified. - Activity options can be updated in bulk with a visibility query list filter. - For example, if you want to reset for activities of type Foo, do: + Activity options can be updated in bulk with a visibility query list filter: ``` temporal activity update-options \ - --query 'TemporalPauseInfo="property:activityType=Foo"' - ... + --query 'WorkflowType="YourWorkflow"' \ + --task-queue NewTaskQueueName ``` options: - name: activity-id short: a type: string description: | - The Activity ID to update options. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified. - - name: activity-type - type: string - description: | - Activities of this Type will be updated. Mutually exclusive with `--match-all` and `activity-id`. - Note: Updating Activity options by Type is an experimental feature and may change in the future. - - name: match-all - type: bool - description: | - Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`. - Note: This is an experimental feature and may change in the future. + The Activity ID to update options. Mutually exclusive with `--query`. Requires `--workflow-id` to be specified. - name: task-queue type: string description: Name of the task queue for the Activity. @@ -358,9 +347,7 @@ commands: If the Activity is on its last retry attempt and fails, the failure will be returned to the caller, just as if the Activity had not been paused. - Activities should be specified either by their Activity ID or Activity Type. - - For example, specify the Activity and Workflow IDs like this: + Specify the Activity and Workflow IDs: ``` temporal activity pause \ @@ -374,13 +361,7 @@ commands: - name: activity-id short: a type: string - description: The Activity ID to pause. Either `activity-id` or `activity-type` must be provided, but not both. - - name: activity-type - type: string - description: | - Activities of the given `activity-type` will be paused. Mutually - exclusive with `activity-id`. - Note: Pausing Activity by Type is an experimental feature and may change in the future. + description: The Activity ID to pause. Required. - name: identity type: string description: The identity of the user or client submitting this request. @@ -406,10 +387,9 @@ commands: Use `--reset-heartbeat` to reset the Activity's heartbeats. - Activities can be specified by their Activity ID or Activity Type. - One of those parameters must be provided. + Either `--activity-id` (with `--workflow-id`) or `--query` must be specified. - Specify the Activity ID or Type and Workflow IDs: + Specify the Activity and Workflow IDs: ``` temporal activity unpause \ @@ -419,37 +399,24 @@ commands: --reset-heartbeats ``` - Activities can be unpaused in bulk via a visibility Query list filter. - For example, if you want to unpause activities of type Foo that you - previously paused, do: + Activities can be unpaused in bulk via a visibility Query list filter: ``` temporal activity unpause \ - --query 'TemporalPauseInfo="property:activityType=Foo"' + --query 'TemporalPauseInfo IS NOT NULL' ``` options: - name: activity-id short: a type: string description: | - The Activity ID to unpause. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified. - - name: activity-type - type: string - description: | - Activities of the given `activity-type` will be unpaused. Mutually - exclusive with `activity-id` and --match-all. - Note: Unpausing Activity by Type is an experimental feature and may change in the future. + The Activity ID to unpause. Mutually exclusive with `--query`. Requires `--workflow-id` to be specified. - name: reset-attempts type: bool description: Reset the activity attempts. - name: reset-heartbeats type: bool description: Reset the Activity's heartbeats. - - name: match-all - type: bool - description: | - Every paused activity should be unpaused. This flag is ignored if activity-type is provided. - Note: This is an experimental feature and may change in the future. - name: jitter type: duration description: | @@ -478,7 +445,7 @@ commands: it will be unpaused. If the activity is paused and `keep_paused` flag is provided - it will stay paused. - Activities can be specified by their Activity ID or Activity Type. + Either `--activity-id` (with `--workflow-id`) or `--query` must be specified. ### Resetting activities that heartbeat {#reset-heartbeats} @@ -490,7 +457,7 @@ commands: If the `reset_heartbeats` flag is set, the heartbeat details will also be cleared. - Specify the Activity Type of ID and Workflow IDs: + Specify the Activity and Workflow IDs: ``` temporal activity reset \ @@ -500,26 +467,17 @@ commands: --reset-heartbeats ``` - Either `activity-id`, `activity-type`, or `--match-all` must be specified. - - Activities can be reset in bulk with a visibility query list filter. - For example, if you want to reset activities of type Foo: + Activities can be reset in bulk with a visibility query list filter: ``` temporal activity reset \ - --query 'TemporalResetInfo="property:activityType=Foo"' + --query 'WorkflowType="YourWorkflow"' ``` options: - name: activity-id short: a type: string - description: The Activity ID to reset. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified. - - name: activity-type - type: string - description: | - Activities of the given `activity-type` will be reset. Mutually - exclusive with --match-all and `activity-id`. - Note: Resetting Activity by Type is an experimental feature and may change in the future. + description: The Activity ID to reset. Mutually exclusive with `--query`. Requires `--workflow-id` to be specified. - name: keep-paused type: bool description: If the activity was paused, it will stay paused. @@ -529,11 +487,6 @@ commands: - name: reset-heartbeats type: bool description: Reset the Activity's heartbeats. - - name: match-all - type: bool - description: | - Every activity should be reset. Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`. - Note: This is an experimental feature and may change in the future. - name: jitter type: duration description: |