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

feat: NonAdminBackup sync controller #138

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mateusoliveira43
Copy link
Contributor

@mateusoliveira43 mateusoliveira43 commented Jan 9, 2025

Why the changes were made

Fix #38

Blocked by #139

Blocked by #116

Blocked by #152

Blocked by openshift/oadp-operator#1624

Once NAC Pod is created, NonAdminBackup Synchronizer controller will start, and will run periodically. Its frequency run is defined by admin user in DPA. By default 2 minutes.

NonAdminBackup Synchronizer controller will:

  • fetch all BSLs in OADP namespace, filtering those that are default or are NAC owned and its related NABSL exists
  • fetch all NAC owned Backups in OADP namespace, filtering those that are in completed state and use one of the filtered BSLs (from previous step)
  • check if related NonAdminBackup exists and its namespace exists, for each filtered Backup (from previous step)
  • non-existent NonAdminBackups (but that its origin namespace exist), will be recreated

How to test the changes made

Follow install-from-source testing documentation, pointing this branch and my OADP fork branch feat/nac-nab-sync-controller

Create NonAdminBackups, using NABSL and default BSL from OADP namespace. Delete them from cluster (but not from object storage). They should be recreated after sync period is reached.

@mateusoliveira43
Copy link
Contributor Author

/hold

Copy link

openshift-ci bot commented Jan 9, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mateusoliveira43

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -89,6 +89,8 @@ func (r *NonAdminBackupReconciler) Reconcile(ctx context.Context, req ctrl.Reque
return ctrl.Result{}, err
}

_, syncBackup := nab.Labels["openshift.io/oadp-nab-synced-from-nacuuid"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was my idea to differ NABs created by user and by sync controller: adding a label to object

what you think about this approach?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That sounds like a proper design for that. Would use something from https://github.com/openshift/oadp-operator/blob/master/api/v1alpha1/oadp_types.go#L35 and we are using it in few places already in the constant.go

Possibly adding yet one label, but that would mean the object is managed by entirely and I think that may be not true, as once it's synced it's no longer managed by sync controller it's the user responsibility to do something with it like deletion:

app.kubernetes.io/managed-by: self-service-sync-controller

cmd/main.go Outdated
@@ -169,6 +170,8 @@ func main() {
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
OADPNamespace: oadpNamespace,
// TODO user input
SyncPeriod: 5 * time.Minute,

Choose a reason for hiding this comment

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

yeah correct, this would be a user input but we would need a default value.
Have you given any thoughts on how to accept this from the user ? I can think of a new possibilities:

  • From DPA.spec.nonAdmin struct.
  • Create a struct under DPA.spec.nonAdmin.Args and accept the value there.
  • Introduce a configmap for nacusers/admin users for specifying such things.
  • All of the above are extensible enough for similar user inputs in the future NAC world if needed.

Copy link
Member

Choose a reason for hiding this comment

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

The minimum should be no less than velero's sync controller IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will be DPA field under nonAdmin

I would not validate if the value is greater or equal to velero's value, do not know if is simple to be done

Copy link
Member

Choose a reason for hiding this comment

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

Velero value isn't customizable AFAICT so if you want to, it can be a hardcoded copy.

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

checking.

Copy link
Member

Choose a reason for hiding this comment

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

looks like that will eventually set here

and there are code to sync backup to cluster and code to delete orphaned backups as part of this velero upstream sync. So I think this is the same case.

Velero default is 1 minute So our 5 minutes works. Could be as low as 2 min imo.

@@ -117,6 +117,14 @@ func (r *NonAdminBackupReconciler) Reconcile(ctx context.Context, req ctrl.Reque
r.removeNabFinalizerUponVeleroBackupDeletion,
}

case function.CheckLabelAnnotationValueIsValid(nab.Labels, constant.NabSyncLabel):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

write test for this scenario

@mateusoliveira43 mateusoliveira43 force-pushed the feat/non-admin-backup-sync-controller branch from 3887cb2 to 48273eb Compare February 7, 2025 20:03
@@ -82,3 +82,5 @@ require (
)

replace github.com/vmware-tanzu/velero => github.com/openshift/velero v0.10.2-0.20241211163542-fa8f2486175b

replace github.com/openshift/oadp-operator => github.com/mateusoliveira43/oadp-operator v0.0.0-20250205190228-fcc5ea4a6c32
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO remove prior to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Non-Admin Backup Sync controller
4 participants