Skip to content

Commit

Permalink
fix(kv): don't stub system buckets when searching by name (#15928)
Browse files Browse the repository at this point in the history
* Removed an unused function as cleanup.
* Users without true system buckets won't have fake buckets returned if they don't specify their org in the request, but this shouldn't break tasks.
  • Loading branch information
imogenkinsman authored Nov 19, 2019
1 parent a875a6a commit 6b19ea7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 0 additions & 5 deletions bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
8 changes: 8 additions & 0 deletions kv/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions task/backend/analytical_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 6b19ea7

Please sign in to comment.