Skip to content

Commit

Permalink
query, rule: make endpoint discovery dynamically reloadable
Browse files Browse the repository at this point in the history
* Removed previously deprecated and hidden flags to configure endpoints ( --rule, --target, ...)
* Added new flags --endpoint.sd-config, --endpoint-sd-config-reload-interval to configure a dynamic SD file
* Moved endpoint set construction into cmd/thanos/endpointset.go for a little cleanup

The new config makes it possible to also set "strict" and "group" flags on the endpoint instead
of only their addresses, making it possible to have file based service discovery for endpoint groups too.

Signed-off-by: Michael Hoffmann <[email protected]>
Signed-off-by: Michael Hoffmann <[email protected]>
  • Loading branch information
MichaHoffmann authored and Michael Hoffmann committed Dec 16, 2024
1 parent 520d2dd commit 6ff8f1b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 53 deletions.
16 changes: 0 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,16 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re

### Fixed

- [#7970](https://github.com/thanos-io/thanos/pull/7970) Sidecar: Respect min-time setting.

### Added

- [#7907](https://github.com/thanos-io/thanos/pull/7907) Receive: Add `--receive.grpc-service-config` flag to configure gRPC service config for the receivers.
- [#7961](https://github.com/thanos-io/thanos/pull/7961) Store Gateway: Add `--store.posting-group-max-keys` flag to mark posting group as lazy if it exceeds number of keys limit. Added `thanos_bucket_store_lazy_expanded_posting_groups_total` for total number of lazy posting groups and corresponding reasons.

### Changed

- [#7890](https://github.com/thanos-io/thanos/pull/7890) Query,Ruler: *breaking :warning:* deprecated `--store.sd-file` and `--store.sd-interval` to be replaced with `--endpoint.sd-config` and `--endpoint-sd-config-reload-interval`; removed legacy flags to pass endpoints `--store`, `--metadata`, `--rule`, `--exemplar`.

### Removed

## [v0.37.2](https://github.com/thanos-io/thanos/tree/release-0.37) - 11.12.2024

### Fixed

- [#7970](https://github.com/thanos-io/thanos/pull/7970) Sidecar: Respect min-time setting.
- [#7962](https://github.com/thanos-io/thanos/pull/7962) Store: Fix potential deadlock in hedging request.

### Added

### Changed

### Removed

## [v0.37.1](https://github.com/thanos-io/thanos/tree/release-0.37) - 04.12.2024

### Fixed
Expand Down
73 changes: 36 additions & 37 deletions cmd/thanos/endpointset.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ func setupEndpointSet(
dialOpts []grpc.DialOption,
queryConnMetricLabels ...string,
) (*query.EndpointSet, error) {
ctx, cancel := context.WithCancel(context.Background())

configProvider, err := newEndpointConfigProvider(
logger,
configFile,
Expand Down Expand Up @@ -248,47 +246,48 @@ func setupEndpointSet(
}
return deduplicated
}
legacyFileSDCache := cache.New()
{
var fileSD *file.Discovery
if len(legacyFileSDFiles) > 0 {
conf := &file.SDConfig{
Files: legacyFileSDFiles,
RefreshInterval: model.Duration(legacyFileSDInterval),
}
var err error
if fileSD, err = file.NewDiscovery(conf, logger, conf.NewDiscovererMetrics(reg, discovery.NewRefreshMetrics(reg))); err != nil {
return nil, fmt.Errorf("unable to create new legacy file sd config: %w", err)
}
var fileSD *file.Discovery
if len(legacyFileSDFiles) > 0 {
conf := &file.SDConfig{
Files: legacyFileSDFiles,
RefreshInterval: model.Duration(legacyFileSDInterval),
}
var err error
if fileSD, err = file.NewDiscovery(conf, logger, conf.NewDiscovererMetrics(reg, discovery.NewRefreshMetrics(reg))); err != nil {
return nil, fmt.Errorf("unable to create new legacy file sd config: %w", err)
}
}
legacyFileSDCache := cache.New()

if fileSD != nil {
fileSDUpdates := make(chan []*targetgroup.Group)
ctx, cancel := context.WithCancel(context.Background())

g.Add(func() error {
fileSD.Run(ctx, fileSDUpdates)
return nil
if fileSD != nil {
fileSDUpdates := make(chan []*targetgroup.Group)

}, func(err error) {
cancel()
})
g.Add(func() error {
for {
select {
case update := <-fileSDUpdates:
// Discoverers sometimes send nil updates so need to check for it to avoid panics.
if update == nil {
continue
}
legacyFileSDCache.Update(update)
case <-ctx.Done():
return nil
g.Add(func() error {
fileSD.Run(ctx, fileSDUpdates)
return nil

}, func(err error) {
cancel()
})

g.Add(func() error {
for {
select {
case update := <-fileSDUpdates:
// Discoverers sometimes send nil updates so need to check for it to avoid panics.
if update == nil {
continue
}
legacyFileSDCache.Update(update)
case <-ctx.Done():
return nil
}
}, func(err error) {
cancel()
})
}
}
}, func(err error) {
cancel()
})
}

{
Expand Down

0 comments on commit 6ff8f1b

Please sign in to comment.