diff --git a/CHANGELOG.md b/CHANGELOG.md index 22b3e6559c..56924ba780 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/task/backend/coordinator/coordinator.go b/task/backend/coordinator/coordinator.go index 61c7fd1fa1..3fc48196d5 100644 --- a/task/backend/coordinator/coordinator.go +++ b/task/backend/coordinator/coordinator.go @@ -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 { diff --git a/task/backend/coordinator/coordinator_test.go b/task/backend/coordinator/coordinator_test.go index b3d9095a9c..cf466bb924 100644 --- a/task/backend/coordinator/coordinator_test.go +++ b/task/backend/coordinator/coordinator_test.go @@ -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) {