Skip to content

Commit 8349902

Browse files
committed
Exposed --shipper.upload-compacted flag in components that use shipper
Signed-off-by: Rafał Dowgird <rafal.dowgird@rtbhouse.com>
1 parent 9c0775c commit 8349902

File tree

12 files changed

+52
-4
lines changed

12 files changed

+52
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
1919
### Added
2020

2121
- [#](https://github.com/thanos-io/thanos/pull/8582): Sidecar: support --storage.tsdb.delay-compact-file.path Prometheus flag.
22+
- [#](.): Tools: add --shipper.upload-compacted flag for controlling upload concurrency in bucket upload-blocks
2223

2324
### Changed
2425

cmd/thanos/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ type shipperConfig struct {
206206
skipCorruptedBlocks bool
207207
hashFunc string
208208
metaFileName string
209+
uploadConcurrency int
209210
}
210211

211212
func (sc *shipperConfig) registerFlag(cmd extkingpin.FlagClause) *shipperConfig {
@@ -228,6 +229,7 @@ func (sc *shipperConfig) registerFlag(cmd extkingpin.FlagClause) *shipperConfig
228229
cmd.Flag("hash-func", "Specify which hash function to use when calculating the hashes of produced files. If no function has been specified, it does not happen. This permits avoiding downloading some files twice albeit at some performance cost. Possible values are: \"\", \"SHA256\".").
229230
Default("").EnumVar(&sc.hashFunc, "SHA256", "")
230231
cmd.Flag("shipper.meta-file-name", "the file to store shipper metadata in").Default(shipper.DefaultMetaFilename).StringVar(&sc.metaFileName)
232+
cmd.Flag("shipper.upload-concurrency", "Number of goroutines to use when uploading block files to object storage.").Default("0").IntVar(&sc.uploadConcurrency)
231233
return sc
232234
}
233235

cmd/thanos/receive.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ func runReceive(
235235
multiTSDBOptions = append(multiTSDBOptions, receive.WithMatchersCache(cache))
236236
}
237237

238+
multiTSDBOptions = append(multiTSDBOptions, receive.WithUploadConcurrency(conf.uploadConcurrency))
239+
238240
dbs := receive.NewMultiTSDB(
239241
conf.dataDir,
240242
logger,
@@ -916,6 +918,7 @@ type receiveConfig struct {
916918
ignoreBlockSize bool
917919
allowOutOfOrderUpload bool
918920
skipCorruptedBlocks bool
921+
uploadConcurrency int
919922

920923
reqLogConfig *extflag.PathOrContent
921924
relabelConfigPath *extflag.PathOrContent
@@ -1093,6 +1096,8 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
10931096
"about order.").
10941097
Default("false").Hidden().BoolVar(&rc.skipCorruptedBlocks)
10951098

1099+
cmd.Flag("shipper.upload-concurrency", "Number of goroutines to use when uploading block files to object storage.").Default("0").IntVar(&rc.uploadConcurrency)
1100+
10961101
cmd.Flag("matcher-cache-size", "Max number of cached matchers items. Using 0 disables caching.").Default("0").IntVar(&rc.matcherCacheSize)
10971102

10981103
rc.reqLogConfig = extkingpin.RegisterRequestLoggingFlags(cmd)

cmd/thanos/rule.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ func runRule(
871871
shipper.WithLabels(func() labels.Labels { return conf.lset }),
872872
shipper.WithAllowOutOfOrderUploads(conf.shipper.allowOutOfOrderUpload),
873873
shipper.WithSkipCorruptedBlocks(conf.shipper.skipCorruptedBlocks),
874+
shipper.WithUploadConcurrency(conf.shipper.uploadConcurrency),
874875
)
875876

876877
ctx, cancel := context.WithCancel(context.Background())

cmd/thanos/sidecar.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ func runSidecar(
426426
shipper.WithUploadCompacted(conf.shipper.uploadCompacted),
427427
shipper.WithAllowOutOfOrderUploads(conf.shipper.allowOutOfOrderUpload),
428428
shipper.WithSkipCorruptedBlocks(conf.shipper.skipCorruptedBlocks),
429+
shipper.WithUploadConcurrency(conf.shipper.uploadConcurrency),
429430
)
430431

431432
return runutil.Repeat(30*time.Second, ctx.Done(), func() error {

cmd/thanos/tools_bucket.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ type bucketMarkBlockConfig struct {
166166
}
167167

168168
type bucketUploadBlocksConfig struct {
169-
path string
170-
labels []string
171-
uploadCompacted bool
169+
path string
170+
labels []string
171+
uploadCompacted bool
172+
uploadConcurrency int
172173
}
173174

174175
func (tbc *bucketVerifyConfig) registerBucketVerifyFlag(cmd extkingpin.FlagClause) *bucketVerifyConfig {
@@ -302,6 +303,7 @@ func (tbc *bucketUploadBlocksConfig) registerBucketUploadBlocksFlag(cmd extkingp
302303
cmd.Flag("path", "Path to the directory containing blocks to upload.").Default("./data").StringVar(&tbc.path)
303304
cmd.Flag("label", "External labels to add to the uploaded blocks (repeated).").PlaceHolder("key=\"value\"").StringsVar(&tbc.labels)
304305
cmd.Flag("shipper.upload-compacted", "If true shipper will try to upload compacted blocks as well.").Default("false").BoolVar(&tbc.uploadCompacted)
306+
cmd.Flag("shipper.upload-concurrency", "Number of goroutines to use when uploading block files to object storage.").Default("5").IntVar(&tbc.uploadConcurrency)
305307

306308
return tbc
307309
}
@@ -1512,6 +1514,7 @@ func registerBucketUploadBlocks(app extkingpin.AppClause, objStoreConfig *extfla
15121514
shipper.WithMetaFileName(shipper.DefaultMetaFilename),
15131515
shipper.WithLabels(func() labels.Labels { return lset }),
15141516
shipper.WithUploadCompacted(tbc.uploadCompacted),
1517+
shipper.WithUploadConcurrency(tbc.uploadConcurrency),
15151518
)
15161519

15171520
ctx, cancel := context.WithCancel(context.Background())

docs/components/receive.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,9 @@ Flags:
643643
happen. This permits avoiding downloading some
644644
files twice albeit at some performance cost.
645645
Possible values are: "", "SHA256".
646+
--shipper.upload-concurrency=0
647+
Number of goroutines to use when uploading
648+
block files to object storage.
646649
--matcher-cache-size=0 Max number of cached matchers items. Using 0
647650
disables caching.
648651
--request.logging-config-file=<file-path>

docs/components/rule.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ Flags:
362362
Possible values are: "", "SHA256".
363363
--shipper.meta-file-name="thanos.shipper.json"
364364
the file to store shipper metadata in
365+
--shipper.upload-concurrency=0
366+
Number of goroutines to use when uploading
367+
block files to object storage.
365368
--query=<query> ... Addresses of statically configured query
366369
API servers (repeatable). The scheme may be
367370
prefixed with 'dns+' or 'dnssrv+' to detect

docs/components/sidecar.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ Flags:
220220
Possible values are: "", "SHA256".
221221
--shipper.meta-file-name="thanos.shipper.json"
222222
the file to store shipper metadata in
223+
--shipper.upload-concurrency=0
224+
Number of goroutines to use when uploading
225+
block files to object storage.
223226
--store.limits.request-series=0
224227
The maximum series allowed for a single Series
225228
request. The Series call fails if this limit is

docs/components/tools.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,9 @@ Flags:
10541054
--[no-]shipper.upload-compacted
10551055
If true shipper will try to upload compacted
10561056
blocks as well.
1057+
--shipper.upload-concurrency=5
1058+
Number of goroutines to use when uploading block
1059+
files to object storage.
10571060
10581061
```
10591062

0 commit comments

Comments
 (0)