-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Uploader Implementation: Kopia backup and restore #5221
Conversation
2ef9d12
to
37c646d
Compare
ffe390d
to
67c5d38
Compare
Signed-off-by: Ming <mqiu@vmware.com>
db0b2e8
to
4060bec
Compare
Codecov Report
@@ Coverage Diff @@
## main #5221 +/- ##
==========================================
- Coverage 41.79% 41.39% -0.40%
==========================================
Files 225 231 +6
Lines 19172 19659 +487
==========================================
+ Hits 8012 8137 +125
- Misses 10574 10928 +354
- Partials 586 594 +8
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
e69a372
to
8d5e38f
Compare
} | ||
|
||
//NewKopiaUploaderProvider initialized with open or create a repository | ||
func NewKopiaUploaderProvider( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the velerov1.BackupRepo
a parameter of the function? Or how does the uploader know where to put the files?
And seems only the BSL's UID is used, how does the uploader know the access information(e.g. URL) of the storage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I am considering this problem, we need to use BSL+VolumeNamespace to identify a repository. On the other hand, actually, if we have the velerov1.BackupRepo
, it is enough to just use velerov1.BackupRepo
's UUID to identify a repository, which is quite simple. However, in the current code, PVB/PVR doesn't get the velerov1.BackupRepo
.
Let me consider this for some more time and discuss with you guys later. In the current PR, let's make it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me add some more explanation here:
- During the Connect operation of unified repo, a config file containing all the connecting information, except the credentials, is stored in a local file
- During the backup/restore, as long as the uploader could provide the name of the config file, it could connect to the repo and then write/read data to/from the repo
- The Connection operation is done during repo initialization, that is, by the
velerov1.BackupRepo
reconciler - We need a unique file name for the local config so that different repos don't mix up their configuration
- At present, the config file is named by the BSL's UUID
As mentioned above BSL's UUID is not enough, velerov1.BackupRepo
's UUID is more suitable, however, it is not currently available in PVB/PVR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I've changed into velerov1.BackupRepo
's UUID
pkg/uploader/provider/kopia.go
Outdated
//CheckContext check context status periodically | ||
//check if context is timeout or cancel | ||
func (kp *kopiaProvider) CheckContext(ctx context.Context) { | ||
for { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The for loop should be stopped once the backup/restore is finished
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I've add one finishChan
chan to stop the loop once finished
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the for loop isn't needed. By removing the default
section, we can use select without the for loop
return errors.Wrapf(err, "Failed to run kopia restore") | ||
} | ||
|
||
updater.UpdateProgress(&uploader.UploaderProgress{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to update the progress here? Could you add comments about it if it is needed indeed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure that the statistic data of TotalBytes is equal to BytesDone when finished, I've added one annotation
pkg/uploader/provider/kopia.go
Outdated
prorgess := new(kopia.KopiaProgress) | ||
prorgess.InitThrottle(backupProgressCheckInterval) | ||
prorgess.Updater = updater | ||
kp.uploader.Progress = prorgess |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the Progress
of the shared uploader
will be overwritten when calling Runbackups()
more than once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I've removed the uploader from the kopiaProvider struct. which will make the progress is independent for every backup
pkg/uploader/provider/kopia.go
Outdated
bkRepo udmrepo.BackupRepo | ||
credGetter *credentials.CredentialGetter | ||
uploader *snapshotfs.Uploader | ||
restoreCancel chan struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it only for one specific restore? If it is, it should be not the field of kopiaProvider
as kopiaProvider
are shared by different RunRestore()
actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed it from the kopiaProvider
struct.
pkg/uploader/provider/kopia.go
Outdated
"parentSnapshot": parentSnapshot, | ||
}) | ||
repoWriter := kopia.NewShimRepo(kp.bkRepo) | ||
kp.uploader = snapshotfs.NewUploader(repoWriter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the uploader shared with other function calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed uploader from kp
272c30c
to
fee188f
Compare
Signed-off-by: Ming <mqiu@vmware.com>
fee188f
to
2bf054a
Compare
Signed-off-by: Ming mqiu@vmware.com
Thank you for contributing to Velero!
Please add a summary of your change
Uploader Implementation: Kopia backup and restore
It's about uploader module implementation, which related to kopia implementation of backup and restore
which reference to #5074 #5073
Please indicate you've done the following:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.