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

add commitTS in column for restore #2926

Merged
merged 10 commits into from
Jul 17, 2020
3 changes: 3 additions & 0 deletions cmd/backup-manager/app/backup/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ func (bm *Manager) performBackup(backup *v1alpha1.Backup, db *sql.DB) error {
if oldTikvGCTimeDuration < tikvGCTimeDuration {
err = bm.SetTikvGCLifeTime(db, oldTikvGCTime)
if err != nil {
if backupErr != nil {
DanielZhangQD marked this conversation as resolved.
Show resolved Hide resolved
errs = append(errs, backupErr)
}
errs = append(errs, err)
klog.Errorf("cluster %s reset tikv GC life time to %s failed, err: %s", bm, oldTikvGCTime, err)
uerr := bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{
Expand Down
5 changes: 4 additions & 1 deletion cmd/backup-manager/app/export/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro
}

if oldTikvGCTimeDuration < tikvGCTimeDuration {
err = bm.SetTikvGCLifeTime(db, constants.TikvGCLifeTime)
err = bm.SetTikvGCLifeTime(db, tikvGCLifeTime)
if err != nil {
errs = append(errs, err)
klog.Errorf("cluster %s set tikv GC life time to %s failed, err: %s", bm, constants.TikvGCLifeTime, err)
Expand All @@ -239,6 +239,9 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro
if oldTikvGCTimeDuration < tikvGCTimeDuration {
err = bm.SetTikvGCLifeTime(db, oldTikvGCTime)
if err != nil {
if backupErr != nil {
errs = append(errs, backupErr)
}
errs = append(errs, err)
klog.Errorf("cluster %s reset tikv GC life time to %s failed, err: %s", bm, oldTikvGCTime, err)
uerr := bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{
Expand Down
3 changes: 3 additions & 0 deletions cmd/backup-manager/app/restore/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ func (rm *Manager) performRestore(restore *v1alpha1.Restore, db *sql.DB) error {
if oldTikvGCTimeDuration < tikvGCTimeDuration {
err = rm.SetTikvGCLifeTime(db, oldTikvGCTime)
if err != nil {
if restoreErr != nil {
errs = append(errs, restoreErr)
}
errs = append(errs, err)
klog.Errorf("cluster %s reset tikv GC life time to %s failed, err: %s", rm, oldTikvGCTime, err)
uerr := rm.StatusUpdater.Update(restore, &v1alpha1.RestoreCondition{
Expand Down
4 changes: 4 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11748,6 +11748,10 @@ spec:
format: date-time
name: Completed
type: string
- JSONPath: .status.commitTs
description: The commit ts of tidb cluster restore
name: CommitTS
type: string
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
Expand Down
8 changes: 7 additions & 1 deletion pkg/util/crdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ var (
Description: "The time at which the restore was completed",
JSONPath: ".status.timeCompleted",
}
restoreCommitTSColumn = extensionsobj.CustomResourceColumnDefinition{
Name: "CommitTS",
Type: "string",
Description: "The commit ts of tidb cluster restore",
JSONPath: ".status.commitTs",
}
bksAdditionalPrinterColumns []extensionsobj.CustomResourceColumnDefinition
bksScheduleColumn = extensionsobj.CustomResourceColumnDefinition{
Name: "Schedule",
Expand Down Expand Up @@ -227,7 +233,7 @@ func init() {
tidbClusterTiKVColumn, tidbClusterTiKVStorageColumn, tidbClusterTiKVReadyColumn, tidbClusterTiKVDesireColumn,
tidbClusterTiDBColumn, tidbClusterTiDBReadyColumn, tidbClusterTiDBDesireColumn, tidbClusterStatusMessageColumn, ageColumn)
backupAdditionalPrinterColumns = append(backupAdditionalPrinterColumns, backupPathColumn, backupBackupSizeColumn, backupCommitTSColumn, backupStartedColumn, backupCompletedColumn, ageColumn)
restoreAdditionalPrinterColumns = append(restoreAdditionalPrinterColumns, restoreStartedColumn, restoreCompletedColumn, ageColumn)
restoreAdditionalPrinterColumns = append(restoreAdditionalPrinterColumns, restoreStartedColumn, restoreCompletedColumn, restoreCommitTSColumn, ageColumn)
bksAdditionalPrinterColumns = append(bksAdditionalPrinterColumns, bksScheduleColumn, bksMaxBackups, bksLastBackup, bksLastBackupTime, ageColumn)
tidbInitializerPrinterColumns = append(tidbInitializerPrinterColumns, tidbInitializerPhase, ageColumn)
autoScalerPrinterColumns = append(autoScalerPrinterColumns, autoScalerTiDBMaxReplicasColumn, autoScalerTiDBMinReplicasColumn,
Expand Down