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

Ensure that duration fields are valid #4282

Closed
simonpasquier opened this issue Sep 24, 2021 · 5 comments
Closed

Ensure that duration fields are valid #4282

simonpasquier opened this issue Sep 24, 2021 · 5 comments

Comments

@simonpasquier
Copy link
Contributor

What is missing?
The operator doesn't prevent invalid values for duration fields like PrometheusSpec.Retention (same is true for EnforcedBodySizeLimit).

Why do we need it?
Avoid breaking Prometheus :)

Environment

  • Prometheus Operator version: N/A

Anything else we need to know?:

@slashpai
Copy link
Contributor

I had thought about that while creating PR but didn't get enough time back then. I will fix that

@simonpasquier
Copy link
Contributor Author

Cool! FWIW the AlertmanagerConfig CRD also has duration fields like groupInterval, groupWait and repeatInterval. The check should happen when the operator selects the resources and rejects the ones that are invalid.

slashpai added a commit to slashpai/prometheus-operator that referenced this issue Sep 27, 2021
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Sep 27, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Sep 27, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
@simonpasquier
Copy link
Contributor Author

The same validation should be run on

  • ScrapeInterval, ScrapeTimeout, EvaluationInterval, MetadataConfig.SendInterval, QuerySpec.Timeout, Thanos.ReadyTimeout, RemoteWriteSpec.RemoteTimeout, RemoteReadSpec.RemoteTimeout and AlertmanagerEndpoints.Timeout for Prometheus resources.
  • Interval and ScrapeTimeout for service/pod monitors and probes.
  • ClusterGossipInterval, ClusterPushpullInterval and ClusterPeerTimeout for Alertmanager.
  • EvaluationInterval for ThanosRuler.

slashpai added a commit to slashpai/prometheus-operator that referenced this issue Sep 27, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Sep 27, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Sep 28, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Sep 28, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Sep 28, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
simonpasquier pushed a commit that referenced this issue Sep 29, 2021
* pkg/prometheus/promcfg*.go: Validate EnforcedBodySizeLimit

Related to #4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>

* :* Run make tidy

* pkg/prometheus/promcfg*.go: Fix error string nits

* pkg/prometheus/promcfg_test.go: Update testcase check

* pkg/prometheus/promcfg*.go: Fix nits
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Oct 6, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Oct 7, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Oct 7, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Oct 18, 2021
Related to prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
simonpasquier pushed a commit that referenced this issue Oct 27, 2021
#4308)

* pkg/prometheus/promcfg.go: Add validation for duration and size fields

Related to #4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>

* pkg/prometheus/promcfg.go: Fix go-linting

* pkg/prometheus/promcfg.go: Update validation func for duration

* pkg/prometheus/promcfg.go: Fix nits

* pkg/prometheus/promcfg_test.go: Add validation tests

* pkg/prometheus/promcfg_test.go: Improve readability
slashpai added a commit to slashpai/prometheus-operator that referenced this issue Oct 29, 2021
Fixes prometheus-operator#4282

Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
@philipgough
Copy link
Contributor

@simonpasquier is this closed by #4308

@slashpai
Copy link
Contributor

slashpai commented Nov 2, 2021

@philipgough We will be able to close once #4352 is merged as well, that was last one part of this fix :)

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

No branches or pull requests

3 participants