Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: OSPC-613 mariadb cleanup old backups #546

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

LukeRepko
Copy link
Contributor

The mariadb-backup init container already runs as root and tries to chmod 777 the backup files, but they get changed back to 0644 at some point later on. This results in the mariadb-operator pod running into a permission denied situation during its cleanup for the desired retention setting.

The fix herein simply runs the pod as root so that the mariadb-operator container in the pod has access to cleanup the old backups as needed.

This change fixes NEW backups, existing ones need to have the corresponding CronJob modified (see below).

While re-applying the mariadb-backup will update the existing Backup, the mariadb-operator does not seem to reconcile the CronJob for the securityContext attribute. One must update the CronJob manually or apply a patch to fix existing jobs without deleting and re-creating them.

This patch has been tested and does just that to add the needed securityContext to the existing CronJob:

kubectl patch cronjob mariadb-backup -n openstack --type='json' \
-p='[{"op": "add", "path": "/spec/jobTemplate/spec/template/spec/securityContext/runAsUser", "value": 0}]'

Ref: OSPC-613

The mariadb-backup init container already runs as root and tries to
chmod `777` the backup files, but they get changed back to `0644` at some
point later on. This results in the mariadb-operator pod running into a
permission denied situation during its cleanup for the desired retention
setting.

The fix herein simply runs the pod as root so that the mariadb-operator
container in the pod has access to cleanup the old backups as needed.

This change fixes **NEW** backups, existing ones need to have the
corresponding `CronJob` modified (see below).

While re-applying the `mariadb-backup` will update the existing `Backup`,
the mariadb-operator does not seem to reconcile the `CronJob` for the
securityContext attribute. One must update the `CronJob` manually or
apply a patch to fix existing jobs without deleting and re-creating them.

This patch has been tested and does just that to add the needed
securityContext to the existing `CronJob`:

```shell
kubectl patch cronjob mariadb-backup -n openstack --type='json' \
-p='[{"op": "add", "path": "/spec/jobTemplate/spec/template/spec/securityContext/runAsUser", "value": 0}]'
```

Ref: OSPC-613
Copy link
Contributor

@cloudnull cloudnull left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@rackerchris rackerchris left a comment

Choose a reason for hiding this comment

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

LGTM +1

@LukeRepko LukeRepko merged commit ca46a3f into rackerlabs:main Nov 11, 2024
3 checks passed
@LukeRepko LukeRepko deleted the OSPC-613 branch November 11, 2024 15:55
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.

3 participants