-
Notifications
You must be signed in to change notification settings - Fork 500
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
Add commit ts to restore status #2899
Add commit ts to restore status #2899
Conversation
@@ -58,18 +58,18 @@ type gcsQuery struct { | |||
} | |||
|
|||
// NewRemoteStorage creates new remote storage | |||
func NewRemoteStorage(backup *v1alpha1.Backup) (*blob.Bucket, error) { | |||
st := util.GetStorageType(backup.Spec.StorageProvider) | |||
func NewRemoteStorage(provider v1alpha1.StorageProvider, fakeRegion bool) (*blob.Bucket, error) { |
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 add fakeRegion
to this function?
@DanielZhangQD @cofyc PTAL again |
Message: err.Error(), | ||
}) | ||
errs = append(errs, uerr) | ||
return errorutils.NewAggregate(errs) |
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.
Suggest not to return here.
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 think it's ok. I don't think it's necessary to continue the restore operation with the backup from which we can't even get the commitTs information.
btw, should we move this before the restore operation like we do in import/manager.go
file?
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, then i think we can move this block before the GC time setting code block.
@@ -186,6 +201,7 @@ func (rm *RestoreManager) performRestore(restore *v1alpha1.Restore) error { | |||
|
|||
restore.Status.TimeStarted = metav1.Time{Time: started} | |||
restore.Status.TimeCompleted = metav1.Time{Time: finish} | |||
restore.Status.CommitTs = commitTs |
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.
always update (edit: ignore)commitTs
when we get it successfully
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.
sorry, maybe it's better not to update it when the restore fails as the commitTs
indicates the commit timestamp or position of the restored backup
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.
which means current implementation is correct?
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.
changes in this file LGTM
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 see
finish := time.Now() | ||
restore.Status.TimeStarted = metav1.Time{Time: started} | ||
restore.Status.TimeCompleted = metav1.Time{Time: finish} | ||
restore.Status.CommitTs = fmt.Sprintf("%d", commitTs) |
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.
nit: use strconv.FormatInt(commitTs, 10)
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.
revised.
|
||
Finished dump at: 2019-06-13 10:00:04 | ||
*/ | ||
func GetCommitTsFromMetadata(backupPath string) (string, error) { |
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.
Can you add a unit test function for this function?
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.
added in b6e3120
} | ||
|
||
// GetCommitTsFromBRMetaData get backup position from `EndVersion` in BR backup meta | ||
func GetCommitTsFromBRMetaData(provider v1alpha1.StorageProvider) (uint64, error) { |
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.
ditto, better to have a unit test for this function
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.
this function get TS from S3 and ts is decoded by proto.Unmarshal
. Maybe later we can mock it in another PR. This PR won't add this.
@@ -299,7 +299,7 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro | |||
} | |||
klog.Infof("get cluster %s archived backup file %s size %d success", bm, archiveBackupPath, size) | |||
|
|||
commitTs, err := getCommitTsFromMetadata(backupFullPath) | |||
commitTs, err := util.GetCommitTsFromMetadata(backupFullPath) |
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.
Please wait for #2897 which removes the temp data after the compression.
@@ -182,10 +182,26 @@ func (rm *RestoreManager) performRestore(restore *v1alpha1.Restore) error { | |||
} | |||
klog.Infof("restore cluster %s from backup %s success", rm, rm.BackupPath) | |||
|
|||
commitTs, err := util.GetCommitTsFromMetadata(unarchiveDataPath) |
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.
As per discussion, please move this block after the uncompression code block.
After manual test, br & export & import can record commitTs correctly. PTAL again @cofyc @DanielZhangQD |
/test pull-e2e-kind-serial |
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.
LGTM
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-1.1 in PR #2925 |
What problem does this PR solve?
Fix #2774.
What is changed and how does it work?
Reuse the
getCommitTs
function for BR and lightning. Save commitTS inrestoreStatus
.Check List
Tests
The manual checks for lightning and br restore are both okay.
Related changes
Does this PR introduce a user-facing change?: