fix(task): clean up offset when removed in script (#14961)

When the flux script removes a offset it should be removed from the task
pull/15008/head
Lyon Hill 2019-09-06 08:26:50 -06:00 committed by GitHub
parent 5e6e84aee5
commit 5d6bb3fced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -713,7 +713,9 @@ func (s *Service) updateTask(ctx context.Context, tx Tx, id influxdb.ID, upd inf
task.Name = options.Name
task.Every = options.Every.String()
task.Cron = options.Cron
if options.Offset != nil {
if options.Offset == nil {
task.Offset = ""
} else {
task.Offset = options.Offset.String()
}
}

View File

@ -488,6 +488,22 @@ from(bucket: "b")
diff := cmp.Diff(savedTask.Flux, expectedFlux)
t.Fatalf("flux unexpected updated: %s", diff)
}
withoutOffset := `option task = {
name: "task-Options-Update",
every: 10s,
concurrency: 100,
}
from(bucket: "b")
|> to(bucket: "two", orgID: "000000000000000")`
fNoOffset, err := sys.TaskService.UpdateTask(authorizedCtx, task.ID, influxdb.TaskUpdate{Flux: &withoutOffset})
if err != nil {
t.Fatal(err)
}
if fNoOffset.Offset != "" {
t.Fatal("removing offset failed")
}
})
}