Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receive: Fixing auto-configuration of --receive.local-endpoint #2937

Merged
merged 2 commits into from Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel

### Fixed

- [#2937](https://github.com/thanos-io/thanos/pull/2937) Receive: Fixing auto-configuration of --receive.local-endpoint
- [#2665](https://github.com/thanos-io/thanos/pull/2665) Swift: fix issue with missing Content-Type HTTP headers.
- [#2800](https://github.com/thanos-io/thanos/pull/2800) Query: Fix handling of `--web.external-prefix` and `--web.route-prefix`
- [#2834](https://github.com/thanos-io/thanos/pull/2834) Query: Fix rendered JSON state value for rules and alerts should be in lowercase
Expand Down
10 changes: 5 additions & 5 deletions cmd/thanos/receive.go
Expand Up @@ -70,7 +70,7 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application) {
refreshInterval := modelDuration(cmd.Flag("receive.hashrings-file-refresh-interval", "Refresh interval to re-read the hashring configuration file. (used as a fallback)").
Default("5m"))

local := cmd.Flag("receive.local-endpoint", "Endpoint of local receive node. Used to identify the local node in the hashring configuration.").String()
localEndpoint := cmd.Flag("receive.local-endpoint", "Endpoint of local receive node. Used to identify the local node in the hashring configuration.").String()

tenantHeader := cmd.Flag("receive.tenant-header", "HTTP header to determine tenant for write requests.").Default(receive.DefaultTenantHeader).String()

Expand Down Expand Up @@ -120,14 +120,14 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application) {

// Local is empty, so try to generate a local endpoint
// based on the hostname and the listening port.
if *local == "" {
if *localEndpoint == "" {
hostname, err := os.Hostname()
if hostname == "" || err != nil {
return errors.New("--receive.local-endpoint is empty and host could not be determined.")
}
parts := strings.Split(*rwAddress, ":")
parts := strings.Split(*grpcBindAddr, ":")
port := parts[len(parts)-1]
*local = fmt.Sprintf("http://%s:%s/api/v1/receive", hostname, port)
*localEndpoint = fmt.Sprintf("%s:%s", hostname, port)
}

return runReceive(
Expand Down Expand Up @@ -156,7 +156,7 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application) {
*ignoreBlockSize,
lset,
cw,
*local,
*localEndpoint,
*tenantHeader,
*defaultTenantID,
*tenantLabelName,
Expand Down