-
Notifications
You must be signed in to change notification settings - Fork 498
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
support cleanPolicy for backup CR #3002
Changes from 15 commits
26b1eb8
0bae349
aedf29b
f2d7cc7
69d2cad
31217f9
7d896d9
e484693
a6c7b80
fe9c627
d177a55
32d164f
4e1d38f
c5e77dc
6341abc
337934b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,15 +65,15 @@ func (bo *Options) cleanBRRemoteBackupData(backup *v1alpha1.Backup) error { | |
|
||
func (bo *Options) cleanRemoteBackupData(bucket string, opts []string) error { | ||
destBucket := util.NormalizeBucketURI(bucket) | ||
args := util.ConstructArgs(constants.RcloneConfigArg, opts, "deletefile", destBucket, "") | ||
args := util.ConstructArgs(constants.RcloneConfigArg, opts, "delete", destBucket, "") | ||
output, err := exec.Command("rclone", args...).CombinedOutput() | ||
if err != nil { | ||
if exitError, ok := err.(*exec.ExitError); ok { | ||
if code := exitError.ExitCode(); code == 3 || code == 4 { | ||
klog.Infof("cluster %s backup %s has already been deleted before", bo, bucket) | ||
return nil | ||
} | ||
} | ||
return fmt.Errorf("cluster %s, execute rclone deletefile command failed, output: %s, err: %v", bo, string(output), err) | ||
} | ||
|
||
args = util.ConstructArgs(constants.RcloneConfigArg, opts, "delete", fmt.Sprintf("%s.tmp", destBucket), "") | ||
output, err = exec.Command("rclone", args...).CombinedOutput() | ||
if err != nil { | ||
return fmt.Errorf("cluster %s, execute rclone deletefile command failed, output: %s, err: %v", bo, string(output), err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/deletefile/delete |
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,6 +323,23 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro | |
|
||
remotePath := strings.TrimPrefix(archiveBackupPath, constants.BackupRootPath+"/") | ||
bucketURI := bm.getDestBucketURI(remotePath) | ||
backup.Status.BackupPath = bucketURI | ||
err = bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{ | ||
Type: v1alpha1.BackupPrepare, | ||
Status: corev1.ConditionTrue, | ||
}) | ||
if err != nil { | ||
errs = append(errs, err) | ||
uerr := bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{ | ||
Type: v1alpha1.BackupFailed, | ||
Status: corev1.ConditionTrue, | ||
Reason: "UpdateBackupPathFailed", | ||
Message: err.Error(), | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why setting this condition if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. copyed from https://github.com/pingcap/tidb-operator/blob/master/cmd/backup-manager/app/backup/manager.go#L159 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it's meaningless to call our current architecture relies on our backup job to update does it cause problems when the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we omit this error, we might be unable to clean files on the Cloud when we delete this CR because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but the (if this is not true, I think we should fix it. one more API call does not help) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So should we omit this error? What about BR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we didn't omit the error, the job fails |
||
errs = append(errs, uerr) | ||
return errorutils.NewAggregate(errs) | ||
} | ||
|
||
err = bm.backupDataToRemote(archiveBackupPath, bucketURI, opts) | ||
if err != nil { | ||
errs = append(errs, err) | ||
|
@@ -342,7 +359,6 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro | |
|
||
finish := time.Now() | ||
|
||
backup.Status.BackupPath = bucketURI | ||
backup.Status.TimeStarted = metav1.Time{Time: started} | ||
backup.Status.TimeCompleted = metav1.Time{Time: finish} | ||
backup.Status.BackupSize = size | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,7 +288,7 @@ func newBackup() *v1alpha1.Backup { | |
}, | ||
StorageClassName: pointer.StringPtr("local-storage"), | ||
StorageSize: "1Gi", | ||
CleanData: true, | ||
CleanPolicy: v1alpha1.CleanPolicyTypeDelete, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add tests for other values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will add tests later |
||
}, | ||
} | ||
} |
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.
s/deletefile/delete