Skip to content

Conversation

@benjaminjb
Copy link
Contributor

Checklist:

  • Have you added an explanation of what your changes do and why you'd like them to be included?
  • Have you updated or added documentation for the change, as applicable?
  • Have you tested your changes on all related environments with successful results, as applicable?
    • Have you added automated tests?

Type of Changes:

  • New feature
  • Bug fix
  • Documentation
  • Testing enhancement
  • Other

What is the current behavior (link to any open issues here)?

PgBackRest logs don't rotate

What is the new behavior (if this is a feature change)?

  • Breaking change (fix or feature that would cause existing functionality to change)

PgBackRest logs -- in both postgres and repohost -- rotate.
This also includes a change where the collector container can create the /receiver dir that it requires. (This will need to be updated if/when we have multiple logrotates in a container.)

Other Information:
Issues: [PGO-2171]

var mkdirScript string
if dir != "" {
mkdirScript = `
` + shell.MakeDirectories(0o775, dir, dir+"/receiver")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a few TODOs about creating the receiver directory through the pod, not through the collector, so I did this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I believe we need to be able to pass in multiple directories (e.g. the collector container in the postgres instance pod needs to create directories for patroni, postgres, and pgbackrest)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was wondering if the logrotate struct might help with that... I was thinking to work some of that out in the pgadmin PR


// Logging
EnablePostgresLogging(ctx, inCluster, config, outParameters)
EnablePatroniLogging(ctx, inCluster, config)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just re-ordering and grouping


if err == nil &&
(feature.Enabled(ctx, feature.OpenTelemetryLogs) && !feature.Enabled(ctx, feature.OpenTelemetryMetrics)) {
if err == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dsessler7 We had talked about reworking this logic a bit along these lines, here's my pass at it.

Note: this work is done with the understanding that we're not rotating postgres or patroni logs through logrotate right now.

monitoringUserSecret := &corev1.Secret{ObjectMeta: naming.MonitoringUserSecret(cluster)}
err = errors.WithStack(
r.Client.Get(ctx, client.ObjectKeyFromObject(monitoringUserSecret), monitoringUserSecret))
// FIXME: is this bool really asking for a backup vol?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, gotta figure this out tomorrow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked into this -- it's not actually looking for a vol, just that backups are in the spec, so I'll use pgbackrest.RepoHostVolumeDefined

}
template.Spec.InitContainers = append(template.Spec.InitContainers, container)

return pgBackRestLogPath
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got tired of looping through repos to get this name, so I had this func return it since I needed this name right after this func was called. I could've done that work outside this func or create a util, maybe I'll consider that tomorrow.

@cbandy cbandy self-requested a review February 27, 2025 16:54
@benjaminjb benjaminjb requested a review from dsessler7 February 27, 2025 18:25
includeLogrotate bool,
) {
if !(feature.Enabled(ctx, feature.OpenTelemetryLogs) || feature.Enabled(ctx, feature.OpenTelemetryMetrics)) {
if spec == nil ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we want to require the instrumentation spec, then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, just like you said at another point: this is all feature gated, but turning on a feature gate doesn't necessarily mean you want X feature for all your clusters.

@benjaminjb benjaminjb force-pushed the benjb/pgbackrest-rotate branch from 7d2792d to 85d9046 Compare February 28, 2025 22:03
Issues: [PGO-2171]
@benjaminjb benjaminjb force-pushed the benjb/pgbackrest-rotate branch from 85d9046 to 01ca6bb Compare February 28, 2025 22:11
@benjaminjb benjaminjb merged commit b50bae9 into main Mar 1, 2025
19 checks passed
@benjaminjb benjaminjb deleted the benjb/pgbackrest-rotate branch March 1, 2025 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants