diff --git a/CHANGELOG.md b/CHANGELOG.md index ee66431a17a..fe1fad6cb21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,7 +63,7 @@ * [ENHANCEMENT] Reduce tail latency by smoothing out spikes in rate of chunk flush operations. #3191 * [ENHANCEMENT] User Cortex as User Agent in http requests issued by Configs DB client. #3264 * [ENHANCEMENT] Experimental Ruler API: Fetch rule groups from object storage in parallel. #3218 -* [ENHANCEMENT] Chunks GCS object storage client uses the `fields` selector to limit the payload size when listing objects in the bucket. #3218 +* [ENHANCEMENT] Chunks GCS object storage client uses the `fields` selector to limit the payload size when listing objects in the bucket. #3218 #3292 * [ENHANCEMENT] Added shuffle sharding support to ruler. Added new metric `cortex_ruler_sync_rules_total`. #3235 * [BUGFIX] No-longer-needed ingester operations for queries triggered by queriers and rulers are now canceled. #3178 * [BUGFIX] Ruler: directories in the configured `rules-path` will be removed on startup and shutdown in order to ensure they don't persist between runs. #3195 diff --git a/pkg/chunk/gcp/gcs_object_client.go b/pkg/chunk/gcp/gcs_object_client.go index 11421077019..7cb50c93a4f 100644 --- a/pkg/chunk/gcp/gcs_object_client.go +++ b/pkg/chunk/gcp/gcs_object_client.go @@ -110,9 +110,16 @@ func (s *GCSObjectClient) List(ctx context.Context, prefix, delimiter string) ([ var storageObjects []chunk.StorageObject var commonPrefixes []chunk.StorageCommonPrefix q := &storage.Query{Prefix: prefix, Delimiter: delimiter} - err := q.SetAttrSelection([]string{"Name", "Updated"}) - if err != nil { - return nil, nil, err + + // Using delimiter and selected attributes doesn't work well together -- it returns nothing. + // Reason is that Go's API only sets "fields=items(name,updated)" parameter in the request, + // but what we really need is "fields=prefixes,items(name,updated)". Unfortunately we cannot set that, + // so instead we don't use attributes selection when using delimiter. + if delimiter == "" { + err := q.SetAttrSelection([]string{"Name", "Updated"}) + if err != nil { + return nil, nil, err + } } iter := s.bucket.Objects(ctx, q) @@ -130,7 +137,7 @@ func (s *GCSObjectClient) List(ctx context.Context, prefix, delimiter string) ([ } // When doing query with Delimiter, Prefix is the only field set for entries which represent synthetic "directory entries". - if attr.Name == "" { + if attr.Prefix != "" { commonPrefixes = append(commonPrefixes, chunk.StorageCommonPrefix(attr.Prefix)) continue }