mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 11:48:53 +00:00
support storage.tsdb.retention.time in prometheus >=2.7.0
This commit is contained in:
parent
1fe861d287
commit
af2308f7a9
2 changed files with 8 additions and 2 deletions
pkg/prometheus
|
@ -336,10 +336,14 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
|
|||
)
|
||||
}
|
||||
case 2:
|
||||
retentionTimeFlag := "-storage.tsdb.retention="
|
||||
if version.Minor >= 7 {
|
||||
retentionTimeFlag = "-storage.tsdb.retention.time="
|
||||
}
|
||||
promArgs = append(promArgs,
|
||||
fmt.Sprintf("-config.file=%s", path.Join(confOutDir, configEnvsubstFilename)),
|
||||
fmt.Sprintf("-storage.tsdb.path=%s", storageDir),
|
||||
"-storage.tsdb.retention="+p.Spec.Retention,
|
||||
retentionTimeFlag+p.Spec.Retention,
|
||||
"-web.enable-lifecycle",
|
||||
"-storage.tsdb.no-lockfile",
|
||||
)
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
monitoringv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
|
||||
"github.com/stretchr/testify/require"
|
||||
appsv1 "k8s.io/api/apps/v1beta2"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
|
@ -619,6 +619,8 @@ func TestRetention(t *testing.T) {
|
|||
{"v1.8.2", "1d", "-storage.local.retention=1d"},
|
||||
{"v2.5.0", "", "--storage.tsdb.retention=24h"},
|
||||
{"v2.5.0", "1d", "--storage.tsdb.retention=1d"},
|
||||
{"v2.7.0", "", "--storage.tsdb.retention.time=24h"},
|
||||
{"v2.7.0", "1d", "--storage.tsdb.retention.time=1d"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue