Skip to content

Commit 3159f47

Browse files
committed
pkg/manifests: Expose retention size settings for Platform Prometheus
Introduce a new "retentionSize" field under the prometheusK8s key When neither retention nor retentionSize are defined, a default of 15d for time retention applies. When "retentionSize" is defined and "retention" isn't, only size retention applies. When "retentionSize" isn't defined and "retention" is, only time retention applies When both time and size retention fields are defined, both apply. Signed-off-by: Jayapriya Pai <[email protected]>
1 parent 728bb35 commit 3159f47

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Note: This CHANGELOG is only for the monitoring team to track all monitoring related changes. Please see OpenShift release notes for official changes.
22

3+
## 4.11
4+
5+
- [#1579](https://github.com/openshift/cluster-monitoring-operator/pull/1579) Expose retention size settings for Platform Prometheus
6+
37
## 4.10
48

59
- [#1509](https://github.com/openshift/cluster-monitoring-operator/pull/1509) add NLB usage metrics for network edge

pkg/manifests/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ type RemoteWriteSpec struct {
170170
type PrometheusK8sConfig struct {
171171
LogLevel string `json:"logLevel"`
172172
Retention string `json:"retention"`
173+
RetentionSize string `json:"retentionSize"`
173174
NodeSelector map[string]string `json:"nodeSelector"`
174175
Tolerations []v1.Toleration `json:"tolerations"`
175176
Resources *v1.ResourceRequirements `json:"resources"`

pkg/manifests/manifests.go

+8
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,10 @@ func (f *Factory) PrometheusK8sTrustedCABundle() (*v1.ConfigMap, error) {
14111411
return cm, nil
14121412
}
14131413

1414+
func isUnsetRetentionConfig(retentionSize string) bool {
1415+
return retentionSize == "" || retentionSize == "0"
1416+
}
1417+
14141418
func (f *Factory) PrometheusK8s(grpcTLS *v1.Secret, trustedCABundleCM *v1.ConfigMap) (*monv1.Prometheus, error) {
14151419
p, err := f.NewPrometheus(f.assets.MustNewAssetReader(PrometheusK8s))
14161420
if err != nil {
@@ -1425,6 +1429,10 @@ func (f *Factory) PrometheusK8s(grpcTLS *v1.Secret, trustedCABundleCM *v1.Config
14251429
p.Spec.Retention = f.config.ClusterMonitoringConfiguration.PrometheusK8sConfig.Retention
14261430
}
14271431

1432+
if !isUnsetRetentionConfig(f.config.ClusterMonitoringConfiguration.PrometheusK8sConfig.RetentionSize) {
1433+
p.Spec.RetentionSize = f.config.ClusterMonitoringConfiguration.PrometheusK8sConfig.RetentionSize
1434+
}
1435+
14281436
p.Spec.Image = &f.config.Images.Prometheus
14291437

14301438
if f.consoleConfig != nil {

pkg/manifests/manifests_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,7 @@ func TestPrometheusK8sRemoteWrite(t *testing.T) {
10341034
func TestPrometheusK8sConfiguration(t *testing.T) {
10351035
c, err := NewConfigFromString(`prometheusK8s:
10361036
retention: 25h
1037+
retentionSize: 10Gi
10371038
nodeSelector:
10381039
type: master
10391040
tolerations:
@@ -1083,6 +1084,10 @@ ingress:
10831084
t.Fatal("Retention is not configured correctly")
10841085
}
10851086

1087+
if p.Spec.RetentionSize != "10Gi" {
1088+
t.Fatal("RetentionSize is not configured correctly")
1089+
}
1090+
10861091
if *p.Spec.Image != "docker.io/openshift/origin-prometheus:latest" {
10871092
t.Fatal("Prometheus image is not configured correctly")
10881093
}

test/e2e/config_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func TestClusterMonitorPrometheusK8Config(t *testing.T) {
151151
data := fmt.Sprintf(`prometheusK8s:
152152
logLevel: debug
153153
retention: 10h
154+
retentionSize: 15GB
154155
queryLogFile: /tmp/test.log
155156
tolerations:
156157
- operator: "Exists"
@@ -189,6 +190,7 @@ func TestClusterMonitorPrometheusK8Config(t *testing.T) {
189190
expectMatchingRequests(podName, containerName, mem, cpu),
190191
expectContainerArg("--log.level=debug", containerName),
191192
expectContainerArg("--storage.tsdb.retention.time=10h", containerName),
193+
expectContainerArg("--storage.tsdb.retention.size=15GB", containerName),
192194
},
193195
),
194196
},

0 commit comments

Comments
 (0)