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

chore: support restore backoffLimit #6242

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apis/dataprotection/v1alpha1/restore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ type RestoreSpec struct {
// specified the required resources of restore job's container.
// +optional
ContainerResources corev1.ResourceRequirements `json:"containerResources,omitempty"`

// Specifies the number of retries before marking the restore failed.
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=10
BackoffLimit *int32 `json:"backoffLimit,omitempty"`
}

// BackupRef describes the backup name and namespace.
Expand Down
5 changes: 5 additions & 0 deletions apis/dataprotection/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions config/crd/bases/dataprotection.kubeblocks.io_restores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ spec:
spec:
description: RestoreSpec defines the desired state of Restore
properties:
backoffLimit:
description: Specifies the number of retries before marking the restore
failed.
format: int32
maximum: 10
minimum: 0
type: integer
backup:
description: 'backup to be restored. The restore behavior based on
the backup type: 1. Full: will be restored the full backup directly.
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/operations/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (c CustomOpsHandler) buildJob(reqCtx intctrlutil.RequestCtx,
buildJobSpec := func() (*batchv1.JobSpec, error) {
jobSpec := opsRes.OpsDef.Spec.JobSpec
if jobSpec.BackoffLimit == nil {
jobSpec.BackoffLimit = pointer.Int32(3)
jobSpec.BackoffLimit = pointer.Int32(2)
}

comp := opsRes.Cluster.Spec.GetComponentByName(compName)
Expand Down
7 changes: 7 additions & 0 deletions deploy/helm/crds/dataprotection.kubeblocks.io_restores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ spec:
spec:
description: RestoreSpec defines the desired state of Restore
properties:
backoffLimit:
description: Specifies the number of retries before marking the restore
failed.
format: int32
maximum: 10
minimum: 0
type: integer
backup:
description: 'backup to be restored. The restore behavior based on
the backup type: 1. Full: will be restored the full backup directly.
Expand Down
6 changes: 5 additions & 1 deletion pkg/dataprotection/restore/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ func (r *restoreJobBuilder) build() *batchv1.Job {
job.Spec.Template.ObjectMeta = metav1.ObjectMeta{
Labels: r.labels,
}
job.Spec.BackoffLimit = &defaultBackoffLimit
if r.restore.Spec.BackoffLimit != nil {
job.Spec.BackoffLimit = r.restore.Spec.BackoffLimit
} else {
job.Spec.BackoffLimit = &defaultBackoffLimit
}

// 2. set restore container
r.specificVolumeMounts = append(r.specificVolumeMounts, r.commonVolumeMounts...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/dataprotection/restore/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ const (
// Restore constant
const Restore = "restore"

var defaultBackoffLimit int32 = 3
var defaultBackoffLimit int32 = 2
2 changes: 1 addition & 1 deletion pkg/dataprotection/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ package types

var (
// DefaultBackOffLimit is the default backoff limit for jobs.
DefaultBackOffLimit = int32(3)
DefaultBackOffLimit = int32(2)
)
Loading