-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
base: main
Are you sure you want to change the base?
query, rule: make endpoint discovery dynamically reloadable #7890
Conversation
7b8c118
to
249620c
Compare
There was a problem hiding this 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!
e57969b
to
963126d
Compare
d5cfc49
to
e9f1ff4
Compare
12a9008
to
529954c
Compare
bb7e84d
to
d3efbc2
Compare
cb05e05
to
3284e0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
cmd/thanos/endpointset.go
Outdated
return "" | ||
} | ||
|
||
type EndpointSpec struct { |
There was a problem hiding this comment.
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.
{ | ||
// Setup Legacy File SD | ||
var fileSD *file.Discovery | ||
if len(legacyFileSDFiles) > 0 { |
There was a problem hiding this comment.
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
}
...
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
3284e0d
to
a45ffad
Compare
* 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]>
c7dd843
a45ffad
to
c7dd843
Compare
Changes
--store.sd-file
and--store.sd-interval
flags--endpoint.sd-config
,--endpoint-sd-config-reload-interval
to configure a dynamic SD fileThe 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.