Skip to content

Commit

Permalink
fix(task): inactive task runs when updated (influxdata#22211)
Browse files Browse the repository at this point in the history
  • Loading branch information
raffs authored Aug 17, 2021
1 parent 2237d02 commit 991ff02
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ This release adds an embedded SQLite database for storing metadata required by t
1. [22186](https://github.com/influxdata/influxdb/pull/22186): Preserve comments in flux queries when saving task definitions
1. [#22174](https://github.com/influxdata/influxdb/pull/22174): systemd service -- handle 40x and block indefinitely
1. [#22228](https://github.com/influxdata/influxdb/pull/22228): influxdb2 packages should depend on curl
1. [#22211](https://github.com/influxdata/influxdb/pull/22211): Prevent scheduling an inactivated tasks after updating it

## v2.0.7 [2021-06-04]

Expand Down
5 changes: 5 additions & 0 deletions task/backend/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func (c *Coordinator) TaskUpdated(ctx context.Context, from, to *taskmodel.Task)
return err
}

// if the tasks is already inactive, we don't do anything
if to.Status == from.Status && to.Status == string(taskmodel.TaskInactive) {
return nil
}

// if disabling the task, release it before schedule update
if to.Status != from.Status && to.Status == string(taskmodel.TaskInactive) {
if err := c.sch.Release(sid); err != nil && err != taskmodel.ErrTaskNotClaimed {
Expand Down
9 changes: 9 additions & 0 deletions task/backend/coordinator/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ func Test_Coordinator_Scheduler_Methods(t *testing.T) {
},
},
},
{
name: "TaskUpdated - inactive task is not scheduled",
call: func(t *testing.T, c *Coordinator) {
if err := c.TaskUpdated(context.Background(), taskTwoInactive, taskTwoInactive); err != nil {
t.Errorf("expected nil error found %q", err)
}
},
scheduler: &schedulerC{},
},
{
name: "TaskDeleted",
call: func(t *testing.T, c *Coordinator) {
Expand Down

0 comments on commit 991ff02

Please sign in to comment.