-
Notifications
You must be signed in to change notification settings - Fork 569
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
Ingester: allow only POST method on /ingester/shutdown
#7707
Ingester: allow only POST method on /ingester/shutdown
#7707
Conversation
Signed-off-by: Kevin Mingtarja <[email protected]>
20bcfa5
to
26ea0af
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.
Thank you for your contribution!
There are a few tools and docs that will need updating to use POST:
https://github.com/grafana/mimir/blob/main/tools/migrate-ingester-statefulsets.sh#L46
https://github.com/grafana/mimir/blob/main/docs/sources/mimir/manage/run-production-environment/scaling-out.md?plain=1 (where it says invoke it should probably say POST).
It would also be good to see a test to make sure GET is disabled unless the config flag is set.
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.
Thank you for working on this!
Signed-off-by: Kevin Mingtarja <[email protected]>
Hi @jhesketh, @pstibrany, thank you as well for the comments! I have updated the docs/tools that I missed, and addressed the comments in a follow-up commit. Please let me know if this is okay. |
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.
Thank you very much for working on this! I've left few minor comments.
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.
docs changes LGTM
Signed-off-by: Kevin Mingtarja <[email protected]>
Signed-off-by: Kevin Mingtarja <[email protected]>
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.
Thank you very much!
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.
Thank you for the improvements!
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 will fix the unit test
Fix missing [deprecated] tag
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.
.
pkg/api/api.go
Outdated
@@ -71,6 +74,7 @@ type Config struct { | |||
func (cfg *Config) RegisterFlags(f *flag.FlagSet) { | |||
f.BoolVar(&cfg.SkipLabelNameValidationHeader, "api.skip-label-name-validation-header-enabled", false, "Allows to skip label name validation via X-Mimir-SkipLabelNameValidation header on the http write path. Use with caution as it breaks PromQL. Allowing this for external clients allows any client to send invalid label names. After enabling it, requests with a specific HTTP header set to true will not have label names validated.") | |||
f.BoolVar(&cfg.EnableOtelMetadataStorage, "distributor.enable-otlp-metadata-storage", true, "If true, store metadata when ingesting metrics via OTLP. This makes metric descriptions and types available for metrics ingested via OTLP.") | |||
f.BoolVar(&cfg.GETRequestForIngesterShutdownEnabled, "get-request-for-ingester-shutdown-enabled", false, "Enable GET requests to the /ingester/shutdown endpoint to trigger an ingester shutdown. This is a potentially dangerous operation and should only be enabled consciously.") |
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.
On re-review, this should probably be:
f.BoolVar(&cfg.GETRequestForIngesterShutdownEnabled, "get-request-for-ingester-shutdown-enabled", false, "Enable GET requests to the /ingester/shutdown endpoint to trigger an ingester shutdown. This is a potentially dangerous operation and should only be enabled consciously.") | |
f.BoolVar(&cfg.GETRequestForIngesterShutdownEnabled, "ingester.get-request-for-shutdown-enabled", false, "Enable GET requests to the /ingester/shutdown endpoint to trigger an ingester shutdown. This is a potentially dangerous operation and should only be enabled consciously.") |
And the corresponding changes to the 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.
Got it, should the yaml
field name stay the same though?
Right now it's get_request_for_ingester_shutdown_enabled
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.
Actually, initially I did as you suggested, but then Peter suggested to make it consistent so I changed it: #7707 (comment)
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.
Oh right, I missed that conversation sorry. Looking at the distributor.enable-otlp-metadata-storage
flag (just above) it exists as both distributor.enable-otlp-metadata-storage
as the flag and enable_otel_metadata_translation
as the yaml. @pstibrany Just want to double check your opinion here please.
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'm sorry for confusion here. The problem here comes from the fact that config option is defined in api
config block in YAML, but we're trying to use ingester.
prefix for CLI flag. At the same time, we're triyng to make CLI flag and yaml field name consistent (this was goal of my previous comment, without realizing it's causing more confusion).
I think we should settle on:
-api.get-request-for-ingester-shutdown-enabled
for CLI flagget_request_for_ingester_shutdown_enabled
as YAML field name (it's already underapi
section)
WDYT?
If we want to use -ingester.
prefix for CLI flag, then we should put this into ingester config struct.
Unfortunately I think enable_otel_metadata_translation
was a mistake, as it doesn't follow our practices. ("enabled" suffix, consistent CLI and YAML names)
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.
@jhesketh thanks for catching this. My suggestion was not to remove -ingester.
prefix (only to add ingester
in the middle of the name), and I missed that this is what happened. 🤦
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 sorry for the misunderstanding too. So should we keep going with the -ingester.
prefix or -api.
instead? As you mentioned, I think the latter makes more sense as it's already under the api
section in the yaml.
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.
Hi Kevin, with Josh we agreed to go with -api.get-request-for-ingester-shutdown-enabled
CLI flag and get_request_for_ingester_shutdown_enabled
YAML field name. Thank you very much for your patience with us!
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.
Hi Peter, no worries! Let me quickly do that
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.
Done!
Signed-off-by: Kevin Mingtarja <[email protected]>
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.
LGTM! Thank you for persisting with our miss on the naming :-). Will leave it for Peter to do final look+merge.
Hang on did i miss something, somehow one of the test fails with this, even though
|
Signed-off-by: Peter Štibraný <[email protected]>
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.
Thank you very much for your contribution and patience with us!
I've regenerated help (using |
No worries, thanks as well for the review Peter and Joshua! |
What this PR does
Previously, we allow both POST and GET
/ingester/shutdown
, which makes it too easy to accidentally trigger, i.e. internal scanners that traverse links can trigger shutdown of ingester just by visiting the link.This PR makes that less likely to happen by only allowing POST requests on
/ingester/shutdown
. At the same time, if users still want to opt in to the existing behavior, we allow that by adding a new-ingester.get-request-for-shutdown-enabled
flag (defaults to false). But this flag is also temporary and will be removed after two Mimir releases (2.15).Which issue(s) this PR fixes or relates to
Fixes #7623
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.