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

fix: set backuppolicy.spec.backofflimit to default value #7192

Merged
merged 6 commits into from
May 6, 2024
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
1 change: 1 addition & 0 deletions apis/apps/v1alpha1/backuppolicytemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type BackupPolicy struct {
// Specifies the maximum number of retry attempts for a backup before it is considered a failure.
//
// +optional
// +kubebuilder:default=2
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=10
BackoffLimit *int32 `json:"backoffLimit,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions apis/dataprotection/v1alpha1/backuppolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type BackupPolicySpec struct {
// Specifies the number of retries before marking the backup as failed.
//
// +optional
// +kubebuilder:default=2
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=10
BackoffLimit *int32 `json:"backoffLimit,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ spec:
are different versions of definitions of the same component.
properties:
backoffLimit:
default: 2
description: Specifies the maximum number of retry attempts
for a backup before it is considered a failure.
format: int32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ spec:
description: BackupPolicySpec defines the desired state of BackupPolicy
properties:
backoffLimit:
default: 2
description: Specifies the number of retries before marking the backup
as failed.
format: int32
Expand Down
1 change: 0 additions & 1 deletion controllers/apps/transformer_cluster_backup_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ func (r *clusterBackupPolicyTransformer) syncBackupPolicy(comp *appsv1alpha1.Clu
backupPolicy.Spec.BackupRepoName = &r.Cluster.Spec.Backup.RepoName
}
backupPolicy.Spec.BackoffLimit = r.backupPolicy.BackoffLimit

r.syncBackupMethods(backupPolicy, comp)
r.syncBackupPolicyTargetSpec(backupPolicy, comp)
}
Expand Down
1 change: 1 addition & 0 deletions controllers/dataprotection/backuppolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (r *BackupPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request
}
return intctrlutil.Reconciled()
}

if err = patchStatus(dpv1alpha1.AvailablePhase, ""); err != nil {
return intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "")
}
Expand Down
13 changes: 13 additions & 0 deletions controllers/dataprotection/backuppolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

dpv1alpha1 "github.com/apecloud/kubeblocks/apis/dataprotection/v1alpha1"
"github.com/apecloud/kubeblocks/pkg/constant"
dptypes "github.com/apecloud/kubeblocks/pkg/dataprotection/types"
"github.com/apecloud/kubeblocks/pkg/generics"
testapps "github.com/apecloud/kubeblocks/pkg/testutil/apps"
testdp "github.com/apecloud/kubeblocks/pkg/testutil/dataprotection"
Expand Down Expand Up @@ -60,6 +61,18 @@ var _ = Describe("BackupPolicy Controller test", func() {
})

Context("create a backup policy", func() {
It("test backup policy without setting backoffLimit", func() {
By("creating backupPolicy without setting backoffLimit")
bp := testdp.NewFakeBackupPolicy(&testCtx, func(backupPolicy *dpv1alpha1.BackupPolicy) {
backupPolicy.Spec.BackoffLimit = nil
})
By("expect its backoffLimit should be set to the value of DefaultBackOffLimit")
Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(bp),
func(g Gomega, bp *dpv1alpha1.BackupPolicy) {
g.Expect(*bp.Spec.BackoffLimit).Should(Equal(dptypes.DefaultBackOffLimit))
})).Should(Succeed())
})

It("backup policy should be available for target", func() {
By("creating actionSet used by backup policy")
as := testdp.NewFakeActionSet(&testCtx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ spec:
are different versions of definitions of the same component.
properties:
backoffLimit:
default: 2
description: Specifies the maximum number of retry attempts
for a backup before it is considered a failure.
format: int32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ spec:
description: BackupPolicySpec defines the desired state of BackupPolicy
properties:
backoffLimit:
default: 2
description: Specifies the number of retries before marking the backup
as failed.
format: int32
Expand Down
Loading