feat: migrate retention options to config file#8547
Merged
simonpasquier merged 1 commit intoJun 10, 2026
Conversation
vprashar2929
force-pushed
the
feat-retention-cfg
branch
from
April 29, 2026 17:58
6e8f550 to
412e544
Compare
| @@ -403,12 +403,12 @@ func buildServerArgs(cg *prompkg.ConfigGenerator, p *monitoringv1.Prometheus) [] | |||
| } | |||
|
|
|||
| if retentionTimeFlagValue != "" { | |||
Contributor
There was a problem hiding this comment.
cg.WithMaximumVersion("3.11.0") would print a warning which we don't want.
Suggested change
| if retentionTimeFlagValue != "" { | |
| // Starting with Prometheus v3.11.0, retention settings are populated in the configuration file. | |
| if retentionTimeFlagValue != "" && cg.Version().LT(semver.MustPass("3.11.0")) { |
| promArgs = cg.WithMaximumVersion("3.11.0").AppendCommandlineArgument(promArgs, monitoringv1.Argument{Name: retentionTimeFlagName, Value: retentionTimeFlagValue}) | ||
| } | ||
|
|
||
| if p.Spec.RetentionSize != "" { |
| if cg.WithMinimumVersion("3.11.0").IsCompatible() { | ||
| var retentionSlice yaml.MapSlice | ||
| retentionTime := string(retention) | ||
| if retentionTime == "" && retentionSize == "" { |
Contributor
There was a problem hiding this comment.
we need a way to avoid duplication for defaults between here and pkg/prometheus/server/statefulset.go
| selector metav1.LabelSelector, | ||
| selectorMechanism *monitoringv1.SelectorMechanism, | ||
| roles []string) k8sSDConfigOptions { | ||
| roles []string, |
Contributor
There was a problem hiding this comment.
please avoid changes unrelated to the PR
| GoGC: ptr.To(int32(25)), | ||
| }, | ||
| Golden: "RuntimeConfig_GoGC_Not_Set.golden", | ||
| Golden: "RuntimeConfig_GoGC_Not_Set_v2.52.0.golden", |
vprashar2929
force-pushed
the
feat-retention-cfg
branch
2 times, most recently
from
May 13, 2026 09:22
8616967 to
cfe0be9
Compare
vprashar2929
force-pushed
the
feat-retention-cfg
branch
from
May 21, 2026 04:00
cfe0be9 to
cb3a296
Compare
Contributor
Author
|
@simonpasquier Can we have a re-review of this? |
|
|
||
| // TestRetentionAndRetentionSizeNoCLIFlags asserts that retention CLI flags | ||
| // are not emitted for Prometheus >= v3.11.0. | ||
| func TestRetentionAndRetentionSizeNoCLIFlags(t *testing.T) { |
Contributor
There was a problem hiding this comment.
can we make this subtests of TestRetentionAndRetentionSize()?
This commit migrates retention options from CLI flags to config file as per Prometheus v3 release which deprecates the `storage.tsdb.retention` flags (prometheus/prometheus#18200) With this change the operator writes the retention options to the config file. For older Prometheus versions the CLI flags continue to be used Addresses prometheus-operator#8522 Written with the help of Claude Code Signed-off-by: vprashar2929 <[email protected]>
vprashar2929
force-pushed
the
feat-retention-cfg
branch
from
May 30, 2026 15:04
cb3a296 to
966824c
Compare
Contributor
Author
|
@simonpasquier Implemented the review comments and updated the PR. Could you please re review it when convenient? |
5 tasks
dongjiang1989
added a commit
to kubeservice-stack/prometheus-operator
that referenced
this pull request
Jun 22, 2026
Main merged PR prometheus-operator#8547 which added storage.tsdb.retention.time to the generated Prometheus config. Update the OutscaleSD golden test files to include this new section.
1 task
sdwilsh
pushed a commit
to sdwilsh/ansible-playbooks
that referenced
this pull request
Jul 22, 2026
…r to v0.92.1 (#1765) ##### [\`v0.92.1\`](https://github.com/prometheus-operator/prometheus-operator/releases/tag/v0.92.1) - \[BUGFIX] Fix "namespace not found" errors when the operator watches monitoring and workload resources in different resources. [#8658](prometheus-operator/prometheus-operator#8658) --- ##### [\`v0.92.0\`](https://github.com/prometheus-operator/prometheus-operator/releases/tag/v0.92.0) > \[!NOTE] > The `PrometheusTopologySharding` and `PrometheusShardRetentionPolicy` feature gates have been promoted to **Beta** in this release and are now enabled by default. See the [sharding documentation](https://prometheus-operator.dev/docs/platform/sharding/) for details. - \[CHANGE] Add URL validation for the `tokenUrl` field in OAuth2 configuration across all CRDs. [#8579](prometheus-operator/prometheus-operator#8579) - \[CHANGE] Add URL validation for the `url` field in `RemoteReadSpec` in `Prometheus` CRD. [#8596](prometheus-operator/prometheus-operator#8596) - \[FEATURE] Migrate retention options from CLI flags to the config file for `Prometheus` CRD (Prometheus >= v3 uses the config file; older versions continue to use CLI flags). [#8547](prometheus-operator/prometheus-operator#8547) - \[FEATURE] Add `staleSeriesCompactionThreshold` field to `TSDBSpec` in `Prometheus` and `PrometheusAgent` CRDs. [#8563](prometheus-operator/prometheus-operator#8563) - \[FEATURE] Add `labelNameUnderscoreSanitization` and `labelNamePreserveMultipleUnderscores` fields to `OTLPConfig` in `Prometheus` and `PrometheusAgent` CRDs. [#8562](prometheus-operator/prometheus-operator#8562) - \[FEATURE] Add `payload` field to Webhook receiver in `AlertmanagerConfig` CRD. [#8507](prometheus-operator/prometheus-operator#8507) - \[ENHANCEMENT] Use pod topology labels for zone sharding on Kubernetes >= 1.35 when the `PrometheusTopologySharding` feature gate is enabled (removes the need for `attachMetadata.node=true`). [#8564](prometheus-operator/prometheus-operator#8564) - \[ENHANCEMENT] Add validation for the Slack `update_message` field in Alertmanager configuration Secret. [#8556](prometheus-operator/prometheus-operator#8556) - \[BUGFIX] Validate target labels in `Probe` static configuration to prevent invalid Prometheus scrape configs. [#7901](prometheus-operator/prometheus-operator#7901) - \[BUGFIX] Fix goroutine leak and data race in `pollBasedListerWatcher`. [#8593](prometheus-operator/prometheus-operator#8593) - \[BUGFIX] Validate `ProxyConfig` in OAuth2 configuration. [#8610](prometheus-operator/prometheus-operator#8610) - \[BUGFIX] Fix SMTP smarthost format error handling in Alertmanager configuration. [#8586](prometheus-operator/prometheus-operator#8586) - \[BUGFIX] Fix missing `return` in admission webhook after marshal failure. [#8582](prometheus-operator/prometheus-operator#8582) - \[BUGFIX] Fix `FindOwner` to return `nil` on `meta.Accessor` error. [#8585](prometheus-operator/prometheus-operator#8585) - \[BUGFIX] Fix dropped gzip `Close` errors in `GzipConfig` and `GunzipConfig`. [#8573](prometheus-operator/prometheus-operator#8573) - \[BUGFIX] Fix panic on malformed key=value flag input (e.g. `--labels "key"`). [#8560](prometheus-operator/prometheus-operator#8560) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This commit migrates retention options from CLI flags to config file as per Prometheus v3 release which deprecates the
storage.tsdb.retentionflags (prometheus/prometheus#18200) With this change the operator writes the retention options to the config file. For older Prometheus versions the CLI flags continue to be usedAddresses #8522
Written with the help of Claude Code
Closes: #8522
If you're contributing for the first-time, check our contribution guidelines.
Type of change
What type of changes does your code introduce to the Prometheus operator? Put an
xin 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
Please check the Prometheus-Operator testing guidelines for recommendations about automated tests.
Changelog entry
Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.