fix(task): inactive task runs when updated (#22211)
parent
2237d02828
commit
991ff02ea7
|
@ -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]
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue