Skip to content

Commit 6ede0f1

Browse files
committed
Merge main
2 parents 4bc99d7 + cfdd0e5 commit 6ede0f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2385
-1157
lines changed

.bingo/Variables.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ $(GOIMPORTS): $(BINGO_DIR)/goimports.mod
4141
@echo "(re)installing $(GOBIN)/goimports-v0.0.0-20200526224456-8b020aee10d2"
4242
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=goimports.mod -o=$(GOBIN)/goimports-v0.0.0-20200526224456-8b020aee10d2 "golang.org/x/tools/cmd/goimports"
4343

44-
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.46.2
44+
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.54.1
4545
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
4646
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
47-
@echo "(re)installing $(GOBIN)/golangci-lint-v1.46.2"
48-
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.46.2 "github.com/golangci/golangci-lint/cmd/golangci-lint"
47+
@echo "(re)installing $(GOBIN)/golangci-lint-v1.54.1"
48+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.54.1 "github.com/golangci/golangci-lint/cmd/golangci-lint"
4949

5050
MDOX := $(GOBIN)/mdox-v0.9.0
5151
$(MDOX): $(BINGO_DIR)/mdox.mod

.bingo/copyright.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
22

3-
go 1.18
3+
go 1.20
44

55
require github.com/efficientgo/tools/copyright v0.0.0-20220225185207-fe763185946b

.bingo/golangci-lint.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
22

33
go 1.14
44

5-
require github.com/golangci/golangci-lint v1.46.2 // cmd/golangci-lint
5+
require github.com/golangci/golangci-lint v1.54.1 // cmd/golangci-lint

.bingo/golangci-lint.sum

+397
Large diffs are not rendered by default.

.bingo/mdox.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
22

3-
go 1.18
3+
go 1.20
44

55
require github.com/bwplotka/mdox v0.9.0

.bingo/variables.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ FAILLINT="${GOBIN}/faillint-v1.11.0"
1616

1717
GOIMPORTS="${GOBIN}/goimports-v0.0.0-20200526224456-8b020aee10d2"
1818

19-
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.46.2"
19+
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.54.1"
2020

2121
MDOX="${GOBIN}/mdox-v0.9.0"
2222

.github/workflows/codeql-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: Set up Go
4141
uses: actions/setup-go@v2
4242
with:
43-
go-version: 1.18
43+
go-version: 1.20.x
4444

4545
# Initializes the CodeQL tools for scanning.
4646
- name: Initialize CodeQL

.github/workflows/docs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install Go
2121
uses: actions/setup-go@v2
2222
with:
23-
go-version: 1.18.x
23+
go-version: 1.21.x
2424

2525
- uses: actions/cache@v1
2626
with:

.go-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.18
1+
1.21.x

CHANGELOG.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@ NOTE: As semantic versioning states all 0.y.z releases can contain breaking chan
99
We use *breaking :warning:* to mark changes that are not backward compatible (relates only to v0.y.z releases.)
1010

1111
## Unreleased
12+
- [#38](https://github.com/thanos-io/objstore/pull/38) GCS: Upgrade cloud.google.com/go/storage version to `v1.43.0`.
13+
- [#145](https://github.com/thanos-io/objstore/pull/145) Include content length in the response of Get and GetRange.
1214

1315
### Fixed
16+
- [#153](https://github.com/thanos-io/objstore/pull/153) Metrics: Fix `objstore_bucket_operation_duration_seconds_*` for `get` and `get_range` operations.
17+
- [#117](https://github.com/thanos-io/objstore/pull/117) Metrics: Fix `objstore_bucket_operation_failures_total` incorrectly incremented if context is cancelled while reading object contents.
18+
- [#115](https://github.com/thanos-io/objstore/pull/115) GCS: Fix creation of bucket with GRPC connections. Also update storage client to `v1.40.0`.
19+
- [#102](https://github.com/thanos-io/objstore/pull/102) Azure: bump azblob sdk to get concurrency fixes.
1420
- [#33](https://github.com/thanos-io/objstore/pull/33) Tracing: Add `ContextWithTracer()` to inject the tracer into the context.
1521
- [#34](https://github.com/thanos-io/objstore/pull/34) Fix ignored options when creating shared credential Azure client.
1622
- [#62](https://github.com/thanos-io/objstore/pull/62) S3: Fix ignored context cancellation in `Iter` method.
23+
- [#77](https://github.com/thanos-io/objstore/pull/77) Fix buckets wrapped with metrics from being unable to determine object sizes in `Upload`.
24+
- [#78](https://github.com/thanos-io/objstore/pull/78) S3: Fix possible concurrent modification of the PutUserMetadata map.
25+
- [#79](https://github.com/thanos-io/objstore/pull/79) Metrics: Fix `objstore_bucket_operation_duration_seconds` for `iter` operations.
1726

1827
### Added
1928
- [#15](https://github.com/thanos-io/objstore/pull/15) Add Oracle Cloud Infrastructure Object Storage Bucket support.
@@ -27,10 +36,32 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
2736
- [#61](https://github.com/thanos-io/objstore/pull/61) Add OpenTelemetry TracingBucket.
2837
> This also changes the behaviour of `client.NewBucket`. Now it returns, uninstrumented and untraced bucket.
2938
You can combine `objstore.WrapWithMetrics` and `tracing/{opentelemetry,opentracing}.WrapWithTraces` to have old behavior.
39+
- [#69](https://github.com/thanos-io/objstore/pull/69) [#66](https://github.com/thanos-io/objstore/pull/66) Add `objstore_bucket_operation_transferred_bytes` that counts the number of total bytes read from the bucket operation Get/GetRange and also counts the number of total bytes written to the bucket operation Upload.
40+
- [#64](https://github.com/thanos-io/objstore/pull/64) OCI: OKE Workload Identity support.
41+
- [#73](https://github.com/thanos-io/objstore/pull/73) Аdded file path to erros from DownloadFile
42+
- [#51](https://github.com/thanos-io/objstore/pull/51) Azure: Support using connection string authentication.
43+
- [#76](https://github.com/thanos-io/objstore/pull/76) GCS: Query for object names only in `Iter` to possibly improve performance when listing objects.
44+
- [#85](https://github.com/thanos-io/objstore/pull/85) S3: Allow checksum algorithm to be configured
45+
- [#92](https://github.com/thanos-io/objstore/pull/92) GCS: Allow using a gRPC client.
46+
- [#94](https://github.com/thanos-io/objstore/pull/94) Allow timingReadCloser to be seeker
47+
- [#96](https://github.com/thanos-io/objstore/pull/96) Allow nopCloserWithObjectSize to be seeker
48+
- [#86](https://github.com/thanos-io/objstore/pull/86) GCS: Add HTTP Config to GCS
49+
- [#99](https://github.com/thanos-io/objstore/pull/99) Swift: Add HTTP_Config
50+
- [#108](https://github.com/thanos-io/objstore/pull/108) Metrics: Add native histogram definitions to histograms
51+
- [#112](https://github.com/thanos-io/objstore/pull/112) S3: Add `DisableDualstack option.
52+
- [#100](https://github.com/thanos-io/objstore/pull/100) s3: add DisableMultipart option
53+
- [#116](https://github.com/thanos-io/objstore/pull/116) Azure: Add new storage_create_container configuration property
54+
- [#128](https://github.com/thanos-io/objstore/pull/128) GCS: Add support for `ChunkSize` for writer.
55+
- [#130](https://github.com/thanos-io/objstore/pull/130) feat: Decouple creating bucket metrics from instrumenting the bucket
56+
- [#150](https://github.com/thanos-io/objstore/pull/150) Add support for roundtripper wrapper.
3057

3158
### Changed
3259
- [#38](https://github.com/thanos-io/objstore/pull/38) *: Upgrade minio-go version to `v7.0.45`.
3360
- [#39](https://github.com/thanos-io/objstore/pull/39) COS: Upgrade cos sdk version to `v0.7.40`.
3461
- [#35](https://github.com/thanos-io/objstore/pull/35) Azure: Update Azure SDK and fix breaking changes.
35-
62+
- [#65](https://github.com/thanos-io/objstore/pull/65) *: Upgrade minio-go version to `v7.0.61`.
63+
- [#70](https://github.com/thanos-io/objstore/pull/70) GCS: Update cloud.google.com/go/storage version to `v1.27.0`.
64+
- [#71](https://github.com/thanos-io/objstore/pull/71) Replace method `IsCustomerManagedKeyError` for a more generic `IsAccessDeniedErr` on the bucket interface.
65+
- [#89](https://github.com/thanos-io/objstore/pull/89) GCS: Upgrade cloud.google.com/go/storage version to `v1.35.1`.
66+
- [#123](https://github.com/thanos-io/objstore/pull/123) *: Upgrade minio-go version to `v7.0.71`.
3667
### Removed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ check-docs: $(MDOX)
3939

4040
.PHONY: deps
4141
deps: ## Ensures fresh go.mod and go.sum.
42-
@go mod tidy -compat=1.18
42+
@go mod tidy -compat=1.20
4343
@go mod verify
4444

4545
.PHONY: format

README.md

+83-7
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ See [MAINTAINERS.md](https://github.com/thanos-io/thanos/blob/main/MAINTAINERS.m
4848

4949
The core this module is the [`Bucket` interface](objstore.go):
5050

51-
```go mdox-exec="sed -n '37,50p' objstore.go"
51+
```go mdox-exec="sed -n '39,55p' objstore.go"
5252
// Bucket provides read and write access to an object storage bucket.
5353
// NOTE: We assume strong consistency for write-read flow.
5454
type Bucket interface {
@@ -63,18 +63,31 @@ type Bucket interface {
6363
// If object does not exist in the moment of deletion, Delete should throw error.
6464
Delete(ctx context.Context, name string) error
6565

66+
// Name returns the bucket name for the provider.
67+
Name() string
68+
}
6669
```
6770

6871
All [provider implementations](providers) have to implement `Bucket` interface that allows common read and write operations that all supported by all object providers. If you want to limit the code that will do bucket operation to only read access (smart idea, allowing to limit access permissions), you can use the [`BucketReader` interface](objstore.go):
6972

70-
```go mdox-exec="sed -n '68,88p' objstore.go"
71-
73+
```go mdox-exec="sed -n '71,106p' objstore.go"
7274
// BucketReader provides read access to an object storage bucket.
7375
type BucketReader interface {
7476
// Iter calls f for each entry in the given directory (not recursive.). The argument to f is the full
7577
// object name including the prefix of the inspected directory.
78+
7679
// Entries are passed to function in sorted order.
77-
Iter(ctx context.Context, dir string, f func(string) error, options ...IterOption) error
80+
Iter(ctx context.Context, dir string, f func(name string) error, options ...IterOption) error
81+
82+
// IterWithAttributes calls f for each entry in the given directory similar to Iter.
83+
// In addition to Name, it also includes requested object attributes in the argument to f.
84+
//
85+
// Attributes can be requested using IterOption.
86+
// Not all IterOptions are supported by all providers, requesting for an unsupported option will fail with ErrOptionNotSupported.
87+
IterWithAttributes(ctx context.Context, dir string, f func(attrs IterObjectAttributes) error, options ...IterOption) error
88+
89+
// SupportedIterOptions returns a list of supported IterOptions by the underlying provider.
90+
SupportedIterOptions() []IterOptionType
7891

7992
// Get returns a reader for the given object name.
8093
Get(ctx context.Context, name string) (io.ReadCloser, error)
@@ -88,7 +101,12 @@ type BucketReader interface {
88101
// IsObjNotFoundErr returns true if error means that object is not found. Relevant to Get operations.
89102
IsObjNotFoundErr(err error) bool
90103

91-
// IsCustomerManagedKeyError returns true if the permissions for key used to encrypt the object was revoked.
104+
// IsAccessDeniedErr returns true if access to object is denied.
105+
IsAccessDeniedErr(err error) bool
106+
107+
// Attributes returns information about the specified object.
108+
Attributes(ctx context.Context, name string) (ObjectAttributes, error)
109+
}
92110
```
93111

94112
Those interfaces represent the object storage operations your code can use from `objstore` clients.
@@ -140,14 +158,15 @@ Thanos uses the [minio client](https://github.com/minio/minio-go) library to upl
140158
141159
> NOTE: S3 client was designed for AWS S3, but it can be configured against other S3-compatible object storages e.g Ceph
142160
143-
The S# object storage yaml configuration definition:
161+
The S3 object storage yaml configuration definition:
144162
145163
```yaml mdox-exec="go run scripts/cfggen/main.go --name=s3.Config"
146164
type: S3
147165
config:
148166
bucket: ""
149167
endpoint: ""
150168
region: ""
169+
disable_dualstack: false
151170
aws_sdk_auth: false
152171
access_key: ""
153172
insecure: false
@@ -175,6 +194,8 @@ config:
175194
enable: false
176195
list_objects_version: ""
177196
bucket_lookup_type: auto
197+
send_content_md5: true
198+
disable_multipart: false
178199
part_size: 67108864
179200
sse_config:
180201
type: ""
@@ -193,6 +214,8 @@ The field `prefix` can be used to transparently use prefixes in your S3 bucket.
193214

194215
The AWS region to endpoint mapping can be found in this [link](https://docs.aws.amazon.com/general/latest/gr/s3.html).
195216

217+
By default, the library prefers using [dual-stack endpoints](https://docs.aws.amazon.com/AmazonS3/latest/userguide/dual-stack-endpoints.html). You can explicitly disable this behaviour by setting `disable_dualstack: true`.
218+
196219
Make sure you use a correct signature version. Currently AWS requires signature v4, so it needs `signature_version2: false`. If you don't specify it, you will get an `Access Denied` error. On the other hand, several S3 compatible APIs use `signature_version2: true`.
197220

198221
You can configure the timeout settings for the HTTP client by setting the `http_config.idle_conn_timeout` and `http_config.response_header_timeout` keys. As a rule of thumb, if you are seeing errors like `timeout awaiting response headers` in your logs, you may want to increase the value of `http_config.response_header_timeout`.
@@ -346,6 +369,25 @@ type: GCS
346369
config:
347370
bucket: ""
348371
service_account: ""
372+
use_grpc: false
373+
grpc_conn_pool_size: 0
374+
http_config:
375+
idle_conn_timeout: 0s
376+
response_header_timeout: 0s
377+
insecure_skip_verify: false
378+
tls_handshake_timeout: 0s
379+
expect_continue_timeout: 0s
380+
max_idle_conns: 0
381+
max_idle_conns_per_host: 0
382+
max_conns_per_host: 0
383+
tls_config:
384+
ca_file: ""
385+
cert_file: ""
386+
key_file: ""
387+
server_name: ""
388+
insecure_skip_verify: false
389+
disable_compression: false
390+
chunk_size_bytes: 0
349391
prefix: ""
350392
```
351393

@@ -418,6 +460,8 @@ type: AZURE
418460
config:
419461
storage_account: ""
420462
storage_account_key: ""
463+
storage_connection_string: ""
464+
storage_create_container: false
421465
container: ""
422466
endpoint: ""
423467
user_assigned_id: ""
@@ -453,6 +497,8 @@ If `msi_resource` is used, authentication is done via system-assigned managed id
453497

454498
If `user_assigned_id` is used, authentication is done via user-assigned managed identity. When using `user_assigned_id` the `msi_resource` defaults to `https://<storage_account>.<endpoint>`
455499

500+
If `storage_connection_string` is set, the values of `storage_account` and `endpoint` values will not be used. Use this method over `storage_account_key` if you need to authenticate via a SAS token.
501+
456502
The generic `max_retries` will be used as value for the `pipeline_config`'s `max_tries` and `reader_config`'s `max_retry_requests`. For more control, `max_retries` could be ignored (0) and one could set specific retry values.
457503

458504
##### OpenStack Swift
@@ -490,6 +536,22 @@ config:
490536
connect_timeout: 10s
491537
timeout: 5m
492538
use_dynamic_large_objects: false
539+
http_config:
540+
idle_conn_timeout: 1m30s
541+
response_header_timeout: 2m
542+
insecure_skip_verify: false
543+
tls_handshake_timeout: 10s
544+
expect_continue_timeout: 1s
545+
max_idle_conns: 100
546+
max_idle_conns_per_host: 100
547+
max_conns_per_host: 0
548+
tls_config:
549+
ca_file: ""
550+
cert_file: ""
551+
key_file: ""
552+
server_name: ""
553+
insecure_skip_verify: false
554+
disable_compression: false
493555
prefix: ""
494556
```
495557

@@ -578,7 +640,7 @@ prefix: ""
578640

579641
### Oracle Cloud Infrastructure Object Storage
580642

581-
To configure Oracle Cloud Infrastructure (OCI) Object Storage as Thanos Object Store, you need to provide appropriate authentication credentials to your OCI tenancy. The OCI object storage client implementation for Thanos supports either the default keypair or instance principal authentication.
643+
To configure Oracle Cloud Infrastructure (OCI) Object Storage as a Thanos Object Store, you need to provide appropriate authentication credentials to your OCI tenancy. The OCI object storage client implementation for Thanos supports default keypair, instance principal, and OKE workload identity authentication.
582644

583645
#### API Signing Key
584646

@@ -642,6 +704,20 @@ config:
642704

643705
You can also include any of the optional configuration just like the example in `Default Provider`.
644706

707+
#### OKE Workload Identity Provider
708+
709+
For Example:
710+
711+
```yaml
712+
type: OCI
713+
config:
714+
provider: "oke-workload-identity"
715+
bucket: ""
716+
region: ""
717+
```
718+
719+
The `bucket` and `region` fields are required. The `region` field identifies the bucket region.
720+
645721
##### HuaweiCloud OBS
646722

647723
To use HuaweiCloud OBS as an object store, you should apply for a HuaweiCloud Account to create an object storage bucket at first. More details: [HuaweiCloud OBS](https://support.huaweicloud.com/obs/index.html)

client/factory.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package client
66
import (
77
"context"
88
"fmt"
9+
"net/http"
910
"strings"
1011

1112
"github.com/thanos-io/objstore"
@@ -49,7 +50,7 @@ type BucketConfig struct {
4950

5051
// NewBucket initializes and returns new object storage clients.
5152
// NOTE: confContentYaml can contain secrets.
52-
func NewBucket(logger log.Logger, confContentYaml []byte, component string) (objstore.Bucket, error) {
53+
func NewBucket(logger log.Logger, confContentYaml []byte, component string, wrapRoundtripper func(http.RoundTripper) http.RoundTripper) (objstore.Bucket, error) {
5354
level.Info(logger).Log("msg", "loading bucket configuration")
5455
bucketConf := &BucketConfig{}
5556
if err := yaml.UnmarshalStrict(confContentYaml, bucketConf); err != nil {
@@ -64,23 +65,23 @@ func NewBucket(logger log.Logger, confContentYaml []byte, component string) (obj
6465
var bucket objstore.Bucket
6566
switch strings.ToUpper(string(bucketConf.Type)) {
6667
case string(GCS):
67-
bucket, err = gcs.NewBucket(context.Background(), logger, config, component)
68+
bucket, err = gcs.NewBucket(context.Background(), logger, config, component, wrapRoundtripper)
6869
case string(S3):
69-
bucket, err = s3.NewBucket(logger, config, component)
70+
bucket, err = s3.NewBucket(logger, config, component, wrapRoundtripper)
7071
case string(AZURE):
71-
bucket, err = azure.NewBucket(logger, config, component)
72+
bucket, err = azure.NewBucket(logger, config, component, wrapRoundtripper)
7273
case string(SWIFT):
73-
bucket, err = swift.NewContainer(logger, config)
74+
bucket, err = swift.NewContainer(logger, config, wrapRoundtripper)
7475
case string(COS):
75-
bucket, err = cos.NewBucket(logger, config, component)
76+
bucket, err = cos.NewBucket(logger, config, component, wrapRoundtripper)
7677
case string(ALIYUNOSS):
77-
bucket, err = oss.NewBucket(logger, config, component)
78+
bucket, err = oss.NewBucket(logger, config, component, wrapRoundtripper)
7879
case string(FILESYSTEM):
7980
bucket, err = filesystem.NewBucketFromConfig(config)
8081
case string(BOS):
8182
bucket, err = bos.NewBucket(logger, config, component)
8283
case string(OCI):
83-
bucket, err = oci.NewBucket(logger, config)
84+
bucket, err = oci.NewBucket(logger, config, wrapRoundtripper)
8485
case string(OBS):
8586
bucket, err = obs.NewBucket(logger, config)
8687
default:

0 commit comments

Comments
 (0)