-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat: enable config reload via signal #5690
feat: enable config reload via signal #5690
Conversation
52b4244
to
084ffeb
Compare
d831438
to
4c95722
Compare
4c95722
to
69df758
Compare
69df758
to
54067a2
Compare
64f0dfa
to
e855890
Compare
e855890
to
a395f08
Compare
a395f08
to
51bd191
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.
Looking good 👍 , let's see how the PR upstream evolves
webRoutePrefix := "/" | ||
if cpf.RoutePrefix != "" { | ||
webRoutePrefix = cpf.RoutePrefix | ||
} | ||
|
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.
Nice clean up by moving this to CommonPrometheusFields!
r, err := http.NewRequestWithContext(ctx, "GET", prt.baseURL.JoinPath("/api/v1/status/runtimeinfo").String(), nil) | ||
if err != nil { | ||
return false, time.Time{}, err | ||
} |
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.
Nice idea to get reload status even when using signal 👍
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.
Yes otherwise it would be like shooting in the dark. This was the blocking point for me to move this forward.
var runtimeInfo = struct { | ||
Status string `json:"status"` | ||
Data struct { | ||
ReloadConfigSuccess bool `json:"reloadConfigSuccess"` | ||
LastConfigTime time.Time `json:"lastConfigTime"` | ||
} `json:"data"` | ||
}{} |
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.
Do we know if prometheus has a history of changing the API response here? I wonder if we'll need to have a test to make sure we don't break when upgrading prometheus versions
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.
https://prometheus.io/docs/prometheus/latest/stability/
The v1 API should be stable. The API returns these fields since at least late 2019 so I wouldn't check the exact Prometheus version (if it ever happens, the only advice would be to upgrade).
} | ||
defer resp.Body.Close() | ||
|
||
if resp.StatusCode/100 != 2 { |
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.
TIL
So cleaver.
Better than check if >= 200 <= 299
select { | ||
case <-ctx.Done(): | ||
return fmt.Errorf("%w: last configuration status: success=%v, success_timetamp=%v", ctx.Err(), success, last) | ||
case <-t.C: |
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.
Dont you need to reset the timer?
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.
No it will automatically resend to the channel at the next tick.
LGTM |
b0e1b2e
to
ac8a73a
Compare
ac8a73a
to
9a5c0c1
Compare
5f0f0d6
to
81d4734
Compare
The Thanos PR has merged and this is now ready for a final review. |
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.
Nice job!
81d4734
to
f805094
Compare
This commit adds the option to reload Prometheus configuration using signal instead of the /-/reload endpoint. Signed-off-by: Simon Pasquier <spasquie@redhat.com>
f805094
to
a143c8d
Compare
Description
Requires thanos-io/thanos#6453
Closes #3381
Type of change
What type of changes does your code introduce to the Prometheus operator? Put an
x
in the box that apply.CHANGE
(fix or feature that would cause existing functionality to not work as expected)FEATURE
(non-breaking change which adds functionality)BUGFIX
(non-breaking change which fixes an issue)ENHANCEMENT
(non-breaking change which improves existing functionality)NONE
(if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)Changelog entry
Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.