longhorn-manager icon indicating copy to clipboard operation
longhorn-manager copied to clipboard

fix(backup): manually synchronizing backup volumes.

Open mantissahz opened this issue 1 year ago • 5 comments

Which issue(s) this PR fixes:

Issue # longhorn/longhorn#7982

What this PR does / why we need it:

When users make a requst to get backup volumes information by Backup Volume Get/List APIs, it will also trigger the synchronization for these backup volumes once.

Special notes for your reviewer:

Additional documentation or context

mantissahz avatar Mar 01 '24 08:03 mantissahz

When users make a BackupVolumeGet or BackupVolumeList HTTP call, they can trigger a backup volume refresh.

Is it possible to synchronize backup volumes by simply editing customer resources? Or do we need to a different method that doesn't involve HTTP calls?

derekbit avatar Mar 05 '24 07:03 derekbit

Is it possible to synchronize backup volumes by simply editing customer resources? Or do we need to a different method that doesn't involve HTTP calls?

Users can modify the field spec.syncRequestedAt of the BackupVolume CR for synchronizing the backup volume. And the time of the filed spec.syncRequestedAt should be after the time of the filed status.lastSyncedAt

mantissahz avatar Mar 05 '24 07:03 mantissahz

Can we just simply update backuptarget.spec.syncRequestedAt instead? Updating the spec for all backup volumes is probably not enough since there may be backup volume CR creation/deletion.

shuo-wu avatar Mar 05 '24 23:03 shuo-wu

Can we just simply update backuptarget.spec.syncRequestedAt instead? Updating the spec for all backup volumes is probably not enough since there may be backup volume CR creation/deletion.

Yes, we can and modified. Thanks.

mantissahz avatar Mar 06 '24 03:03 mantissahz

That's a good idea. And you don't need to worry about the schema validation. I think we can create a separate PR for this improvement. k8s-webhook-1

shuo-wu avatar Mar 08 '24 18:03 shuo-wu

backupTarget.Spec.SyncRequestedAt = "now" // metav1.Time{Time: time.Now().UTC()}

I think it isn't easy to have a constant value representing to trigger the sync , and the mutator will update it with a qualified time value instead because of https://github.com/longhorn/longhorn-manager/blob/master/webhook/admission/request.go#L43.

mantissahz avatar Mar 25 '24 07:03 mantissahz

Hello @mantissahz Is the PR ready?

derekbit avatar Apr 15 '24 07:04 derekbit

Hi @derekbit, Yes, it's ready. Thanks

mantissahz avatar Apr 15 '24 07:04 mantissahz

backupTarget.Spec.SyncRequestedAt = "now" // metav1.Time{Time: time.Now().UTC()}

I think it isn't easy to have a constant value representing to trigger the sync , and the mutator will update it with a qualified time value instead because of master/webhook/admission/request.go#L43.

I meant, you can rely on the mutator to update now to a qualified time.

innobead avatar May 07 '24 09:05 innobead

In general, LGTM. however, still have some feedback required to resolve.

P.S. In the current implementation, it's specific for REST API. How do users trigger it by updating the CR? need to exactly update the right time in the syncat field of backup target or backup volume on their own? I still recommend a way that can benefit both interfaces (UI and CLI kubectl)

After a quick discussion with @mantissahz , we added type validation for the sync_at field, so it's infeasible to use a non-time value to trigger the sync. so for non-UI users, we can create a CLI command for it. James will create a ticket for the following improvement.

/chart/templates/crds.yaml#L961-L965

              syncRequestedAt:
                description: The time to request run sync the remote backup target.
                format: date-time
                nullable: true
                type: string

innobead avatar May 07 '24 11:05 innobead

@mantissahz Ready to review?

derekbit avatar May 10 '24 00:05 derekbit

@mantissahz Ready to review?

@derekbit, Yes, it is ready.

mantissahz avatar May 10 '24 00:05 mantissahz

@Mergifyio backport v1.6.x

mantissahz avatar May 10 '24 03:05 mantissahz

backport v1.6.x

✅ Backports have been created

mergify[bot] avatar May 10 '24 03:05 mergify[bot]