Skip to content

Commit

Permalink
Merge pull request #1744 from zimnx/mz/manager-stop-before-delete
Browse files Browse the repository at this point in the history
Stop Scylla Manager task before deletion
  • Loading branch information
scylla-operator-bot[bot] authored Feb 23, 2024
2 parents 52c24fc + 554475a commit c8901da
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 c8901da

Please sign in to comment.