From 4fdf55df46140ff053d386bff0fffa973049ebf5 Mon Sep 17 00:00:00 2001 From: Johnathan Falk Date: Tue, 17 Sep 2019 11:45:16 -0400 Subject: [PATCH] Add bucket inspect timeout flag (#1533) * Add bucket inspect timeout. Signed-off-by: Johnathan Falk * Added change log entry. Signed-off-by: Johnathan Falk --- CHANGELOG.md | 3 +++ cmd/thanos/bucket.go | 3 ++- docs/components/bucket.md | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 029f0b1ee3c..1e0c4df3102 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ We use *breaking* word for marking changes that are not backward compatible (rel ## Unreleased +## Added +-[1533](https://github.com/thanos-io/thanos/pull/1533) Thanos inspect now supports the timeout flag. + ### Fixed -[#1525](https://github.com/thanos-io/thanos/pull/1525) Thanos now deletes block's file in correct order allowing to detect partial blocks without problems. diff --git a/cmd/thanos/bucket.go b/cmd/thanos/bucket.go index 505ac87ea55..9c68d9b2b27 100644 --- a/cmd/thanos/bucket.go +++ b/cmd/thanos/bucket.go @@ -247,6 +247,7 @@ func registerBucketInspect(m map[string]setupFunc, root *kingpin.CmdClause, name PlaceHolder("=\\\"\\\"").Strings() sortBy := cmd.Flag("sort-by", "Sort by columns. It's also possible to sort by multiple columns, e.g. '--sort-by FROM --sort-by UNTIL'. I.e., if the 'FROM' value is equal the rows are then further sorted by the 'UNTIL' value."). Default("FROM", "UNTIL").Enums(inspectColumns...) + timeout := cmd.Flag("timeout", "Timeout to download metadata from remote storage").Default("5m").Duration() m[name+" inspect"] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ bool) error { @@ -271,7 +272,7 @@ func registerBucketInspect(m map[string]setupFunc, root *kingpin.CmdClause, name defer runutil.CloseWithLogOnErr(logger, bkt, "bucket client") - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), *timeout) defer cancel() // Getting Metas. diff --git a/docs/components/bucket.md b/docs/components/bucket.md index 9414dd2f7a9..ef08e2863fe 100644 --- a/docs/components/bucket.md +++ b/docs/components/bucket.md @@ -278,5 +278,6 @@ Flags: multiple columns, e.g. '--sort-by FROM --sort-by UNTIL'. I.e., if the 'FROM' value is equal the rows are then further sorted by the 'UNTIL' value. + --timeout=5m Timeout to download metadata from remote storage ```