Skip to content

Commit

Permalink
New S3 Flag to configure ListObjectsVersion (#5099)
Browse files Browse the repository at this point in the history
This patch make it possible to configure the S3 ListObjectsVersion, which is
already configurable in the [thanos-io S3
Client](https://github.com/thanos-io/objstore/blob/23ebe2eacadd89cf23bf0fbd931352112b4c846d/providers/s3/s3.go#LL137C47-L137C67).

Signed-off-by: Sven Haardiek <[email protected]>
  • Loading branch information
shaardie authored Jun 27, 2023
1 parent c39dd9e commit 6a76b73
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [FEATURE] Query-frontend: added experimental support to cache cardinality query responses. The cache will be used when `-query-frontend.cache-results` is enabled and `-query-frontend.results-cache-ttl-for-cardinality-query` set to a value greater than 0. The following metrics have been added to track the query results cache hit ratio per `request_type`: #5212 #5235
* `cortex_frontend_query_result_cache_requests_total{request_type="query_range|cardinality"}`
* `cortex_frontend_query_result_cache_hits_total{request_type="query_range|cardinality"}`
* [FEATURE] Added `-<prefix>.s3.list-objects-version` flag to configure the S3 list objects version.
* [FEATURE] Ingester: Add optional CPU/memory utilization based read request limiting, considered experimental. Disabled by default, enable by configuring limits via both of the following flags: #5012
* `-ingester.read-path-cpu-utilization-limit`
* `-ingester.read-path-memory-utilization-limit`
Expand Down
44 changes: 44 additions & 0 deletions cmd/mimir/config-descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -4980,6 +4980,17 @@
"fieldType": "string",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "list_objects_version",
"required": false,
"desc": "Use a specific version of the S3 list object API. Supported values are v1 or v2. Default is unset.",
"fieldValue": null,
"fieldDefaultValue": "",
"fieldFlag": "blocks-storage.s3.list-objects-version",
"fieldType": "string",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "storage_class",
Expand Down Expand Up @@ -10433,6 +10444,17 @@
"fieldType": "string",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "list_objects_version",
"required": false,
"desc": "Use a specific version of the S3 list object API. Supported values are v1 or v2. Default is unset.",
"fieldValue": null,
"fieldDefaultValue": "",
"fieldFlag": "ruler-storage.s3.list-objects-version",
"fieldType": "string",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "storage_class",
Expand Down Expand Up @@ -12388,6 +12410,17 @@
"fieldType": "string",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "list_objects_version",
"required": false,
"desc": "Use a specific version of the S3 list object API. Supported values are v1 or v2. Default is unset.",
"fieldValue": null,
"fieldDefaultValue": "",
"fieldFlag": "alertmanager-storage.s3.list-objects-version",
"fieldType": "string",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "storage_class",
Expand Down Expand Up @@ -14611,6 +14644,17 @@
"fieldType": "string",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "list_objects_version",
"required": false,
"desc": "Use a specific version of the S3 list object API. Supported values are v1 or v2. Default is unset.",
"fieldValue": null,
"fieldDefaultValue": "",
"fieldFlag": "common.storage.s3.list-objects-version",
"fieldType": "string",
"fieldCategory": "advanced"
},
{
"kind": "field",
"name": "storage_class",
Expand Down
8 changes: 8 additions & 0 deletions cmd/mimir/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Usage of ./cmd/mimir/mimir:
The amount of time the client will wait for a servers response headers. (default 2m0s)
-alertmanager-storage.s3.insecure
If enabled, use http:// for the S3 endpoint instead of https://. This could be useful in local dev/test environments while using an S3-compatible backend storage, like Minio.
-alertmanager-storage.s3.list-objects-version string
Use a specific version of the S3 list object API. Supported values are v1 or v2. Default is unset.
-alertmanager-storage.s3.max-connections-per-host int
Maximum number of connections per host. 0 means no limit.
-alertmanager-storage.s3.max-idle-connections int
Expand Down Expand Up @@ -653,6 +655,8 @@ Usage of ./cmd/mimir/mimir:
The amount of time the client will wait for a servers response headers. (default 2m0s)
-blocks-storage.s3.insecure
If enabled, use http:// for the S3 endpoint instead of https://. This could be useful in local dev/test environments while using an S3-compatible backend storage, like Minio.
-blocks-storage.s3.list-objects-version string
Use a specific version of the S3 list object API. Supported values are v1 or v2. Default is unset.
-blocks-storage.s3.max-connections-per-host int
Maximum number of connections per host. 0 means no limit.
-blocks-storage.s3.max-idle-connections int
Expand Down Expand Up @@ -803,6 +807,8 @@ Usage of ./cmd/mimir/mimir:
The amount of time the client will wait for a servers response headers. (default 2m0s)
-common.storage.s3.insecure
If enabled, use http:// for the S3 endpoint instead of https://. This could be useful in local dev/test environments while using an S3-compatible backend storage, like Minio.
-common.storage.s3.list-objects-version string
Use a specific version of the S3 list object API. Supported values are v1 or v2. Default is unset.
-common.storage.s3.max-connections-per-host int
Maximum number of connections per host. 0 means no limit.
-common.storage.s3.max-idle-connections int
Expand Down Expand Up @@ -2067,6 +2073,8 @@ Usage of ./cmd/mimir/mimir:
The amount of time the client will wait for a servers response headers. (default 2m0s)
-ruler-storage.s3.insecure
If enabled, use http:// for the S3 endpoint instead of https://. This could be useful in local dev/test environments while using an S3-compatible backend storage, like Minio.
-ruler-storage.s3.list-objects-version string
Use a specific version of the S3 list object API. Supported values are v1 or v2. Default is unset.
-ruler-storage.s3.max-connections-per-host int
Maximum number of connections per host. 0 means no limit.
-ruler-storage.s3.max-idle-connections int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4197,6 +4197,11 @@ The s3_backend block configures the connection to Amazon S3 object storage backe
# CLI flag: -<prefix>.s3.signature-version
[signature_version: <string> | default = "v4"]
# (advanced) Use a specific version of the S3 list object API. Supported values
# are v1 or v2. Default is unset.
# CLI flag: -<prefix>.s3.list-objects-version
[list_objects_version: <string> | default = ""]
# (experimental) The S3 storage class to use, not set by default. Details can be
# found at https://aws.amazon.com/s3/storage-classes/. Supported values are:
# STANDARD, REDUCED_REDUNDANCY, GLACIER, STANDARD_IA, ONEZONE_IA,
Expand Down
17 changes: 9 additions & 8 deletions pkg/storage/bucket/s3/bucket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ func newS3Config(cfg Config) (s3.Config, error) {
}

return s3.Config{
Bucket: cfg.BucketName,
Endpoint: cfg.Endpoint,
Region: cfg.Region,
AccessKey: cfg.AccessKeyID,
SecretKey: cfg.SecretAccessKey.String(),
Insecure: cfg.Insecure,
PutUserMetadata: putUserMetadata,
SSEConfig: sseCfg,
Bucket: cfg.BucketName,
Endpoint: cfg.Endpoint,
Region: cfg.Region,
AccessKey: cfg.AccessKeyID,
SecretKey: cfg.SecretAccessKey.String(),
Insecure: cfg.Insecure,
PutUserMetadata: putUserMetadata,
SSEConfig: sseCfg,
ListObjectsVersion: cfg.ListObjectsVersion,
HTTPConfig: s3.HTTPConfig{
IdleConnTimeout: model.Duration(cfg.HTTP.IdleConnTimeout),
ResponseHeaderTimeout: model.Duration(cfg.HTTP.ResponseHeaderTimeout),
Expand Down
18 changes: 10 additions & 8 deletions pkg/storage/bucket/s3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ func (cfg *HTTPConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {

// Config holds the config options for an S3 backend
type Config struct {
Endpoint string `yaml:"endpoint"`
Region string `yaml:"region"`
BucketName string `yaml:"bucket_name"`
SecretAccessKey flagext.Secret `yaml:"secret_access_key"`
AccessKeyID string `yaml:"access_key_id"`
Insecure bool `yaml:"insecure" category:"advanced"`
SignatureVersion string `yaml:"signature_version" category:"advanced"`
StorageClass string `yaml:"storage_class" category:"experimental"`
Endpoint string `yaml:"endpoint"`
Region string `yaml:"region"`
BucketName string `yaml:"bucket_name"`
SecretAccessKey flagext.Secret `yaml:"secret_access_key"`
AccessKeyID string `yaml:"access_key_id"`
Insecure bool `yaml:"insecure" category:"advanced"`
SignatureVersion string `yaml:"signature_version" category:"advanced"`
ListObjectsVersion string `yaml:"list_objects_version" category:"advanced"`
StorageClass string `yaml:"storage_class" category:"experimental"`

SSE SSEConfig `yaml:"sse"`
HTTP HTTPConfig `yaml:"http"`
Expand All @@ -102,6 +103,7 @@ func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
f.StringVar(&cfg.Endpoint, prefix+"s3.endpoint", "", "The S3 bucket endpoint. It could be an AWS S3 endpoint listed at https://docs.aws.amazon.com/general/latest/gr/s3.html or the address of an S3-compatible service in hostname:port format.")
f.BoolVar(&cfg.Insecure, prefix+"s3.insecure", false, "If enabled, use http:// for the S3 endpoint instead of https://. This could be useful in local dev/test environments while using an S3-compatible backend storage, like Minio.")
f.StringVar(&cfg.SignatureVersion, prefix+"s3.signature-version", SignatureVersionV4, fmt.Sprintf("The signature version to use for authenticating against S3. Supported values are: %s.", strings.Join(supportedSignatureVersions, ", ")))
f.StringVar(&cfg.ListObjectsVersion, prefix+"s3.list-objects-version", "", "Use a specific version of the S3 list object API. Supported values are v1 or v2. Default is unset.")
f.StringVar(&cfg.StorageClass, prefix+"s3.storage-class", "", "The S3 storage class to use, not set by default. Details can be found at https://aws.amazon.com/s3/storage-classes/. Supported values are: "+strings.Join(supportedStorageClasses, ", "))
cfg.SSE.RegisterFlagsWithPrefix(prefix+"s3.sse.", f)
cfg.HTTP.RegisterFlagsWithPrefix(prefix, f)
Expand Down

0 comments on commit 6a76b73

Please sign in to comment.