Skip to content

K8SPSMDB-1202 add logs for scheduled backup cleanup#2381

Merged
hors merged 7 commits into
mainfrom
K8SPSMDB-1202
Jun 12, 2026
Merged

K8SPSMDB-1202 add logs for scheduled backup cleanup#2381
hors merged 7 commits into
mainfrom
K8SPSMDB-1202

Conversation

@nmarukovich

Copy link
Copy Markdown
Contributor

CHANGE DESCRIPTION

Problem:
Short explanation of the problem.
Logs about scheduled clean up were added.
Cause:
Short explanation of the root cause of the issue if applicable.

Solution:
Short explanation of the solution we are providing with this PR.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported MongoDB version?
  • Does the change support oldest and newest supported Kubernetes version?

Copilot AI review requested due to automatic review settings June 4, 2026 09:17
@pull-request-size pull-request-size Bot added the size/XS 0-9 lines label Jun 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds additional structured logging around scheduled backup retention cleanup in the Percona Server for MongoDB operator, improving observability when old scheduled backups are deleted.

Changes:

  • Log when retention-count cleanup is about to remove scheduled backups.
  • Log each backup deletion and include the backup name in deletion error logs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +167 to +170
if len(oldjobs) > 0 {
log.Info("cleaning up old backups based on retention count",
"job", item.Name, "keep", ret.Count, "toDelete", len(oldjobs))
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@nmarukovich please check these comments

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeap valid point

Comment on lines 172 to +176
for _, todel := range oldjobs {
log.Info("deleting outdated backup", "job", item.Name, "backup", todel.Name)
err = r.client.Delete(ctx, &todel)
if err != nil {
log.Error(err, "failed to delete backup object")
log.Error(err, "failed to delete backup object", "backup", todel.Name)
@egegunes egegunes changed the title K8SPSMDB-1202 add logs K8SPSMDB-1202 add logs for scheduled backup cleanup Jun 5, 2026
egegunes
egegunes previously approved these changes Jun 5, 2026
hors
hors previously approved these changes Jun 5, 2026
Comment on lines +167 to +170
if len(oldjobs) > 0 {
log.Info("cleaning up old backups based on retention count",
"job", item.Name, "keep", ret.Count, "toDelete", len(oldjobs))
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@nmarukovich please check these comments

Comment on lines +167 to +170
if len(oldjobs) > 0 {
log.Info("cleaning up old backups based on retention count",
"job", item.Name, "keep", ret.Count, "toDelete", len(oldjobs))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we have this log when, at the same time we are iterating oldjobs and we generate one log for each old job we have?

}

for _, todel := range oldjobs {
log.Info("deleting outdated backup", "job", item.Name, "backup", todel.Name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would't say that these old jobs are outdated, they are not. They are just exceeding retention. Maybe we can say exceeding retention

@gkech gkech Jun 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: deleting backup exceeding retention

@hors hors added this to the v1.23.0 milestone Jun 8, 2026
@nmarukovich nmarukovich dismissed stale reviews from hors and egegunes via af65c5e June 9, 2026 10:04
Copilot AI review requested due to automatic review settings June 10, 2026 08:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines +168 to 172
log.Info("deleting backup exceeding retention", "job", item.Name, "backup", todel.Name)
err = r.client.Delete(ctx, &todel)
if err != nil {
log.Error(err, "failed to delete backup object")
log.Error(err, "failed to delete backup object", "backup", todel.Name)
return true
Copilot AI review requested due to automatic review settings June 11, 2026 10:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines +168 to 172
log.Info("deleting backup exceeding retention", "job", item.Name, "backup", todel.Name)
err = r.client.Delete(ctx, &todel)
if err != nil {
log.Error(err, "failed to delete backup object")
log.Error(err, "failed to delete backup object", "backup", todel.Name)
return true
@JNKPercona

Copy link
Copy Markdown
Collaborator
Test Name Result Time
arbiter passed 00:00:00
balancer passed 00:00:00
cert-management-policy passed 00:00:00
cross-site-sharded passed 00:00:00
custom-replset-name passed 00:00:00
custom-tls passed 00:00:00
custom-users-roles passed 00:00:00
custom-users-roles-sharded passed 00:00:00
data-at-rest-encryption passed 00:00:00
data-sharded passed 00:00:00
demand-backup passed 00:16:34
demand-backup-eks-credentials-irsa passed 00:00:00
demand-backup-fs passed 00:00:00
demand-backup-if-unhealthy passed 00:00:00
demand-backup-incremental-aws passed 00:00:00
demand-backup-incremental-azure passed 00:00:00
demand-backup-incremental-gcp-native passed 00:00:00
demand-backup-incremental-gcp-s3 passed 00:00:00
demand-backup-incremental-minio passed 00:00:00
demand-backup-incremental-sharded-aws passed 00:00:00
demand-backup-incremental-sharded-azure passed 00:00:00
demand-backup-incremental-sharded-gcp-native passed 00:00:00
demand-backup-incremental-sharded-gcp-s3 passed 00:00:00
demand-backup-incremental-sharded-minio passed 00:00:00
demand-backup-logical-minio-native-tls passed 00:00:00
demand-backup-physical-parallel passed 00:00:00
demand-backup-physical-aws passed 00:12:30
demand-backup-physical-azure passed 00:00:00
demand-backup-physical-gcp-s3 passed 00:00:00
demand-backup-physical-gcp-native passed 00:00:00
demand-backup-physical-minio passed 00:00:00
demand-backup-physical-minio-native passed 00:00:00
demand-backup-physical-minio-native-tls passed 00:00:00
demand-backup-physical-sharded-parallel passed 00:00:00
demand-backup-physical-sharded-aws passed 00:00:00
demand-backup-physical-sharded-azure passed 00:00:00
demand-backup-physical-sharded-gcp-native passed 00:00:00
demand-backup-physical-sharded-minio passed 00:00:00
demand-backup-physical-sharded-minio-native passed 00:00:00
demand-backup-sharded passed 00:00:00
demand-backup-snapshot passed 00:00:00
demand-backup-snapshot-vault passed 00:00:00
disabled-auth passed 00:00:00
expose-sharded passed 00:32:52
finalizer passed 00:00:00
ignore-labels-annotations passed 00:00:00
init-deploy passed 00:00:00
ldap passed 00:09:55
ldap-tls passed 00:00:00
limits passed 00:00:00
liveness passed 00:00:00
mongod-major-upgrade passed 00:00:00
mongod-major-upgrade-sharded passed 00:00:00
monitoring-2-0 passed 00:00:00
monitoring-pmm3 passed 00:00:00
multi-cluster-service passed 00:13:34
multi-storage passed 00:00:00
non-voting-and-hidden passed 00:00:00
one-pod passed 00:08:26
operator-self-healing-chaos passed 00:00:00
pitr passed 00:00:00
pitr-physical passed 00:00:00
pitr-sharded passed 00:23:40
pitr-to-new-cluster passed 00:00:00
pitr-physical-backup-source passed 00:00:00
preinit-updates passed 00:00:00
pvc-auto-resize passed 00:00:00
pvc-resize passed 00:00:00
recover-no-primary passed 00:00:00
replset-overrides passed 00:00:00
replset-remapping passed 00:00:00
replset-remapping-sharded passed 00:00:00
rs-shard-migration passed 00:00:00
scaling passed 00:00:00
scheduled-backup passed 00:00:00
security-context passed 00:00:00
self-healing-chaos passed 00:00:00
service-per-pod passed 00:00:00
serviceless-external-nodes passed 00:00:00
smart-update passed 00:00:00
split-horizon passed 00:00:00
split-horizon-manual-tls passed 00:00:00
stable-resource-version passed 00:00:00
storage passed 00:00:00
tls-issue-cert-manager passed 00:00:00
unsafe-psa passed 00:00:00
upgrade passed 00:00:00
upgrade-consistency passed 00:00:00
upgrade-consistency-sharded-tls passed 00:00:00
upgrade-sharded passed 00:00:00
upgrade-partial-backup passed 00:00:00
users passed 00:00:00
users-vault passed 00:00:00
version-service passed 00:00:00
Summary Value
Tests Run 94/94
Job Duration 00:59:00
Total Test Time 01:57:35

commit: c451228
image: perconalab/percona-server-mongodb-operator:PR-2381-c451228ca

Copilot AI review requested due to automatic review settings June 12, 2026 11:13
@hors hors merged commit 44edc35 into main Jun 12, 2026
16 checks passed
@hors hors deleted the K8SPSMDB-1202 branch June 12, 2026 11:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines +168 to 172
log.Info("deleting backup exceeding retention", "job", item.Name, "backup", todel.Name)
err = r.client.Delete(ctx, &todel)
if err != nil {
log.Error(err, "failed to delete backup object")
log.Error(err, "failed to delete backup object", "backup", todel.Name)
return true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS 0-9 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants