Skip to content

Commit

Permalink
Stop Scylla Manager task before deletion
Browse files Browse the repository at this point in the history
Tasks that are running and are deleted contine their run.
This may prevent other tasks from being run if they are created and
started before deleted task finishes.
  • Loading branch information
zimnx committed Feb 23, 2024
1 parent e8dd337 commit 554475a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/controller/manager/sync_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ type deleteTaskAction struct {
}

func (a *deleteTaskAction) Execute(ctx context.Context, client *managerclient.Client, status *scyllav1.ScyllaClusterStatus) error {
err := client.DeleteTask(ctx, a.clusterID, a.taskType, uuid.MustParse(a.taskID))
err := a.stopAndDeleteTask(ctx, client)

if a.taskType == "repair" {
filteredStatuses := status.Repairs[:0]
Expand Down Expand Up @@ -388,6 +388,21 @@ func (a *deleteTaskAction) Execute(ctx context.Context, client *managerclient.Cl
return err
}

func (a *deleteTaskAction) stopAndDeleteTask(ctx context.Context, client *managerclient.Client) error {
// StopTask is idempotent
err := client.StopTask(ctx, a.clusterID, a.taskType, uuid.MustParse(a.taskID), false)
if err != nil {
return fmt.Errorf("can't stop task %q: %w", a.taskID, err)
}

err = client.DeleteTask(ctx, a.clusterID, a.taskType, uuid.MustParse(a.taskID))
if err != nil {
return fmt.Errorf("can't delete task %q: %w", a.taskID, err)
}

return nil
}

func (a deleteTaskAction) String() string {
return fmt.Sprintf("delete task %q", a.taskID)
}
Expand Down

0 comments on commit 554475a

Please sign in to comment.