From 1a79b50a74e9f1efda2a0e34ad1d7faff397d622 Mon Sep 17 00:00:00 2001 From: Lyon Hill Date: Wed, 17 Apr 2019 15:31:48 -0600 Subject: [PATCH 1/7] Integrat the new changes to tasks --- cmd/influxd/launcher/launcher.go | 40 +-- cmd/influxd/launcher/tasks_test.go | 10 +- kv/task.go | 349 ++++++++++++++++++------ task.go | 4 + task/backend/analytical_storage.go | 4 +- task/backend/coordinator/coordinator.go | 9 +- task/servicetest/servicetest.go | 2 +- 7 files changed, 288 insertions(+), 130 deletions(-) diff --git a/cmd/influxd/launcher/launcher.go b/cmd/influxd/launcher/launcher.go index c65e8cd31a8..ca70f24d4f6 100644 --- a/cmd/influxd/launcher/launcher.go +++ b/cmd/influxd/launcher/launcher.go @@ -37,7 +37,6 @@ import ( "github.com/influxdata/influxdb/storage/readservice" "github.com/influxdata/influxdb/task" taskbackend "github.com/influxdata/influxdb/task/backend" - taskbolt "github.com/influxdata/influxdb/task/backend/bolt" "github.com/influxdata/influxdb/task/backend/coordinator" taskexecutor "github.com/influxdata/influxdb/task/backend/executor" "github.com/influxdata/influxdb/telemetry" @@ -211,8 +210,8 @@ type Launcher struct { natsServer *nats.Server - scheduler *taskbackend.TickScheduler - taskStore taskbackend.Store + scheduler *taskbackend.TickScheduler + taskControlService taskbackend.TaskControlService jaegerTracerCloser io.Closer logger *zap.Logger @@ -504,35 +503,22 @@ func (m *Launcher) run(ctx context.Context) (err error) { var storageQueryService = readservice.NewProxyQueryService(m.queryController) var taskSvc platform.TaskService { - var ( - store taskbackend.Store - err error - ) - store, err = taskbolt.New(m.boltClient.DB(), "tasks", taskbolt.NoCatchUp) - if err != nil { - m.logger.Error("failed opening task bolt", zap.Error(err)) - return err - } - if m.storeType == "memory" { - store = taskbackend.NewInMemStore() - } + // create the task stack: + // validation(coordinator(analyticalstore(kv.Service))) - executor := taskexecutor.NewAsyncQueryServiceExecutor(m.logger.With(zap.String("service", "task-executor")), m.queryController, authSvc, nil) + // define the executor and build analytical storage middleware + combinedTaskService := taskbackend.NewAnalyticalStorage(m.kvService, m.kvService, pointsWriter, query.QueryServiceBridge{AsyncQueryService: m.queryController}) + executor := taskexecutor.NewAsyncQueryServiceExecutor(m.logger.With(zap.String("service", "task-executor")), m.queryController, authSvc, combinedTaskService) - lw := taskbackend.NewPointLogWriter(pointsWriter) - queryService := query.QueryServiceBridge{AsyncQueryService: m.queryController} - lr := taskbackend.NewQueryLogReader(queryService) - taskControlService := taskbackend.TaskControlAdaptor(store, lw, lr) - m.scheduler = taskbackend.NewScheduler(taskControlService, executor, time.Now().UTC().Unix(), taskbackend.WithTicker(ctx, 100*time.Millisecond), taskbackend.WithLogger(m.logger)) + // create the scheduler + m.scheduler = taskbackend.NewScheduler(combinedTaskService, executor, time.Now().UTC().Unix(), taskbackend.WithTicker(ctx, 100*time.Millisecond), taskbackend.WithLogger(m.logger)) m.scheduler.Start(ctx) m.reg.MustRegister(m.scheduler.PrometheusCollectors()...) - taskSvc = task.PlatformAdapter(store, lr, m.scheduler, authSvc, userResourceSvc, orgSvc) - taskexecutor.AddTaskService(executor, taskSvc) - taskSvc = coordinator.New(m.logger.With(zap.String("service", "task-coordinator")), m.scheduler, taskSvc) + taskSvc = coordinator.New(m.logger.With(zap.String("service", "task-coordinator")), m.scheduler, combinedTaskService) taskSvc = task.NewValidator(m.logger.With(zap.String("service", "task-authz-validator")), taskSvc, bucketSvc) - m.taskStore = store + m.taskControlService = combinedTaskService } // NATS streaming server @@ -691,8 +677,8 @@ func (m *Launcher) TaskService() platform.TaskService { } // TaskStore returns the internal store service. -func (m *Launcher) TaskStore() taskbackend.Store { - return m.taskStore +func (m *Launcher) TaskControlService() taskbackend.TaskControlService { + return m.taskControlService } // TaskScheduler returns the internal scheduler service. diff --git a/cmd/influxd/launcher/tasks_test.go b/cmd/influxd/launcher/tasks_test.go index f1e03be48e9..b6e576f8273 100644 --- a/cmd/influxd/launcher/tasks_test.go +++ b/cmd/influxd/launcher/tasks_test.go @@ -90,27 +90,24 @@ stuff f=-123.456,b=true,s="hello" create := influxdb.TaskCreate{ OrganizationID: org.ID, + Token: be.Auth.Token, Flux: fmt.Sprintf(`option task = { name: "my_task", every: 1s, } from(bucket:"my_bucket_in") |> range(start:-5m) |> to(bucket:"%s", org:"%s")`, bOut.Name, be.Org.Name), } + created, err := be.TaskService().CreateTask(ctx, create) if err != nil { t.Fatal(err) } // Find the next due run of the task we just created, so that we can accurately tick the scheduler to it. - m, err := be.TaskStore().FindTaskMetaByID(ctx, created.ID) + ndr, err := be.TaskControlService().NextDueRun(ctx, created.ID) if err != nil { t.Fatal(err) } - ndr, err := m.NextDueRun() - if err != nil { - t.Fatal(err) - } - be.TaskScheduler().(*backend.TickScheduler).Tick(ndr + 1) // Poll for the task to have started and finished. @@ -210,7 +207,6 @@ from(bucket:"my_bucket_in") |> range(start:-5m) |> to(bucket:"%s", org:"%s")`, b } t.Run("showrun", func(t *testing.T) { - t.Skip("FindRunByID isn't returning the log") // do a show run! showRun, err := be.TaskService().FindRunByID(ctx, created.ID, targetRun.ID) if err != nil { diff --git a/kv/task.go b/kv/task.go index b4cca02b0b9..80bf2216cdd 100644 --- a/kv/task.go +++ b/kv/task.go @@ -3,7 +3,6 @@ package kv import ( "context" "encoding/json" - "errors" "fmt" "strings" "time" @@ -172,10 +171,24 @@ func (s *Service) findTaskByID(ctx context.Context, tx Tx, id influxdb.ID) (*inf return nil, err } if !latestCompleted.IsZero() { - t.LatestCompleted = latestCompleted.Format(time.RFC3339) - } else { + if t.LatestCompleted != "" { + tlc, err := time.Parse(time.RFC3339, t.LatestCompleted) + if err == nil && latestCompleted.After(tlc) { + t.LatestCompleted = latestCompleted.Format(time.RFC3339) + + } + } else { + t.LatestCompleted = latestCompleted.Format(time.RFC3339) + } + } + + if t.LatestCompleted == "" { t.LatestCompleted = t.CreatedAt } + latestCompleted, err = time.Parse(time.RFC3339, t.LatestCompleted) + if err != nil { + return nil, err + } return t, nil } @@ -200,9 +213,7 @@ func (s *Service) FindTasks(ctx context.Context, filter influxdb.TaskFilter) ([] } func (s *Service) findTasks(ctx context.Context, tx Tx, filter influxdb.TaskFilter) ([]*influxdb.Task, int, error) { - if filter.User == nil && filter.OrganizationID == nil && filter.Organization == "" { - return nil, 0, errors.New("find tasks requires filtering by org or user") - } + var org *influxdb.Organization var err error if filter.OrganizationID != nil { @@ -227,87 +238,119 @@ func (s *Service) findTasks(ctx context.Context, tx Tx, filter influxdb.TaskFilt filter.Limit = influxdb.TaskDefaultPageSize } - var ts []*influxdb.Task // filter by user id. if filter.User != nil { - maps, err := s.findUserResourceMappings( - ctx, - tx, - influxdb.UserResourceMappingFilter{ - ResourceType: influxdb.TasksResourceType, - UserID: *filter.User, - UserType: influxdb.Owner, - }, - ) + return s.findTasksByUser(ctx, tx, filter) + } else if org != nil { + return s.findTaskByOrg(ctx, tx, filter) + } + + return s.findAllTasks(ctx, tx, filter) +} + +// findTasksByUser is a subset of the find tasks function. Used for cleanliness +func (s *Service) findTasksByUser(ctx context.Context, tx Tx, filter influxdb.TaskFilter) ([]*influxdb.Task, int, error) { + if filter.User == nil { + return nil, 0, ErrTaskNotFound + } + + var org *influxdb.Organization + var err error + if filter.OrganizationID != nil { + org, err = s.findOrganizationByID(ctx, tx, *filter.OrganizationID) + if err != nil { + return nil, 0, err + } + } else if filter.Organization != "" { + org, err = s.findOrganizationByName(ctx, tx, filter.Organization) if err != nil { return nil, 0, err } + } - for _, m := range maps { - task, err := s.findTaskByID(ctx, tx, m.ResourceID) - if err != nil { - return nil, 0, err - } + var ts []*influxdb.Task - if org != nil && task.OrganizationID != org.ID { - continue - } + maps, err := s.findUserResourceMappings( + ctx, + tx, + influxdb.UserResourceMappingFilter{ + ResourceType: influxdb.TasksResourceType, + UserID: *filter.User, + UserType: influxdb.Owner, + }, + ) + if err != nil { + return nil, 0, err + } - ts = append(ts, task) + for _, m := range maps { + task, err := s.findTaskByID(ctx, tx, m.ResourceID) + if err != nil { + return nil, 0, err + } - if len(ts) >= filter.Limit { - break - } + if org != nil && task.OrganizationID != org.ID { + continue } - } else { - indexBucket, err := tx.Bucket(taskIndexBucket) - if err != nil { - return nil, 0, ErrUnexpectedTaskBucketErr(err) + + ts = append(ts, task) + + if len(ts) >= filter.Limit { + break } + } + return ts, len(ts), nil +} - c, err := indexBucket.Cursor() +// findTaskByOrg is a subset of the find tasks function. Used for cleanliness +func (s *Service) findTaskByOrg(ctx context.Context, tx Tx, filter influxdb.TaskFilter) ([]*influxdb.Task, int, error) { + var org *influxdb.Organization + var err error + if filter.OrganizationID != nil { + org, err = s.findOrganizationByID(ctx, tx, *filter.OrganizationID) if err != nil { - return nil, 0, ErrUnexpectedTaskBucketErr(err) + return nil, 0, err } - // we can filter by orgID - if filter.After != nil { - key, err := taskOrgKey(org.ID, *filter.After) - if err != nil { - return nil, 0, err - } - // ignore the key:val returned in this seek because we are starting "after" - // this key - c.Seek(key) - } else { - // if we dont have an after we just move the cursor to the first instance of the - // orgID - key, err := org.ID.Encode() - if err != nil { - return nil, 0, ErrInvalidTaskID - } - k, v := c.Seek(key) - if k != nil { - id, err := influxdb.IDFromString(string(v)) - if err != nil { - return nil, 0, ErrInvalidTaskID - } - - t, err := s.findTaskByID(ctx, tx, *id) - if err != nil { - return nil, 0, err - } - - // insert the new task into the list - ts = append(ts, t) - } + } else if filter.Organization != "" { + org, err = s.findOrganizationByName(ctx, tx, filter.Organization) + if err != nil { + return nil, 0, err } + } - for { - k, v := c.Next() - if k == nil { - break - } + if org == nil { + return nil, 0, ErrTaskNotFound + } + + var ts []*influxdb.Task + + indexBucket, err := tx.Bucket(taskIndexBucket) + if err != nil { + return nil, 0, ErrUnexpectedTaskBucketErr(err) + } + c, err := indexBucket.Cursor() + if err != nil { + return nil, 0, ErrUnexpectedTaskBucketErr(err) + } + // we can filter by orgID + if filter.After != nil { + key, err := taskOrgKey(org.ID, *filter.After) + if err != nil { + return nil, 0, err + } + // ignore the key:val returned in this seek because we are starting "after" + // this key + c.Seek(key) + } else { + // if we dont have an after we just move the cursor to the first instance of the + // orgID + key, err := org.ID.Encode() + if err != nil { + return nil, 0, ErrInvalidTaskID + } + k, v := c.Seek(key) + if k != nil { id, err := influxdb.IDFromString(string(v)) if err != nil { return nil, 0, ErrInvalidTaskID @@ -318,22 +361,118 @@ func (s *Service) findTasks(ctx context.Context, tx Tx, filter influxdb.TaskFilt return nil, 0, err } - // If the new task doesn't belong to the org we have looped outside the org filter - if org != nil && t.OrganizationID != org.ID { - break - } - // insert the new task into the list ts = append(ts, t) + } + } - // Check if we are over running the limit - if len(ts) >= filter.Limit { - break - } + for { + k, v := c.Next() + if k == nil { + break + } + + id, err := influxdb.IDFromString(string(v)) + if err != nil { + return nil, 0, ErrInvalidTaskID + } + + t, err := s.findTaskByID(ctx, tx, *id) + if err != nil { + return nil, 0, err + } + + // If the new task doesn't belong to the org we have looped outside the org filter + if org != nil && t.OrganizationID != org.ID { + break + } + + // insert the new task into the list + ts = append(ts, t) + + // Check if we are over running the limit + if len(ts) >= filter.Limit { + break } } + return ts, len(ts), err +} - return ts, len(ts), nil +// findAllTasks is a subset of the find tasks function. Used for cleanliness. +// This function should only be executed internally because it doesn't force organization or user filtering. +// Enforcing filters should be done in a validation layer. +func (s *Service) findAllTasks(ctx context.Context, tx Tx, filter influxdb.TaskFilter) ([]*influxdb.Task, int, error) { + var ts []*influxdb.Task + + taskBucket, err := tx.Bucket(taskBucket) + if err != nil { + return nil, 0, ErrUnexpectedTaskBucketErr(err) + } + + c, err := taskBucket.Cursor() + if err != nil { + return nil, 0, ErrUnexpectedTaskBucketErr(err) + } + // we can filter by orgID + if filter.After != nil { + + key, err := taskKey(*filter.After) + if err != nil { + return nil, 0, err + } + // ignore the key:val returned in this seek because we are starting "after" + // this key + c.Seek(key) + } else { + k, v := c.First() + if k == nil { + return ts, len(ts), nil + } + + t := &influxdb.Task{} + if err := json.Unmarshal(v, t); err != nil { + return nil, 0, ErrInternalTaskServiceError(err) + } + latestCompleted, err := s.findLatestCompletedTime(ctx, tx, t.ID) + if err != nil { + return nil, 0, err + } + if !latestCompleted.IsZero() { + t.LatestCompleted = latestCompleted.Format(time.RFC3339) + } else { + t.LatestCompleted = t.CreatedAt + } + // insert the new task into the list + ts = append(ts, t) + } + + for { + k, v := c.Next() + if k == nil { + break + } + t := &influxdb.Task{} + if err := json.Unmarshal(v, t); err != nil { + return nil, 0, ErrInternalTaskServiceError(err) + } + latestCompleted, err := s.findLatestCompletedTime(ctx, tx, t.ID) + if err != nil { + return nil, 0, err + } + if !latestCompleted.IsZero() { + t.LatestCompleted = latestCompleted.Format(time.RFC3339) + } else { + t.LatestCompleted = t.CreatedAt + } + // insert the new task into the list + ts = append(ts, t) + + // Check if we are over running the limit + if len(ts) >= filter.Limit { + break + } + } + return ts, len(ts), err } // CreateTask creates a new task. @@ -401,9 +540,11 @@ func (s *Service) createTask(ctx context.Context, tx Tx, tc influxdb.TaskCreate) Flux: tc.Flux, Every: opt.Every.String(), Cron: opt.Cron, - Offset: opt.Offset.String(), CreatedAt: time.Now().UTC().Format(time.RFC3339), } + if opt.Offset != nil { + task.Offset = opt.Offset.String() + } taskBucket, err := tx.Bucket(taskBucket) if err != nil { @@ -510,6 +651,10 @@ func (s *Service) updateTask(ctx context.Context, tx Tx, id influxdb.ID, upd inf task.Status = *upd.Status } + if upd.LatestCompleted != nil { + task.LatestCompleted = *upd.LatestCompleted + } + task.UpdatedAt = time.Now().UTC().Format(time.RFC3339) // save the updated task bucket, err := tx.Bucket(taskBucket) @@ -640,8 +785,8 @@ func (s *Service) findLogs(ctx context.Context, tx Tx, filter influxdb.LogFilter return nil, 0, err } rtn := make([]*influxdb.Log, len(r.Log)) - for i, log := range r.Log { - rtn[i] = &log + for i := 0; i < len(r.Log); i++ { + rtn[i] = &r.Log[i] } return rtn, len(rtn), nil } @@ -1034,6 +1179,14 @@ func (s *Service) createNextRun(ctx context.Context, tx Tx, taskID influxdb.ID, return backend.RunCreation{}, ErrTaskTimeParse(err) } + // we could have a latest completed newer then the created at time. + if task.LatestCompleted != "" { + lc, err := time.Parse(time.RFC3339, task.LatestCompleted) + if err == nil && lc.After(latestCompleted) { + latestCompleted = lc + } + } + lRun, err := s.findLatestCompleted(ctx, tx, taskID) if err != nil { return backend.RunCreation{}, err @@ -1048,6 +1201,27 @@ func (s *Service) createNextRun(ctx context.Context, tx Tx, taskID influxdb.ID, latestCompleted = runTime } } + // Align create to the hour/minute + // If we decide we no longer want to do this we can just remove the code block below + { + if strings.HasPrefix(task.EffectiveCron(), "@every ") { + everyString := strings.TrimPrefix(task.EffectiveCron(), "@every ") + every := options.Duration{} + err := every.Parse(everyString) + if err != nil { + // We cannot align a invalid time + goto NoChange + } + t := time.Unix(latestCompleted.Unix(), 0) + everyDur, err := every.DurationFrom(t) + if err != nil { + goto NoChange + } + t = t.Truncate(everyDur) + latestCompleted = t.Truncate(time.Second) + } + NoChange: + } // create a run if possible sch, err := cron.Parse(task.EffectiveCron()) @@ -1306,18 +1480,11 @@ func (s *Service) nextDueRun(ctx context.Context, tx Tx, taskID influxdb.ID) (in return 0, err } - latestCompleted, err := s.findLatestCompletedTime(ctx, tx, taskID) + latestCompleted, err := time.Parse(time.RFC3339, task.LatestCompleted) if err != nil { return 0, err } - if latestCompleted.IsZero() { - latestCompleted, err = time.Parse(time.RFC3339, task.CreatedAt) - if err != nil { - return 0, ErrTaskTimeParse(err) - } - } - // create a run if possible sch, err := cron.Parse(task.EffectiveCron()) if err != nil { diff --git a/task.go b/task.go index 05ff7d57783..32e5f36ffd0 100644 --- a/task.go +++ b/task.go @@ -155,6 +155,10 @@ func (t TaskCreate) Validate() error { type TaskUpdate struct { Flux *string `json:"flux,omitempty"` Status *string `json:"status,omitempty"` + + // LatestCompleted us to set latest completed on startup to skip task catchup + LatestCompleted *string `json:"-"` + // Options gets unmarshalled from json as if it was flat, with the same level as Flux and Status. Options options.Options // when we unmarshal this gets unmarshalled from flat key-values diff --git a/task/backend/analytical_storage.go b/task/backend/analytical_storage.go index aa951362bd4..a94d57b8387 100644 --- a/task/backend/analytical_storage.go +++ b/task/backend/analytical_storage.go @@ -94,7 +94,7 @@ func (as *AnalyticalStorage) FindLogs(ctx context.Context, filter influxdb.LogFi return nil, 0, err } for i := 0; i < len(run.Log); i++ { - logs = append(logs, &run.Log[0]) + logs = append(logs, &run.Log[i]) } return logs, len(logs), nil } @@ -107,7 +107,7 @@ func (as *AnalyticalStorage) FindLogs(ctx context.Context, filter influxdb.LogFi for _, run := range runs { for i := 0; i < len(run.Log); i++ { - logs = append(logs, &run.Log[0]) + logs = append(logs, &run.Log[i]) } } diff --git a/task/backend/coordinator/coordinator.go b/task/backend/coordinator/coordinator.go index 18c55fb7c4a..e799aea308c 100644 --- a/task/backend/coordinator/coordinator.go +++ b/task/backend/coordinator/coordinator.go @@ -3,6 +3,7 @@ package coordinator import ( "context" "fmt" + "time" platform "github.com/influxdata/influxdb" "github.com/influxdata/influxdb/task/backend" @@ -58,10 +59,9 @@ func New(logger *zap.Logger, scheduler backend.Scheduler, ts platform.TaskServic func (c *Coordinator) claimExistingTasks() { tasks, _, err := c.TaskService.FindTasks(context.Background(), platform.TaskFilter{}) if err != nil { - c.logger.Error("failed to list tasks", zap.Error(err)) return } - + newLatestCompleted := time.Now().UTC().Format(time.RFC3339) for len(tasks) > 0 { for _, task := range tasks { if task.Status != string(backend.TaskActive) { @@ -69,6 +69,11 @@ func (c *Coordinator) claimExistingTasks() { continue } + task, err := c.TaskService.UpdateTask(context.Background(), task.ID, platform.TaskUpdate{LatestCompleted: &newLatestCompleted}) + if err != nil { + c.logger.Error("failed to set latestCompleted", zap.Error(err)) + } + // I may need a context with an auth here if err := c.sch.ClaimTask(context.Background(), task); err != nil { c.logger.Error("failed claim task", zap.Error(err)) diff --git a/task/servicetest/servicetest.go b/task/servicetest/servicetest.go index 3b11fce4a2e..2c5d2e25ebb 100644 --- a/task/servicetest/servicetest.go +++ b/task/servicetest/servicetest.go @@ -1253,7 +1253,7 @@ func testLogsAcrossStorage(t *testing.T, sys *System) { } // Create several run logs in both rc0 and rc1 - // + // We can then finalize rc1 and ensure that both the transactional (currently running logs) can be found with analytical (completed) logs. sys.TaskControlService.AddRunLog(sys.Ctx, task.ID, rc0.Created.RunID, time.Now(), "0-0") sys.TaskControlService.AddRunLog(sys.Ctx, task.ID, rc0.Created.RunID, time.Now(), "0-1") sys.TaskControlService.AddRunLog(sys.Ctx, task.ID, rc0.Created.RunID, time.Now(), "0-2") From d9266d348c63aa5eaf436dfe9eab10a6324c9880 Mon Sep 17 00:00:00 2001 From: Lyon Hill Date: Wed, 17 Apr 2019 16:57:40 -0600 Subject: [PATCH 2/7] add some grease --- kv/task.go | 10 ++++- ui/package-lock.json | 96 ++++++++++++++++++++++---------------------- 2 files changed, 57 insertions(+), 49 deletions(-) diff --git a/kv/task.go b/kv/task.go index 80bf2216cdd..4e9e4b6c93c 100644 --- a/kv/task.go +++ b/kv/task.go @@ -502,7 +502,15 @@ func (s *Service) createTask(ctx context.Context, tx Tx, tc influxdb.TaskCreate) auth, err := s.findAuthorizationByToken(ctx, tx, tc.Token) if err != nil { - return nil, err + if err.Error() != " authorization not found" { + return nil, err + } + // if i cant find an authoriaztion based on the token we will use the users authID + auth, err = s.findAuthorizationByID(ctx, tx, userAuth.Identifier()) + if err != nil { + // if we still fail to fine a real auth we cannot continue + return nil, err + } } var org *influxdb.Organization diff --git a/ui/package-lock.json b/ui/package-lock.json index ebc38ae169c..c8ab3fcfcea 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -6233,20 +6233,20 @@ "dependencies": { "abbrev": { "version": "1.1.1", - "resolved": false, + "resolved": "", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true, "optional": true }, "ansi-regex": { "version": "2.1.1", - "resolved": false, + "resolved": "", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, "aproba": { "version": "1.2.0", - "resolved": false, + "resolved": "", "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true, "optional": true @@ -6264,13 +6264,13 @@ }, "balanced-match": { "version": "1.0.0", - "resolved": false, + "resolved": "", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, "brace-expansion": { "version": "1.1.11", - "resolved": false, + "resolved": "", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { @@ -6287,32 +6287,32 @@ }, "code-point-at": { "version": "1.1.0", - "resolved": false, + "resolved": "", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, "concat-map": { "version": "0.0.1", - "resolved": false, + "resolved": "", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, "console-control-strings": { "version": "1.1.0", - "resolved": false, + "resolved": "", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "dev": true }, "core-util-is": { "version": "1.0.2", - "resolved": false, + "resolved": "", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true, "optional": true }, "debug": { "version": "2.6.9", - "resolved": false, + "resolved": "", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "optional": true, @@ -6329,21 +6329,21 @@ }, "delegates": { "version": "1.0.0", - "resolved": false, + "resolved": "", "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "dev": true, "optional": true }, "detect-libc": { "version": "1.0.3", - "resolved": false, + "resolved": "", "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", "dev": true, "optional": true }, "fs-minipass": { "version": "1.2.5", - "resolved": false, + "resolved": "", "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "dev": true, "optional": true, @@ -6353,14 +6353,14 @@ }, "fs.realpath": { "version": "1.0.0", - "resolved": false, + "resolved": "", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true, "optional": true }, "gauge": { "version": "2.7.4", - "resolved": false, + "resolved": "", "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "dev": true, "optional": true, @@ -6392,7 +6392,7 @@ }, "has-unicode": { "version": "2.0.1", - "resolved": false, + "resolved": "", "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", "dev": true, "optional": true @@ -6409,7 +6409,7 @@ }, "ignore-walk": { "version": "3.0.1", - "resolved": false, + "resolved": "", "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", "dev": true, "optional": true, @@ -6419,7 +6419,7 @@ }, "inflight": { "version": "1.0.6", - "resolved": false, + "resolved": "", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "optional": true, @@ -6430,20 +6430,20 @@ }, "inherits": { "version": "2.0.3", - "resolved": false, + "resolved": "", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, "ini": { "version": "1.3.5", - "resolved": false, + "resolved": "", "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true, "optional": true }, "is-fullwidth-code-point": { "version": "1.0.0", - "resolved": false, + "resolved": "", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "requires": { @@ -6452,14 +6452,14 @@ }, "isarray": { "version": "1.0.0", - "resolved": false, + "resolved": "", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true, "optional": true }, "minimatch": { "version": "3.0.4", - "resolved": false, + "resolved": "", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { @@ -6468,7 +6468,7 @@ }, "minimist": { "version": "0.0.8", - "resolved": false, + "resolved": "", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, @@ -6494,7 +6494,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": false, + "resolved": "", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -6503,7 +6503,7 @@ }, "ms": { "version": "2.0.0", - "resolved": false, + "resolved": "", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true, "optional": true @@ -6541,7 +6541,7 @@ }, "nopt": { "version": "4.0.1", - "resolved": false, + "resolved": "", "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "dev": true, "optional": true, @@ -6570,7 +6570,7 @@ }, "npmlog": { "version": "4.1.2", - "resolved": false, + "resolved": "", "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "dev": true, "optional": true, @@ -6583,20 +6583,20 @@ }, "number-is-nan": { "version": "1.0.1", - "resolved": false, + "resolved": "", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true }, "object-assign": { "version": "4.1.1", - "resolved": false, + "resolved": "", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true, "optional": true }, "once": { "version": "1.4.0", - "resolved": false, + "resolved": "", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { @@ -6605,21 +6605,21 @@ }, "os-homedir": { "version": "1.0.2", - "resolved": false, + "resolved": "", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true, "optional": true }, "os-tmpdir": { "version": "1.0.2", - "resolved": false, + "resolved": "", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true, "optional": true }, "osenv": { "version": "0.1.5", - "resolved": false, + "resolved": "", "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "dev": true, "optional": true, @@ -6630,14 +6630,14 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": false, + "resolved": "", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true, "optional": true }, "process-nextick-args": { "version": "2.0.0", - "resolved": false, + "resolved": "", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true, "optional": true @@ -6657,7 +6657,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": false, + "resolved": "", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true, "optional": true @@ -6666,7 +6666,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": false, + "resolved": "", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "optional": true, @@ -6698,14 +6698,14 @@ }, "safer-buffer": { "version": "2.1.2", - "resolved": false, + "resolved": "", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true, "optional": true }, "sax": { "version": "1.2.4", - "resolved": false, + "resolved": "", "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "dev": true, "optional": true @@ -6719,21 +6719,21 @@ }, "set-blocking": { "version": "2.0.0", - "resolved": false, + "resolved": "", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true, "optional": true }, "signal-exit": { "version": "3.0.2", - "resolved": false, + "resolved": "", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true, "optional": true }, "string-width": { "version": "1.0.2", - "resolved": false, + "resolved": "", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { @@ -6744,7 +6744,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": false, + "resolved": "", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "optional": true, @@ -6754,7 +6754,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": false, + "resolved": "", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -6763,7 +6763,7 @@ }, "strip-json-comments": { "version": "2.0.1", - "resolved": false, + "resolved": "", "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true, "optional": true @@ -6786,7 +6786,7 @@ }, "util-deprecate": { "version": "1.0.2", - "resolved": false, + "resolved": "", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true, "optional": true @@ -6803,7 +6803,7 @@ }, "wrappy": { "version": "1.0.2", - "resolved": false, + "resolved": "", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, From dfb1485106300bb72fea3b6a2dc6b9db7bb3ae52 Mon Sep 17 00:00:00 2001 From: Lyon Hill Date: Thu, 18 Apr 2019 12:18:20 -0600 Subject: [PATCH 3/7] add change log and update tests to confirm task creat function --- CHANGELOG.md | 2 ++ cmd/influxd/launcher/tasks_test.go | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9f855d9d01..2f6c50b2d34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Features 1. [13423](https://github.com/influxdata/influxdb/pull/13423): Set autorefresh of dashboard to pause if absolute time range is selected +1. [13473](https://github.com/influxdata/influxdb/pull/13473): Switch task back end to a more modular and flexible system + ### Bug Fixes diff --git a/cmd/influxd/launcher/tasks_test.go b/cmd/influxd/launcher/tasks_test.go index b6e576f8273..23d33d5a88d 100644 --- a/cmd/influxd/launcher/tasks_test.go +++ b/cmd/influxd/launcher/tasks_test.go @@ -90,7 +90,6 @@ stuff f=-123.456,b=true,s="hello" create := influxdb.TaskCreate{ OrganizationID: org.ID, - Token: be.Auth.Token, Flux: fmt.Sprintf(`option task = { name: "my_task", every: 1s, From 2fea86110dba035ab89fc325cb775bca38b90880 Mon Sep 17 00:00:00 2001 From: Lyon Hill Date: Thu, 18 Apr 2019 15:47:41 -0600 Subject: [PATCH 4/7] add a note to the change log about the tasks being wiped --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55816fb53cd..53ae17a29b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## v2.0.0-alpha.9 [unreleased] + +**NOTE: This will remove all tasks from your InfluxDB v2.0 instance.** + ### Features 1. [13423](https://github.com/influxdata/influxdb/pull/13423): Set autorefresh of dashboard to pause if absolute time range is selected 1. [13473](https://github.com/influxdata/influxdb/pull/13473): Switch task back end to a more modular and flexible system From 0adde081f4d87b31ac5f6936314f4138a3af8a6d Mon Sep 17 00:00:00 2001 From: Lyon Hill Date: Thu, 18 Apr 2019 16:12:02 -0600 Subject: [PATCH 5/7] pull lock from master --- ui/package-lock.json | 96 ++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/ui/package-lock.json b/ui/package-lock.json index b1c27c294c5..2250cb45f45 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -6233,20 +6233,20 @@ "dependencies": { "abbrev": { "version": "1.1.1", - "resolved": "", + "resolved": false, "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true, "optional": true }, "ansi-regex": { "version": "2.1.1", - "resolved": "", + "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, "aproba": { "version": "1.2.0", - "resolved": "", + "resolved": false, "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true, "optional": true @@ -6264,13 +6264,13 @@ }, "balanced-match": { "version": "1.0.0", - "resolved": "", + "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, "brace-expansion": { "version": "1.1.11", - "resolved": "", + "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { @@ -6287,32 +6287,32 @@ }, "code-point-at": { "version": "1.1.0", - "resolved": "", + "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, "concat-map": { "version": "0.0.1", - "resolved": "", + "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, "console-control-strings": { "version": "1.1.0", - "resolved": "", + "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "dev": true }, "core-util-is": { "version": "1.0.2", - "resolved": "", + "resolved": false, "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true, "optional": true }, "debug": { "version": "2.6.9", - "resolved": "", + "resolved": false, "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "optional": true, @@ -6329,21 +6329,21 @@ }, "delegates": { "version": "1.0.0", - "resolved": "", + "resolved": false, "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "dev": true, "optional": true }, "detect-libc": { "version": "1.0.3", - "resolved": "", + "resolved": false, "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", "dev": true, "optional": true }, "fs-minipass": { "version": "1.2.5", - "resolved": "", + "resolved": false, "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "dev": true, "optional": true, @@ -6353,14 +6353,14 @@ }, "fs.realpath": { "version": "1.0.0", - "resolved": "", + "resolved": false, "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true, "optional": true }, "gauge": { "version": "2.7.4", - "resolved": "", + "resolved": false, "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "dev": true, "optional": true, @@ -6392,7 +6392,7 @@ }, "has-unicode": { "version": "2.0.1", - "resolved": "", + "resolved": false, "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", "dev": true, "optional": true @@ -6409,7 +6409,7 @@ }, "ignore-walk": { "version": "3.0.1", - "resolved": "", + "resolved": false, "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", "dev": true, "optional": true, @@ -6419,7 +6419,7 @@ }, "inflight": { "version": "1.0.6", - "resolved": "", + "resolved": false, "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "optional": true, @@ -6430,20 +6430,20 @@ }, "inherits": { "version": "2.0.3", - "resolved": "", + "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, "ini": { "version": "1.3.5", - "resolved": "", + "resolved": false, "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true, "optional": true }, "is-fullwidth-code-point": { "version": "1.0.0", - "resolved": "", + "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "requires": { @@ -6452,14 +6452,14 @@ }, "isarray": { "version": "1.0.0", - "resolved": "", + "resolved": false, "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true, "optional": true }, "minimatch": { "version": "3.0.4", - "resolved": "", + "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { @@ -6468,7 +6468,7 @@ }, "minimist": { "version": "0.0.8", - "resolved": "", + "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, @@ -6494,7 +6494,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "", + "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -6503,7 +6503,7 @@ }, "ms": { "version": "2.0.0", - "resolved": "", + "resolved": false, "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true, "optional": true @@ -6541,7 +6541,7 @@ }, "nopt": { "version": "4.0.1", - "resolved": "", + "resolved": false, "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "dev": true, "optional": true, @@ -6570,7 +6570,7 @@ }, "npmlog": { "version": "4.1.2", - "resolved": "", + "resolved": false, "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "dev": true, "optional": true, @@ -6583,20 +6583,20 @@ }, "number-is-nan": { "version": "1.0.1", - "resolved": "", + "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true }, "object-assign": { "version": "4.1.1", - "resolved": "", + "resolved": false, "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true, "optional": true }, "once": { "version": "1.4.0", - "resolved": "", + "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { @@ -6605,21 +6605,21 @@ }, "os-homedir": { "version": "1.0.2", - "resolved": "", + "resolved": false, "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true, "optional": true }, "os-tmpdir": { "version": "1.0.2", - "resolved": "", + "resolved": false, "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true, "optional": true }, "osenv": { "version": "0.1.5", - "resolved": "", + "resolved": false, "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "dev": true, "optional": true, @@ -6630,14 +6630,14 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "", + "resolved": false, "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true, "optional": true }, "process-nextick-args": { "version": "2.0.0", - "resolved": "", + "resolved": false, "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true, "optional": true @@ -6657,7 +6657,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "", + "resolved": false, "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true, "optional": true @@ -6666,7 +6666,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "", + "resolved": false, "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "optional": true, @@ -6698,14 +6698,14 @@ }, "safer-buffer": { "version": "2.1.2", - "resolved": "", + "resolved": false, "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true, "optional": true }, "sax": { "version": "1.2.4", - "resolved": "", + "resolved": false, "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "dev": true, "optional": true @@ -6719,21 +6719,21 @@ }, "set-blocking": { "version": "2.0.0", - "resolved": "", + "resolved": false, "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true, "optional": true }, "signal-exit": { "version": "3.0.2", - "resolved": "", + "resolved": false, "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true, "optional": true }, "string-width": { "version": "1.0.2", - "resolved": "", + "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { @@ -6744,7 +6744,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "", + "resolved": false, "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "optional": true, @@ -6754,7 +6754,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "", + "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -6763,7 +6763,7 @@ }, "strip-json-comments": { "version": "2.0.1", - "resolved": "", + "resolved": false, "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true, "optional": true @@ -6786,7 +6786,7 @@ }, "util-deprecate": { "version": "1.0.2", - "resolved": "", + "resolved": false, "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true, "optional": true @@ -6803,7 +6803,7 @@ }, "wrappy": { "version": "1.0.2", - "resolved": "", + "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, From 5191978bccc82d85ad41f4b1653c03681e0a7e04 Mon Sep 17 00:00:00 2001 From: Lyon Hill Date: Thu, 18 Apr 2019 16:19:08 -0600 Subject: [PATCH 6/7] update log test to actually look at the content of the logs --- task/servicetest/servicetest.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/task/servicetest/servicetest.go b/task/servicetest/servicetest.go index c9edbd9d827..7c08b590df6 100644 --- a/task/servicetest/servicetest.go +++ b/task/servicetest/servicetest.go @@ -1275,6 +1275,16 @@ func testLogsAcrossStorage(t *testing.T, sys *System) { } t.Fatalf("failed to get all logs: expected: 7 got: %d", len(logs)) } + smash := func(logs []*influxdb.Log) string { + smashed := "" + for _, log := range logs { + smashed = smashed + log.Message + } + return smashed + } + if smash(logs) != "0-00-10-21-01-11-21-3" { + t.Fatalf("log contents not acceptable, expected: %q, got: %q", "0-00-10-21-01-11-21-3", smash(logs)) + } logs, _, err = sys.TaskService.FindLogs(sys.Ctx, influxdb.LogFilter{Task: task.ID, Run: &rc1.Created.RunID}) if err != nil { @@ -1284,6 +1294,10 @@ func testLogsAcrossStorage(t *testing.T, sys *System) { t.Fatalf("failed to get all logs: expected: 4 got: %d", len(logs)) } + if smash(logs) != "1-01-11-21-3" { + t.Fatalf("log contents not acceptable, expected: %q, got: %q", "1-01-11-21-3", smash(logs)) + } + logs, _, err = sys.TaskService.FindLogs(sys.Ctx, influxdb.LogFilter{Task: task.ID, Run: &rc0.Created.RunID}) if err != nil { t.Fatal(err) @@ -1292,6 +1306,10 @@ func testLogsAcrossStorage(t *testing.T, sys *System) { t.Fatalf("failed to get all logs: expected: 3 got: %d", len(logs)) } + if smash(logs) != "0-00-10-2" { + t.Fatalf("log contents not acceptable, expected: %q, got: %q", "0-00-10-2", smash(logs)) + } + } func creds(t *testing.T, s *System) TestCreds { From 67071a8a52c7dbff0e20f45456ef49445df48bf1 Mon Sep 17 00:00:00 2001 From: Lyon Hill Date: Thu, 18 Apr 2019 16:53:21 -0600 Subject: [PATCH 7/7] add testing to confirm active and inactive tasks get updates when claimed --- task/backend/coordinator/coordinator.go | 9 +++--- task/backend/coordinator/coordinator_test.go | 33 +++++++++++++++++++- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/task/backend/coordinator/coordinator.go b/task/backend/coordinator/coordinator.go index e799aea308c..cde35e348fd 100644 --- a/task/backend/coordinator/coordinator.go +++ b/task/backend/coordinator/coordinator.go @@ -64,16 +64,17 @@ func (c *Coordinator) claimExistingTasks() { newLatestCompleted := time.Now().UTC().Format(time.RFC3339) for len(tasks) > 0 { for _, task := range tasks { - if task.Status != string(backend.TaskActive) { - // Don't claim inactive tasks at startup. - continue - } task, err := c.TaskService.UpdateTask(context.Background(), task.ID, platform.TaskUpdate{LatestCompleted: &newLatestCompleted}) if err != nil { c.logger.Error("failed to set latestCompleted", zap.Error(err)) } + if task.Status != string(backend.TaskActive) { + // Don't claim inactive tasks at startup. + continue + } + // I may need a context with an auth here if err := c.sch.ClaimTask(context.Background(), task); err != nil { c.logger.Error("failed claim task", zap.Error(err)) diff --git a/task/backend/coordinator/coordinator_test.go b/task/backend/coordinator/coordinator_test.go index 26de5e0e010..9d47d8ecb92 100644 --- a/task/backend/coordinator/coordinator_test.go +++ b/task/backend/coordinator/coordinator_test.go @@ -67,6 +67,10 @@ func inmemTaskService() platform.TaskService { if upd.Status != nil { t.Status = *upd.Status } + if upd.LatestCompleted != nil { + t.LatestCompleted = *upd.LatestCompleted + } + return t, nil }, FindTaskByIDFn: func(ctx context.Context, id platform.ID) (*platform.Task, error) { @@ -76,7 +80,8 @@ func inmemTaskService() platform.TaskService { if !ok { return nil, backend.ErrTaskNotFound } - return t, nil + newt := *t + return &newt, nil }, FindTasksFn: func(ctx context.Context, tf platform.TaskFilter) ([]*platform.Task, int, error) { mu.Lock() @@ -254,6 +259,14 @@ func TestCoordinator_ClaimExistingTasks(t *testing.T) { } createdIDs[i] = task.ID } + origActive, err := ts.FindTaskByID(context.Background(), createdIDs[0]) + if err != nil { + t.Fatal(err) + } + origInactive, err := ts.FindTaskByID(context.Background(), createdIDs[inactiveTaskIndex]) + if err != nil { + t.Fatal(err) + } coordinator.New(zaptest.NewLogger(t), sched, ts) @@ -275,6 +288,24 @@ func TestCoordinator_ClaimExistingTasks(t *testing.T) { t.Fatalf("did not find created task with ID %s", id) } } + + active, err := ts.FindTaskByID(context.Background(), createdIDs[0]) + if err != nil { + t.Fatal(err) + } + inactive, err := ts.FindTaskByID(context.Background(), createdIDs[inactiveTaskIndex]) + if err != nil { + t.Fatal(err) + } + + if origActive.LatestCompleted == active.LatestCompleted { + t.Fatalf("active tasks not update with latest completed time") + } + + if origInactive.LatestCompleted == inactive.LatestCompleted { + t.Fatalf("inactive tasks not update with latest completed time") + } + } func TestCoordinator_ForceRun(t *testing.T) {