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

Added init container which applies config file once by setting --watch-interval equals to 0 #3955

Merged
merged 43 commits into from Jun 10, 2021

Conversation

zsuzhengdu
Copy link
Contributor

@zsuzhengdu zsuzhengdu commented Apr 7, 2021

Fix #3061

Depends on a new Thanos release that includes thanos-io/thanos#3994

@zsuzhengdu zsuzhengdu requested a review from a team as a code owner April 7, 2021 01:25
@coderanger
Copy link
Contributor

At the point that the init container runs, the primary containers have not started. So prometheus won't actually be up yet for this to trigger a reload on.

@zsuzhengdu zsuzhengdu changed the title F/init container Added init container which apples config file once by setting --watch-interval equals to 0 Apr 7, 2021
@zsuzhengdu
Copy link
Contributor Author

Good call. Updated to skip making reload request to :locahost:9090/-/reload when --watch-interval==0; please see thanos-io/thanos#4032
Also skip starting metrics server in cmd/prometheus-config-reloader/main.go when --watch-interval==0.

@zsuzhengdu
Copy link
Contributor Author

@coderanger @brancz

Would you please help to review the changes? Thanks!

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

can you update the description of the --watch-interval flag to explain that when 0, the program runs only once and exits.

pkg/prometheus/statefulset.go Outdated Show resolved Hide resolved
pkg/operator/statefulset.go Outdated Show resolved Hide resolved
Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

A few suggestions but great work!

pkg/operator/statefulset.go Outdated Show resolved Hide resolved
pkg/operator/statefulset.go Outdated Show resolved Hide resolved
pkg/operator/statefulset.go Outdated Show resolved Hide resolved
pkg/operator/statefulset.go Outdated Show resolved Hide resolved
pkg/operator/statefulset.go Outdated Show resolved Hide resolved
pkg/operator/statefulset.go Outdated Show resolved Hide resolved
pkg/operator/statefulset.go Outdated Show resolved Hide resolved
pkg/operator/statefulset.go Outdated Show resolved Hide resolved
pkg/operator/statefulset.go Outdated Show resolved Hide resolved
pkg/operator/statefulset.go Outdated Show resolved Hide resolved
@simonpasquier simonpasquier changed the title Added init container which apples config file once by setting --watch-interval equals to 0 Added init container which applies config file once by setting --watch-interval equals to 0 May 27, 2021
Copy link
Contributor

@fpetkovski fpetkovski left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, the PR looks quite good so far.

As one last improvement, could you also add tests to the prometheus and alertmanager test suites to make sure the init container is added to the respective statefulsets?

pkg/operator/statefulset.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
test/framework/prometheus.go Outdated Show resolved Hide resolved
@zsuzhengdu
Copy link
Contributor Author

@fpetkovski Are these changes good enough and would you please give another review?

@fpetkovski
Copy link
Contributor

Hey @zsuzhengdu, this looks good to me now. I also tested the changes locally and they look solid. Thanks for the contribution!

@zsuzhengdu
Copy link
Contributor Author

Thank you for the review and local try out, @fpetkovski!

Copy link
Member

@paulfantom paulfantom left a comment

Choose a reason for hiding this comment

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

lgtm from my side, leaving final say to @simonpasquier

@simonpasquier
Copy link
Contributor

Thanks a lot for your perseverance and sorry about the delayed review from my side! Also thanks to @fpetkovski for taking over :)

I have 2 last comments:

  • I don't think we need to add the init container to the Alertmanager statefulset because the config reloader doesn't substitute environment variables in the Alertmanager config file.
  • It would be good to mention the new init-config-reloader container in the API documentation. In practice, this comment should be expanded to match what's already documented for regular containers generated by the operator.

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

👍 thanks a lot! 🎉

@simonpasquier simonpasquier merged commit da8b34a into prometheus-operator:master Jun 10, 2021
@simonpasquier
Copy link
Contributor

@zsuzhengdu it took longer than expected but finally it's merged! Thanks a lot for your patience 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prometheus pod cannot find prometheus.env.yaml on start
5 participants