Skip to content

Commit

Permalink
Address review issues
Browse files Browse the repository at this point in the history
Signed-off-by: Kemal Akkoyun <[email protected]>
  • Loading branch information
kakkoyun committed Dec 9, 2020
1 parent 6efb9c8 commit 81dbb29
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,8 @@ Highlights:

### Added

<<<<<<< HEAD
- [#3114](https://github.com/thanos-io/thanos/pull/3114) Query Frontend: Added support for Memacached cache.
- **breaking** Renamed flag `log_queries_longer_than` to `log-queries-longer-than`.
=======
- [#3114](https://github.com/thanos-io/thanos/pull/3114) Query Frontend: Added support for Memcached cache.
- **breaking** Renamed flag `log_queries_longer_than` to `log-queries-longer-than`.
>>>>>>> dedc7164 (Add ability to consume content of the hashring directly)
- [#3166](https://github.com/thanos-io/thanos/pull/3166) UIs: Added UI for passing a `storeMatch[]` parameter to queries.
- [#3181](https://github.com/thanos-io/thanos/pull/3181) Logging: Added debug level logging for responses between 300-399
- [#3133](https://github.com/thanos-io/thanos/pull/3133) Query: Allowed passing a `storeMatch[]` to Labels APIs; Time range metadata based store filtering is supported on Labels APIs.
Expand Down
13 changes: 3 additions & 10 deletions cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ func registerReceive(app *extkingpin.App) {
return errors.New("no external labels configured for receive, uniquely identifying external labels must be configured (ideally with `receive_` prefix); see https://thanos.io/tip/thanos/storage.md#external-labels for details.")
}

var cw *receive.ConfigWatcher
if *hashringsFile != "" {
cw, err = receive.NewConfigWatcher(log.With(logger, "component", "config-watcher"), reg, *hashringsFile, *refreshInterval)
if err != nil {
return err
}
}

tsdbOpts := &tsdb.Options{
MinBlockDuration: int64(time.Duration(*tsdbMinBlockDuration) / time.Millisecond),
MaxBlockDuration: int64(time.Duration(*tsdbMaxBlockDuration) / time.Millisecond),
Expand Down Expand Up @@ -376,8 +368,8 @@ func runReceive(
// watcher, we close the chan ourselves.
updates := make(chan receive.Hashring, 1)

// The Hashrings config file path given initializing config watcher.
if configPath, err := hashringsFile.Path(); err != nil {
// The Hashrings config file path is given initializing config watcher.
if configPath, err := hashringsFile.Path(); err == nil && configPath != "" {
cw, err := receive.NewConfigWatcher(log.With(logger, "component", "config-watcher"), reg, configPath, *refreshInterval)
if err != nil {
return errors.Wrap(err, "failed to initialize config watcher")
Expand All @@ -397,6 +389,7 @@ func runReceive(
cancel()
})
} else {
// The Hashrings config file path is not given, so initialize using content..
configContent, err := hashringsFile.Content()
if err != nil {
return errors.Wrap(err, "failed to read hashrings configuration file")
Expand Down
9 changes: 5 additions & 4 deletions pkg/extflag/pathorcontent.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func RegisterPathOrContent(cmd FlagClause, flagName string, help string, require
}
}

// Content returns the content of the file. Flag that specifies path has priority.
// Content returns the content of the file when given or directly the content that has passed to the flag.
// Flag that specifies path has priority.
// It returns error if the content is empty and required flag is set to true.
func (p *PathOrContent) Content() ([]byte, error) {
fileFlagName := fmt.Sprintf("%s-file", p.flagName)
Expand All @@ -71,9 +72,9 @@ func (p *PathOrContent) Content() ([]byte, error) {
return content, nil
}

// Path returns the path of the file. Flag that specifies path has priority.
// It returns error if the required flag is set to true and content is empty.
// It also returns errors if both a path and content are given.
// Path returns the path of the given file that has passed to the flag.
// It returns error if both a path and content are given.
// It returns error if the required flag is set to true and path is empty.
func (p *PathOrContent) Path() (string, error) {
fileFlagName := fmt.Sprintf("%s-file", p.flagName)

Expand Down

0 comments on commit 81dbb29

Please sign in to comment.