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

Backups created by policy can be deleted by ArgoCD #1260

Open
wyattwalter opened this issue Feb 28, 2023 · 4 comments
Open

Backups created by policy can be deleted by ArgoCD #1260

wyattwalter opened this issue Feb 28, 2023 · 4 comments

Comments

@wyattwalter
Copy link

We are using ArgoCD to manage both the kube-arangodb operator install as well as a number of ArangoDB deployment objects. I noticed today that some backups that are being scheduled by our BackupPolicy are simply missing. Looking through the event logs, it looks like those backups were indeed created, and then subsequently deleted by ArgoCD.

I believe that what has been happening is that the backup is created on the schedule without an ownerReference object by the policy handler without an ownerReference but it does do a copy of the annotations from the deployment such as argocd.argoproj.io/instance. Then some job is coming along and adding that ownerReference to the backup object. However, if ArgoCD tries to sync with prune set to true on the application in the meantime, it deletes the backup object. This happens because at that moment the object says it's managed by an ArgoCD project (argocd.argoproj.io/instance is set), but the application doesn't have that resource and there's no ownerReference to follow so ArgoCD can know that it's owned by the cluster.

I think that ArgoCD is behaving correctly in this case, and that the ownerReference should be added to the object by the policy handler at creation time.

@jwierzbo
Copy link
Collaborator

jwierzbo commented Mar 6, 2023

We have ownerReference set in place in every Backup object

➜ kubectl get arangobackup backup-1 -o yaml
apiVersion: backup.arangodb.com/v1
kind: ArangoBackup
metadata:
  annotations:
  finalizers:
  - arangobackups.backup.arangodb.com/cleanup
  generation: 2
  name: backup-1
  namespace: test
  ownerReferences:
  - apiVersion: database.arangodb.com/v1
    controller: true
    kind: ArangoDeployment
    name: single
    uid: d264d3a9-afb3-4acf-96e7-e177570b3f10

@wyattwalter
Copy link
Author

Yes, but not immediately upon creation when it's created by a policy. There's a timing-related issue here where it doesn't at first and the operator comes along at some point and adds that field. Not all backups are deleted by ArgoCD, only ones where a sync happens in that time between when the backup object is created and the ownerReferences field is added.

@ajanikow
Copy link
Collaborator

Hello!

We will modify creation of backups for policy.

Best,
Adam.

@wyattwalter
Copy link
Author

Hey @ajanikow , it looks like this is still an issue in the latest version of the operator. We've worked around it last year by disabling prune on the ArgoCD app, but that has its own problems in certain scenarios. Can we get this in an upcoming release?

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

No branches or pull requests

3 participants