diff --git a/bucket.go b/bucket.go index d4c1e709bf0..b5fc2dbc23d 100644 --- a/bucket.go +++ b/bucket.go @@ -153,8 +153,3 @@ func (f BucketFilter) String() string { } return "[" + strings.Join(parts, ", ") + "]" } - -// FindSystemBucket finds the system bucket with a given name -func FindSystemBucket(ctx context.Context, bs BucketService, orgID ID, name string) (*Bucket, error) { - return bs.FindBucketByName(ctx, orgID, name) -} diff --git a/kv/bucket.go b/kv/bucket.go index edf823b47c2..6efe571f3b8 100644 --- a/kv/bucket.go +++ b/kv/bucket.go @@ -345,6 +345,14 @@ func (s *Service) FindBuckets(ctx context.Context, filter influxdb.BucketFilter, return nil }) + // Don't append system buckets if Name is set. Users who don't have real + // system buckets won't get mocked buckets if they query for a bucket by name + // without the orgID, but this is a vanishing small number of users and has + // limited utility anyways. Can be removed once mock system code is ripped out. + if filter.Name != nil { + return bs, len(bs), nil + } + needsSystemBuckets := true for _, b := range bs { if b.Type == influxdb.BucketTypeSystem { diff --git a/task/backend/analytical_storage.go b/task/backend/analytical_storage.go index 31d18721b01..750914ba524 100644 --- a/task/backend/analytical_storage.go +++ b/task/backend/analytical_storage.go @@ -75,7 +75,7 @@ func (as *AnalyticalStorage) FinishRun(ctx context.Context, taskID, runID influx return run, err } - sb, err := influxdb.FindSystemBucket(ctx, as.BucketService, task.OrganizationID, influxdb.TasksSystemBucketName) + sb, err := as.BucketService.FindBucketByName(ctx, task.OrganizationID, influxdb.TasksSystemBucketName) if err != nil { return run, err } @@ -142,7 +142,7 @@ func (as *AnalyticalStorage) FindRuns(ctx context.Context, filter influxdb.RunFi return runs, n, err } - sb, err := influxdb.FindSystemBucket(ctx, as.BucketService, task.OrganizationID, influxdb.TasksSystemBucketName) + sb, err := as.BucketService.FindBucketByName(ctx, task.OrganizationID, influxdb.TasksSystemBucketName) if err != nil { return runs, n, err } @@ -246,7 +246,7 @@ func (as *AnalyticalStorage) FindRunByID(ctx context.Context, taskID, runID infl return run, err } - sb, err := influxdb.FindSystemBucket(ctx, as.BucketService, task.OrganizationID, influxdb.TasksSystemBucketName) + sb, err := as.BucketService.FindBucketByName(ctx, task.OrganizationID, influxdb.TasksSystemBucketName) if err != nil { return run, err }