Skip to content

Commit cc3188f

Browse files
authored
Merge pull request #8582 from prymitive/storage.tsdb.delay-compact-file.path
Support newly added --storage.tsdb.delay-compact-file.path Prometheus…
2 parents 65be251 + 3a0665e commit cc3188f

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
1717

1818
### Added
1919

20+
- [#](https://github.com/thanos-io/thanos/pull/8582): Sidecar: support --storage.tsdb.delay-compact-file.path Prometheus flag.
21+
2022
### Changed
2123

2224
- [#8555](https://github.com/thanos-io/thanos/pull/8555): Promu: re-add Darwin and FreeBSD as release platforms

cmd/thanos/sidecar.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func runSidecar(
189189
iterCtx, iterCancel := context.WithTimeout(context.Background(), conf.prometheus.getConfigTimeout)
190190
defer iterCancel()
191191

192-
if err := validatePrometheus(iterCtx, m.client, logger, conf.shipper.ignoreBlockSize, m); err != nil {
192+
if err := validatePrometheus(iterCtx, m.client, logger, conf.shipper.ignoreBlockSize, conf.shipper.metaFileName, m); err != nil {
193193
level.Warn(logger).Log(
194194
"msg", "failed to validate prometheus flags. Is Prometheus running? Retrying",
195195
"err", err,
@@ -443,7 +443,7 @@ func runSidecar(
443443
return nil
444444
}
445445

446-
func validatePrometheus(ctx context.Context, client *promclient.Client, logger log.Logger, ignoreBlockSize bool, m *promMetadata) error {
446+
func validatePrometheus(ctx context.Context, client *promclient.Client, logger log.Logger, ignoreBlockSize bool, metaFileName string, m *promMetadata) error {
447447
var (
448448
flagErr error
449449
flags promclient.Flags
@@ -464,8 +464,16 @@ func validatePrometheus(ctx context.Context, client *promclient.Client, logger l
464464
return nil
465465
}
466466

467+
if flags.TSDBDelayCompact != "" && flags.TSDBDelayCompact != metaFileName {
468+
return errors.Errorf(
469+
"found that Prometheus and Thanos use different paths for tracking block uploads. "+
470+
"Prometheus uses --storage.tsdb.delay-compact-file.path=%s while Thanos uses --shipper.meta-file-name=%s, they must both use the same path.",
471+
flags.TSDBDelayCompact, metaFileName,
472+
)
473+
}
474+
467475
// Check if compaction is disabled.
468-
if flags.TSDBMinTime != flags.TSDBMaxTime {
476+
if flags.TSDBMinTime != flags.TSDBMaxTime && flags.TSDBDelayCompact == "" {
469477
if !ignoreBlockSize {
470478
return errors.Errorf("found that TSDB Max time is %s and Min time is %s. "+
471479
"Compaction needs to be disabled (storage.tsdb.min-block-duration = storage.tsdb.max-block-duration)", flags.TSDBMaxTime, flags.TSDBMinTime)

pkg/promclient/promclient.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ type Flags struct {
217217
TSDBRetention model.Duration `json:"storage.tsdb.retention"`
218218
TSDBMinTime model.Duration `json:"storage.tsdb.min-block-duration"`
219219
TSDBMaxTime model.Duration `json:"storage.tsdb.max-block-duration"`
220+
TSDBDelayCompact string `json:"storage.tsdb.delay-compact-file.path"`
220221
WebEnableAdminAPI bool `json:"web.enable-admin-api"`
221222
WebEnableLifecycle bool `json:"web.enable-lifecycle"`
222223
}
@@ -231,6 +232,7 @@ func (f *Flags) UnmarshalJSON(b []byte) error {
231232
TSDBRetention modelDuration `json:"storage.tsdb.retention"`
232233
TSDBMinTime modelDuration `json:"storage.tsdb.min-block-duration"`
233234
TSDBMaxTime modelDuration `json:"storage.tsdb.max-block-duration"`
235+
TSDBDelayCompact string `json:"storage.tsdb.delay-compact-file.path"`
234236
WebEnableAdminAPI modelBool `json:"web.enable-admin-api"`
235237
WebEnableLifecycle modelBool `json:"web.enable-lifecycle"`
236238
}{}
@@ -244,6 +246,7 @@ func (f *Flags) UnmarshalJSON(b []byte) error {
244246
TSDBRetention: model.Duration(parsableFlags.TSDBRetention),
245247
TSDBMinTime: model.Duration(parsableFlags.TSDBMinTime),
246248
TSDBMaxTime: model.Duration(parsableFlags.TSDBMaxTime),
249+
TSDBDelayCompact: parsableFlags.TSDBDelayCompact,
247250
WebEnableAdminAPI: bool(parsableFlags.WebEnableAdminAPI),
248251
WebEnableLifecycle: bool(parsableFlags.WebEnableLifecycle),
249252
}

0 commit comments

Comments
 (0)