@@ -1200,29 +1200,33 @@ func (r *Reconciler) reconcileInstance(
12001200 spec , instanceCertificates , instanceConfigMap , & instance .Spec .Template )
12011201 }
12021202
1203- if err == nil &&
1204- (feature .Enabled (ctx , feature .OpenTelemetryLogs ) && ! feature .Enabled (ctx , feature .OpenTelemetryMetrics )) {
1203+ if err == nil {
12051204
1206- // TODO: Setting the includeLogrotate argument to false for now. This
1207- // should be changed when we implement log rotation for postgres
1208- // TODO: add dir
1209- collector .AddToPod (ctx , cluster .Spec .Instrumentation , cluster .Spec .ImagePullPolicy , instanceConfigMap , & instance .Spec .Template .Spec ,
1210- []corev1.VolumeMount {postgres .DataVolumeMount ()}, "" , "" , false )
1211- }
1205+ // If OTel metrics are enabled, we'll need the MonitoringUserSecret
1206+ var password = ""
1207+ if feature .Enabled (ctx , feature .OpenTelemetryMetrics ) {
1208+ monitoringUserSecret := & corev1.Secret {ObjectMeta : naming .MonitoringUserSecret (cluster )}
1209+ err = errors .WithStack (
1210+ r .Client .Get (ctx , client .ObjectKeyFromObject (monitoringUserSecret ), monitoringUserSecret ))
1211+
1212+ if err == nil {
1213+ password = string (monitoringUserSecret .Data ["password" ])
1214+ }
1215+ }
12121216
1213- if err == nil &&
1214- feature .Enabled (ctx , feature .OpenTelemetryMetrics ) {
1217+ // FIXME: is this bool really asking for a backup vol?
1218+ var logrotate = false
1219+ if backupsSpecFound {
1220+ logrotate = true
1221+ }
12151222
1216- monitoringUserSecret := & corev1.Secret {ObjectMeta : naming .MonitoringUserSecret (cluster )}
1217- err = errors .WithStack (
1218- r .Client .Get (ctx , client .ObjectKeyFromObject (monitoringUserSecret ), monitoringUserSecret ))
1223+ if feature .Enabled (ctx , feature .OpenTelemetryLogs ) || feature .Enabled (ctx , feature .OpenTelemetryMetrics ) {
12191224
1220- if err == nil {
1221- // TODO: Setting the includeLogrotate argument to false for now. This
1222- // should be changed when we implement log rotation for postgres
1223- // TODO: add dir
1224- collector .AddToPod (ctx , cluster .Spec .Instrumentation , cluster .Spec .ImagePullPolicy , instanceConfigMap , & instance .Spec .Template .Spec ,
1225- []corev1.VolumeMount {postgres .DataVolumeMount ()}, string (monitoringUserSecret .Data ["password" ]), "" , false )
1225+ // TODO: Add pgBackRestDir if we want that.
1226+ collector .AddToPod (ctx , cluster .Spec .Instrumentation , cluster .Spec .ImagePullPolicy ,
1227+ instanceConfigMap , & instance .Spec .Template .Spec ,
1228+ []corev1.VolumeMount {postgres .DataVolumeMount ()},
1229+ password , naming .PGBackRestPGDataLogPath , logrotate )
12261230 }
12271231 }
12281232
@@ -1435,7 +1439,7 @@ func (r *Reconciler) reconcileInstanceConfigMap(
14351439 if err == nil && feature .Enabled (ctx , feature .OpenTelemetryLogs ) &&
14361440 backupSpecFound && cluster .Spec .Instrumentation != nil {
14371441 err = collector .AddLogrotateConfig (ctx , cluster .Spec .Instrumentation ,
1438- instanceConfigMap , naming .PGBackRestPGDataLogPath , "" )
1442+ instanceConfigMap , naming .PGBackRestPGDataLogPath + "/*.log" , "" )
14391443 }
14401444 }
14411445 if err == nil {
0 commit comments