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(backup): manually synchronizing backup volumes. #2660

Merged
merged 1 commit into from
May 10, 2024

Conversation

mantissahz
Copy link
Contributor

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

@derekbit
Copy link
Member

derekbit commented Mar 5, 2024

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?

@mantissahz
Copy link
Contributor Author

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

@shuo-wu
Copy link
Contributor

shuo-wu commented Mar 5, 2024

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.

@mantissahz
Copy link
Contributor Author

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.

shuo-wu
shuo-wu previously approved these changes Mar 7, 2024
Copy link
Contributor

@shuo-wu shuo-wu left a comment

Choose a reason for hiding this comment

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

The implementation LGTM.

Currently, the main concern is, will the websocket keep calling BackupVolumeList then Longhorn generates tons of requests to the remote? If users are using public cloud services like S3, it will lead to a higher bill.

Copy link
Member

@innobead innobead left a comment

Choose a reason for hiding this comment

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

Should we consider just updating SyncRequestedAt to trigger the sync? We could have a constant value representing that the sync will be just triggered, and the mutator will update it with a qualified time value instead. WDYT?

In this way, for UI or even manifest, users can trigger the sync immediately with the same experience.

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

P.S. I assume we don't have schema validation for that property.

@shuo-wu
Copy link
Contributor

shuo-wu commented Mar 8, 2024

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

@mantissahz
Copy link
Contributor Author

mantissahz commented Mar 25, 2024

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.

@derekbit
Copy link
Member

Hello @mantissahz Is the PR ready?

@mantissahz
Copy link
Contributor Author

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

Copy link
Contributor

@shuo-wu shuo-wu left a comment

Choose a reason for hiding this comment

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

Currently, will Longhorn UI show all backup volumes for all backup targets? If NO, it's better to add an input BackupTargetName for API SyncBackupTarget.

api/router.go Outdated Show resolved Hide resolved
@mantissahz mantissahz requested a review from shuo-wu April 19, 2024 04:23
api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
derekbit
derekbit previously approved these changes May 7, 2024
Copy link
Member

@derekbit derekbit left a comment

Choose a reason for hiding this comment

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

LGTM

@innobead
Copy link
Member

innobead commented May 7, 2024

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.

Copy link
Member

@innobead innobead left a comment

Choose a reason for hiding this comment

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

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)

api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
api/backup.go Outdated Show resolved Hide resolved
api/model.go Outdated Show resolved Hide resolved
api/model.go Outdated Show resolved Hide resolved
manager/engine.go Show resolved Hide resolved
manager/engine.go Show resolved Hide resolved
@innobead
Copy link
Member

innobead commented May 7, 2024

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

@derekbit
Copy link
Member

@mantissahz Ready to review?

When users make a requst to synchronize the backup target by
a new Backup Volume APIs `syncBackupTarget`, it will also trigger
the synchronization for thee backup volumes of the backup target.

Ref: 7982

Signed-off-by: James Lu <james.lu@suse.com>
@mantissahz
Copy link
Contributor Author

@mantissahz Ready to review?

@derekbit, Yes, it is ready.

@mantissahz mantissahz requested a review from a team May 10, 2024 01:01
@derekbit derekbit dismissed innobead’s stale review May 10, 2024 03:01

Dismiss for merge

@derekbit derekbit merged commit e1a2b4c into longhorn:master May 10, 2024
7 checks passed
@mantissahz
Copy link
Contributor Author

@Mergifyio backport v1.6.x

Copy link

mergify bot commented May 10, 2024

backport v1.6.x

✅ Backports have been created

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.

4 participants