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

frontend: Allow blocking raw http requests #10484

Merged
merged 6 commits into from
Jan 21, 2025

Conversation

julienduchesne
Copy link
Member

@julienduchesne julienduchesne commented Jan 20, 2025

What this PR does

This is a setting that can be set in user overrides like this:

user1:
  blocked_requests:
    - path: /api/v1/series
      method: GET
      query_params:
        foo: bar

Or a combination of these. Each entry is an AND condition

BlockedRequest could be expanded to support headers, body content, etc, but we don't need these feature right now.

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.

@julienduchesne julienduchesne force-pushed the julienduchesne/block-requests branch from 5c96d7a to 06bd242 Compare January 20, 2025 18:08
Copy link
Contributor

github-actions bot commented Jan 20, 2025

💻 Deploy preview deleted.

@julienduchesne julienduchesne force-pushed the julienduchesne/block-requests branch from 06bd242 to 4a66c1d Compare January 20, 2025 18:12
This is a setting that can be set in user overrides like this:
```
user1:
  blocked_requests:
    - path: /api/v1/series
    - method: DELETE
    - query_params
         foo: bar
```

Or a combination of these. Each entry is an AND condition
@julienduchesne julienduchesne force-pushed the julienduchesne/block-requests branch from 4a66c1d to 1777468 Compare January 20, 2025 18:21
@julienduchesne julienduchesne marked this pull request as ready for review January 20, 2025 20:04
@julienduchesne julienduchesne requested review from tacole02 and a team as code owners January 20, 2025 20:04
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.

Very nice work! LGTM. Please remember a CHANGELOG entry before merging. I left a couple of comments, but they're non blocking.

pkg/frontend/querymiddleware/request_blocker.go Outdated Show resolved Hide resolved
@julienduchesne julienduchesne force-pushed the julienduchesne/block-requests branch from 832db8a to ebf7793 Compare January 21, 2025 18:11
@julienduchesne julienduchesne force-pushed the julienduchesne/block-requests branch from df6a871 to 231c530 Compare January 21, 2025 18:31
@julienduchesne julienduchesne force-pushed the julienduchesne/block-requests branch from 231c530 to 548c218 Compare January 21, 2025 18:39
@julienduchesne julienduchesne merged commit 557830d into main Jan 21, 2025
30 checks passed
@julienduchesne julienduchesne deleted the julienduchesne/block-requests branch January 21, 2025 18:56
@grafanabot
Copy link
Contributor

The backport to r325 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-10484-to-r325 origin/r325
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 557830d5a75709de7e299a0a5151a37d8236ea9e
# Push it to GitHub
git push --set-upstream origin backport-10484-to-r325
git switch main
# Remove the local backport branch
git branch -D backport-10484-to-r325

Then, create a pull request where the base branch is r325 and the compare/head branch is backport-10484-to-r325.

@grafanabot
Copy link
Contributor

The backport to r324 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-10484-to-r324 origin/r324
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 557830d5a75709de7e299a0a5151a37d8236ea9e
# Push it to GitHub
git push --set-upstream origin backport-10484-to-r324
git switch main
# Remove the local backport branch
git branch -D backport-10484-to-r324

Then, create a pull request where the base branch is r324 and the compare/head branch is backport-10484-to-r324.

julienduchesne added a commit that referenced this pull request Jan 21, 2025
* frontend: Allow blocking raw http requests
This is a setting that can be set in user overrides like this:
```
user1:
  blocked_requests:
    - path: /api/v1/series
    - method: DELETE
    - query_params
         foo: bar
```

Or a combination of these. Each entry is an AND condition

* Add Roundtripper test

* linting...

* Allow for regexps on the query params + add changelog

* Add test for unmarshalling

* Fix linting

(cherry picked from commit 557830d)
julienduchesne added a commit that referenced this pull request Jan 21, 2025
* frontend: Allow blocking raw http requests
This is a setting that can be set in user overrides like this:
```
user1:
  blocked_requests:
    - path: /api/v1/series
    - method: DELETE
    - query_params
         foo: bar
```

Or a combination of these. Each entry is an AND condition

* Add Roundtripper test

* linting...

* Allow for regexps on the query params + add changelog

* Add test for unmarshalling

* Fix linting

(cherry picked from commit 557830d)
@@ -25,6 +25,7 @@
* [ENHANCEMENT] Query-frontend: include more information about read consistency in trace spans produced when using experimental ingest storage. #10412
* [ENHANCEMENT] Ingester: Hide tokens in ingester ring status page when ingest storage is enabled #10399
* [ENHANCEMENT] Ingester: add `active_series_additional_custom_trackers` configuration, in addition to the already existing `active_series_custom_trackers`. The `active_series_additional_custom_trackers` configuration allows you to configure additional custom trackers that get merged with `active_series_custom_trackers` at runtime. #10428
* [ENHANCEMENT] Query-frontend: Allow blocking raw http requests with the `blocked_requests` configuration. Requests can be blocked based on their path, method
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks changelog has been truncated here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have fixed it here: #10497

julienduchesne added a commit that referenced this pull request Jan 22, 2025
I seemed to have messed it up
julienduchesne added a commit that referenced this pull request Jan 22, 2025
I seemed to have messed it up
julienduchesne added a commit that referenced this pull request Jan 22, 2025
* frontend: Allow blocking raw http requests
This is a setting that can be set in user overrides like this:
```
user1:
  blocked_requests:
    - path: /api/v1/series
    - method: DELETE
    - query_params
         foo: bar
```

Or a combination of these. Each entry is an AND condition

* Add Roundtripper test

* linting...

* Allow for regexps on the query params + add changelog

* Add test for unmarshalling

* Fix linting

(cherry picked from commit 557830d)

Co-authored-by: Julien Duchesne <[email protected]>
julienduchesne added a commit that referenced this pull request Feb 10, 2025
Forgot to add some experimental features here:
- #10460
- #10484
julienduchesne added a commit that referenced this pull request Feb 10, 2025
* Update about-versioning.md

Forgot to add some experimental features here:
- #10460
- #10484

* Update docs/sources/mimir/configure/about-versioning.md

Co-authored-by: Charles Korn <[email protected]>

---------

Co-authored-by: Charles Korn <[email protected]>
ying-jeanne pushed a commit that referenced this pull request Feb 19, 2025
* Update about-versioning.md

Forgot to add some experimental features here:
- #10460
- #10484

* Update docs/sources/mimir/configure/about-versioning.md

Co-authored-by: Charles Korn <[email protected]>

---------

Co-authored-by: Charles Korn <[email protected]>
ying-jeanne pushed a commit that referenced this pull request Feb 20, 2025
* Update about-versioning.md

Forgot to add some experimental features here:
- #10460
- #10484

* Update docs/sources/mimir/configure/about-versioning.md

Co-authored-by: Charles Korn <[email protected]>

---------

Co-authored-by: Charles Korn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants