Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make task-id a required argument for remove-task command #6586

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tools/tdbg/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@
}
var visibilityTimestamp int64
if category.Type() == tasks.CategoryTypeScheduled {
if !c.IsSet(FlagTaskVisibilityTimestamp) {
return fmt.Errorf("%s is required to remove %s tasks", FlagTaskVisibilityTimestamp, category.Name())

Check failure on line 465 in tools/tdbg/commands.go

View workflow job for this annotation

GitHub Actions / lint

do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"%s is required to remove %s tasks\", FlagTaskVisibilityTimestamp, category.Name())" (err113)
}
visibilityTimestamp = c.Int64(FlagTaskVisibilityTimestamp)
}

Expand Down
24 changes: 11 additions & 13 deletions tools/tdbg/tdbg_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,6 @@ func newAdminShardManagementCommands(clientFactory ClientFactory, taskCategoryRe
// which is required and does not have a default. The second is the task category
// for the remove-task command, which is optional and defaults to transfer.
taskCategoryFlag := getTaskCategoryFlag(taskCategoryRegistry)
listTasksCategory := *taskCategoryFlag
listTasksCategory.Required = true
removeTaskCategory := *taskCategoryFlag
removeTaskCategory.Value = tasks.CategoryTransfer.Name()

return []*cli.Command{
{
Name: "describe",
Expand Down Expand Up @@ -305,7 +300,7 @@ func newAdminShardManagementCommands(clientFactory ClientFactory, taskCategoryRe
Usage: "The ID of the shard",
Required: true,
},
&listTasksCategory,
taskCategoryFlag,
&cli.Int64Flag{
Name: FlagMinTaskID,
Usage: "Inclusive min taskID. Optional for transfer, replication, visibility tasks. Can't be specified for timer task",
Expand Down Expand Up @@ -357,14 +352,16 @@ func newAdminShardManagementCommands(clientFactory ClientFactory, taskCategoryRe
Usage: "remove a task based on shardId, task category, taskId, and task visibility timestamp",
Flags: []cli.Flag{
&cli.IntFlag{
Name: FlagShardID,
Usage: "shardId",
Name: FlagShardID,
Usage: "shardId",
Required: true,
},
&cli.Int64Flag{
Name: FlagTaskID,
Usage: "taskId",
Name: FlagTaskID,
Usage: "taskId",
Required: true,
},
&removeTaskCategory,
taskCategoryFlag,
&cli.Int64Flag{
Name: FlagTaskVisibilityTimestamp,
Usage: "task visibility timestamp in nano (required for removing timer task)",
Expand All @@ -384,8 +381,9 @@ func getTaskCategoryFlag(taskCategoryRegistry tasks.TaskCategoryRegistry) *cli.S
options = append(options, category.Name())
}
flag := &cli.StringFlag{
Name: FlagTaskCategory,
Usage: "Task category: " + strings.Join(options, ", "),
Name: FlagTaskCategory,
Usage: "Task category: " + strings.Join(options, ", "),
Required: true,
}
return flag
}
Expand Down
Loading