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

feat: added validation for prometheusRule size (#6478) #6606

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

yp969803
Copy link
Contributor

Description

fixes: #6478
Reject PrometheusRule objects that generate > 1MB configmap

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.)

Verification

added unit test

Changelog entry


@yp969803 yp969803 requested a review from a team as a code owner May 18, 2024 21:56
@yp969803
Copy link
Contributor Author

@simonpasquier can u review the pr

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.

In fact the original issue is about the internal hardcoded limit of the operator which is 512KiB (1MiB/2):

// The maximum `Data` size of a ConfigMap seems to differ between
// environments. This is probably due to different meta data sizes which count
// into the overall maximum size of a ConfigMap. Thereby lets leave a
// large buffer.
var maxConfigMapDataSize = int(float64(v1.MaxSecretSize) * 0.5)

IMHO the first things to do would be

  • better advertise this limit in the API documentation.
  • have a descriptive error message stating the operator limit and the actual value.

I'd also rather see the check in ValidateRule() since it would help users that don't run the admission webhook.

Eventually we may want to make the 512MB limit configurable and/or increase the default limit. Unfortunately #1591 has little details on why 50% of 1MiB was picked up.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this specific case, I'd avoid storing a large file in the Git repository.

@yp969803
Copy link
Contributor Author

@simonpasquier done the above changes

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

Successfully merging this pull request may close these issues.

Reject PrometheusRule objects that generate > 512KiB configmap
2 participants