Skip to content

Commit 5ee89d1

Browse files
committed
Rotate pgbackrest Issues: [PGO-2171]
1 parent e884806 commit 5ee89d1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

internal/pgbackrest/config.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
"github.com/crunchydata/postgres-operator/internal/collector"
1919
"github.com/crunchydata/postgres-operator/internal/config"
20+
"github.com/crunchydata/postgres-operator/internal/feature"
2021
"github.com/crunchydata/postgres-operator/internal/initialize"
2122
"github.com/crunchydata/postgres-operator/internal/naming"
2223
"github.com/crunchydata/postgres-operator/internal/postgres"
@@ -134,6 +135,21 @@ func CreatePGBackRestConfigMapIntent(ctx context.Context, postgresCluster *v1bet
134135
postgresCluster.Spec.Instrumentation,
135136
postgresCluster.Spec.Backups.PGBackRest.Repos,
136137
), cm)
138+
139+
// If OTel logging is enabled, add logrotate config for the RepoHost
140+
if err == nil &&
141+
postgresCluster.Spec.Instrumentation != nil &&
142+
feature.Enabled(ctx, feature.OpenTelemetryLogs) {
143+
var pgBackRestLogPath string
144+
for _, repo := range postgresCluster.Spec.Backups.PGBackRest.Repos {
145+
if repo.Volume != nil {
146+
pgBackRestLogPath = fmt.Sprintf(naming.PGBackRestRepoLogPath, repo.Name)
147+
break
148+
}
149+
}
150+
err = collector.AddLogrotateConfig(ctx, postgresCluster.Spec.Instrumentation, cm,
151+
pgBackRestLogPath+"/*.log", "")
152+
}
137153
}
138154

139155
cm.Data[ConfigHashKey] = configHash

0 commit comments

Comments
 (0)