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

query, rule: make endpoint discovery dynamically reloadable #7890

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichaHoffmann
Copy link
Contributor

@MichaHoffmann MichaHoffmann commented Nov 7, 2024

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

  • Removed previously deprecated and hidden flags to configure endpoints ( --rule, --target, ...)
  • Deprecated --store.sd-file and --store.sd-interval flags
  • 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.

Verification

Existing E2E test suite, some manual testing.

@MichaHoffmann MichaHoffmann force-pushed the mhoffmann/make-endpoint-config-dynamically-reloadable branch 3 times, most recently from 7b8c118 to 249620c Compare November 7, 2024 13:52
Copy link
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it generally makes a lot of sense to me.

Just one small comment!

cmd/thanos/query.go Show resolved Hide resolved
cmd/thanos/endpointset.go Outdated Show resolved Hide resolved
cmd/thanos/endpointset.go Outdated Show resolved Hide resolved
cmd/thanos/endpointset.go Outdated Show resolved Hide resolved
@MichaHoffmann MichaHoffmann force-pushed the mhoffmann/make-endpoint-config-dynamically-reloadable branch 8 times, most recently from e57969b to 963126d Compare November 8, 2024 15:55
@MichaHoffmann MichaHoffmann force-pushed the mhoffmann/make-endpoint-config-dynamically-reloadable branch 5 times, most recently from d5cfc49 to e9f1ff4 Compare November 8, 2024 17:44
@MichaHoffmann MichaHoffmann force-pushed the mhoffmann/make-endpoint-config-dynamically-reloadable branch 5 times, most recently from 12a9008 to 529954c Compare November 10, 2024 13:36
@MichaHoffmann MichaHoffmann force-pushed the mhoffmann/make-endpoint-config-dynamically-reloadable branch 3 times, most recently from bb7e84d to d3efbc2 Compare November 12, 2024 12:23
@MichaHoffmann MichaHoffmann force-pushed the mhoffmann/make-endpoint-config-dynamically-reloadable branch 2 times, most recently from cb05e05 to 3284e0d Compare November 12, 2024 13:19
saswatamcode
saswatamcode previously approved these changes Nov 12, 2024
Copy link
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

return ""
}

type EndpointSpec struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be closer to the endpointset in the query package.

fpetkovski
fpetkovski previously approved these changes Nov 13, 2024
{
// Setup Legacy File SD
var fileSD *file.Discovery
if len(legacyFileSDFiles) > 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's return early:

if len(legacyFIleSDFiles) == 0 {
  return
}
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot, we would return from the whole method early

return nil

}, func(err error) {
cancelLegacyFileSD()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just close here fileSDUpdates to make ctxUpdateLegacyFileSDUpdate unnecessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That feels dangerous, we dont own the channel; what if there is a race and filesd wants to send on the channel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we close the channel after Run()? That way we ensure that no one will send anything on it anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only drawback of having context is namespace pollution; I would prefer keeping the context here; its somewhat established pattern with the g.Add() functions and outside of the naming i dont find it too offensive

return removeDuplicateEndpointSpecs(specs)
}, unhealthyTimeout, endpointTimeout, queryConnMetricLabels...)

ctxEndpointUpdate, cancelEndpointUpdate := context.WithCancel(context.Background())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it possible to just create one ctx, cancel := context.WithCancel(context.Background()) and use it in all branches (expect when there's a deadline)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah well; It might, i thought its nicer to have one per group ~ It might be just matter of taste

type EndpointSpec struct {
Strict bool `yaml:"strict"`
Group bool `yaml:"group"`
Address string `yaml:"address"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document the conent of this file. As a person who is not too familiar with this I feel confused about what strict and group is doing so better to have docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essentially same as for flags "--strict-endpoint" and "--endpoint-group" ~ Can I add docs in followup?

@MichaHoffmann MichaHoffmann force-pushed the mhoffmann/make-endpoint-config-dynamically-reloadable branch from 3284e0d to a45ffad Compare November 15, 2024 11:31
* 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]>
@MichaHoffmann MichaHoffmann force-pushed the mhoffmann/make-endpoint-config-dynamically-reloadable branch from a45ffad to c7dd843 Compare November 15, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants