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

ingester: Support for disallowing Push API for ingest storage #7503

Merged
merged 8 commits into from
Mar 13, 2024

Conversation

narqo
Copy link
Contributor

@narqo narqo commented Feb 29, 2024

What this PR does

These changes are still in progress by I wanted to get some early feedback, on if the direction is right

The changes add a new flag -ingerster.push-grpc-method-enabled (default "true"). It allows a user to configure the app to block "push" gRPC API in the ingester module, IFF it has ingest-store enabled.

Which issue(s) this PR fixes or relates to

n/a

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@narqo narqo requested a review from a team as a code owner February 29, 2024 07:59
@narqo narqo marked this pull request as draft February 29, 2024 07:59
@narqo narqo force-pushed the ingest-store-dont-push-api branch 2 times, most recently from f8262fb to 03bbc75 Compare February 29, 2024 21:25
@narqo narqo changed the title wip! ingester: Support for disallowing Push API for ingest storage ingester: Support for disallowing Push API for ingest storage Feb 29, 2024
pkg/ingester/ingester.go Outdated Show resolved Hide resolved
@narqo narqo force-pushed the ingest-store-dont-push-api branch from 03bbc75 to 4e482e0 Compare March 1, 2024 17:34
@narqo narqo marked this pull request as ready for review March 1, 2024 17:35
Makefile Show resolved Hide resolved
Copy link
Collaborator

@pracucci pracucci 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 working on this! I left a major comment.

pkg/ingester/ingester.go Outdated Show resolved Hide resolved
pkg/ingester/ingester.go Outdated Show resolved Hide resolved
pkg/ingester/errors.go Outdated Show resolved Hide resolved
pkg/ingester/ingester.go Outdated Show resolved Hide resolved
@narqo narqo requested review from grafanabot and a team as code owners March 11, 2024 14:58
@narqo narqo force-pushed the ingest-store-dont-push-api branch from a61556f to e6498a0 Compare March 11, 2024 15:01
Copy link
Contributor

Building new version of mimir-build-image. After image is built and pushed to Docker Hub, a new commit will automatically be added to this PR with new image version grafana/mimir-build-image:pr7503-ae15c572b6. This can take up to 1 hour.

@narqo narqo force-pushed the ingest-store-dont-push-api branch 5 times, most recently from 6e2599e to 41b691d Compare March 12, 2024 07:43
@@ -281,7 +279,6 @@ type Ingester interface {
ShutdownHandler(http.ResponseWriter, *http.Request)
PrepareShutdownHandler(http.ResponseWriter, *http.Request)
PreparePartitionDownscaleHandler(http.ResponseWriter, *http.Request)
PushWithCleanup(context.Context, *mimirpb.WriteRequest, func()) error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The method PushWithCleanup() shouldn't be required by the api.Ingester interface. Thus, I want to remove it here. IMHO, this makes the code a tiny bit simpler.

@narqo narqo requested a review from pstibrany March 12, 2024 08:24
Copy link
Member

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Thank you, this looks good overall. I have left some small comments.

I would not call this "Push API" because that is widely understood as HTTP push endpoint on distributors. Ingesters only have "Push" gRPC method, so I would suggest to use that name explicitely.

I would also like to see changes that are not necessary for this PR in ingester error mapping and grpc push check to be reverted.

Comment on lines 571 to 576
var errStatus errorWithStatus
if errors.As(err, &errStatus) {
// If the error was already mapped (or wrapped) into appropriate errorWithStatus,
// return it as is.
return errStatus
}
Copy link
Member

Choose a reason for hiding this comment

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

Why is this change required? Newly introduced errPushAPIDisabled is not mapped via this method. (We could map METHOD_NOT_ALLOWED to codes.Unimplemented if needed).

Same comment in mapPushErrorToErrorWithHTTPOrGRPCStatus. I would suggest to remove unnecessary changes from the PR.

@@ -206,6 +206,8 @@ type Config struct {
UpdateIngesterOwnedSeries bool `yaml:"track_ingester_owned_series" category:"experimental"`
OwnedSeriesUpdateInterval time.Duration `yaml:"owned_series_update_interval" category:"experimental"`

EnablePushAPI bool `yaml:"enable_push_api" category:"experimental" doc:"hidden"`
Copy link
Member

Choose a reason for hiding this comment

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

We try to use "Enabled" suffix, in this case PushAPIEnabled or perhaps PushMethodEnabled or even PushGrpcMethodEnabled to indicate this is very low-level thing that nobody should touch. Same name should be used for YAML field and CLI flag.

pkg/ingester/ingester.go Outdated Show resolved Hide resolved
pkg/ingester/ingester.go Outdated Show resolved Hide resolved
pkg/ingester/ingester.go Outdated Show resolved Hide resolved
pkg/mimir/grpc_push_check.go Outdated Show resolved Hide resolved
pkg/mimir/mimir.go Outdated Show resolved Hide resolved
narqo and others added 2 commits March 12, 2024 21:18
Signed-off-by: Vladimir Varankin <[email protected]>
Co-authored-by: Marco Pracucci <[email protected]>
narqo added 5 commits March 12, 2024 21:18
Signed-off-by: Vladimir Varankin <[email protected]>
Signed-off-by: Vladimir Varankin <[email protected]>
Signed-off-by: Vladimir Varankin <[email protected]>
Signed-off-by: Vladimir Varankin <[email protected]>
@narqo narqo force-pushed the ingest-store-dont-push-api branch from 41b691d to f4e24c5 Compare March 12, 2024 20:37
Co-authored-by: Peter Štibraný <[email protected]>
Signed-off-by: Vladimir Varankin <[email protected]>
@narqo narqo force-pushed the ingest-store-dont-push-api branch from bce5c21 to 52bcfd7 Compare March 12, 2024 21:01
@narqo
Copy link
Contributor Author

narqo commented Mar 12, 2024

🆙

I think, I've addressed all the comments. PHAL

@narqo narqo requested a review from pstibrany March 12, 2024 21:44
Copy link
Member

@pstibrany pstibrany left a 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 this PR and addressing my feedback.

@pstibrany pstibrany merged commit 08a2bd2 into main Mar 13, 2024
29 checks passed
@pstibrany pstibrany deleted the ingest-store-dont-push-api branch March 13, 2024 09:33
@@ -46,6 +46,7 @@ enum ErrorCause {
TSDB_UNAVAILABLE = 8;
TOO_BUSY = 9;
CIRCUIT_BREAKER_OPEN = 10;
METHOD_NOT_ALLOWED = 11;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We've added a new error cause, but then this has to be explicitly mapped to HTTP status codes. As a reference, look all places where TSDB_UNAVAILABLE is used and do something similar for METHOD_NOT_ALLOWED too. I would return 405 for METHOD_NOT_ALLOWED.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually I see you proposed it in #7618 but got rejected with a good feedback. Let me follow up offline about it.

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.

3 participants