Skip to content

Commit 51428d5

Browse files
authored
br: cp bugfix from operator v1 (#6400)
1 parent de7e3f6 commit 51428d5

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

api/br/v1alpha1/restore_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ type RestoreSpec struct {
130130
StorageProvider `json:",inline"`
131131
// BR is the configs for BR.
132132
BR *BRConfig `json:"br,omitempty"`
133-
134133
// PitrRestoredTs is the pitr restored ts.
134+
// +optional
135135
PitrRestoredTs string `json:"pitrRestoredTs,omitempty"`
136136
// LogRestoreStartTs is the start timestamp which log restore from.
137137
// +optional
@@ -184,6 +184,8 @@ type RestoreSpec struct {
184184
// TolerateSingleTiKVOutage indicates whether to tolerate a single failure of a store without data loss
185185
// +kubebuilder:default=false
186186
TolerateSingleTiKVOutage bool `json:"tolerateSingleTiKVOutage,omitempty"`
187+
// +kubebuilder:default=0
188+
BackoffLimit int32 `json:"backoffLimit,omitempty"`
187189
}
188190

189191
// RestoreStatus represents the current status of a tidb cluster restore.

manifests/crd/br.pingcap.com_restores.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,6 +2886,10 @@ spec:
28862886
Otherwise retrieve the storage account from secret
28872887
type: string
28882888
type: object
2889+
backoffLimit:
2890+
default: 0
2891+
format: int32
2892+
type: integer
28892893
backupType:
28902894
description: Type is the backup type for tidb cluster and only used
28912895
when Mode = snapshot, such as full, db, table.

pkg/controllers/br/manager/restore/restore_manager.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"k8s.io/apimachinery/pkg/api/errors"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/client-go/tools/record"
27-
"k8s.io/utils/ptr"
2827
"sigs.k8s.io/controller-runtime/pkg/client"
2928
"sigs.k8s.io/controller-runtime/pkg/log"
3029

@@ -228,7 +227,10 @@ func (rm *restoreManager) makeRestoreJob(ctx context.Context, restore *v1alpha1.
228227

229228
switch restore.Spec.Mode {
230229
case v1alpha1.RestoreModePiTR:
231-
args = append(args, fmt.Sprintf("--mode=%s", v1alpha1.RestoreModePiTR), fmt.Sprintf("--pitrRestoredTs=%s", restore.Spec.PitrRestoredTs))
230+
args = append(args, fmt.Sprintf("--mode=%s", v1alpha1.RestoreModePiTR))
231+
if restore.Spec.PitrRestoredTs != "" {
232+
args = append(args, fmt.Sprintf("--pitrRestoredTs=%s", restore.Spec.PitrRestoredTs))
233+
}
232234
default:
233235
args = append(args, fmt.Sprintf("--mode=%s", v1alpha1.RestoreModeSnapshot))
234236
}
@@ -355,7 +357,7 @@ func (rm *restoreManager) makeRestoreJob(ctx context.Context, restore *v1alpha1.
355357
},
356358
},
357359
Spec: batchv1.JobSpec{
358-
BackoffLimit: ptr.To(int32(0)),
360+
BackoffLimit: &restore.Spec.BackoffLimit,
359361
Template: *podSpec,
360362
},
361363
}

0 commit comments

Comments
 (0)