Skip to content

Commit

Permalink
fix unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pooknull committed Dec 18, 2024
1 parent 57b343e commit 450fbd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions internal/controller/postgrescluster/pgbackrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -864,8 +865,14 @@ func generateBackupJobSpecIntent(ctx context.Context, postgresCluster *v1beta1.P
// K8SPG-619: Set RestartPolicy to "OnFailure" (by default) to handle potential delays in establishing communication with the Kubernetes API.
// The container will be restarted until the BackoffLimit is reached to handle these delays.
jobSpec.Template.Spec.RestartPolicy = postgresCluster.Spec.Backups.PGBackRest.Jobs.RestartPolicy
if jobSpec.Template.Spec.RestartPolicy == "" {
jobSpec.Template.Spec.RestartPolicy = corev1.RestartPolicyOnFailure
}
// K8SPG-619: The job container will try to restart with increasing delays (10s, 20s) before failing.
jobSpec.BackoffLimit = postgresCluster.Spec.Backups.PGBackRest.Jobs.BackoffLimit
if jobSpec.BackoffLimit == nil {
jobSpec.BackoffLimit = ptr.To(int32(2))
}
}

// Set the image pull secrets, if any exist.
Expand Down
2 changes: 1 addition & 1 deletion percona/controller/pgcluster/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ var _ = Describe("Watching secrets", Ordered, func() {
}

return false
}, time.Second*30, time.Millisecond*250).Should(Equal(true))
}, time.Second*60, time.Millisecond*250).Should(Equal(true))
reconcileCount = getReconcileCount(crunchyR)
})
})
Expand Down

0 comments on commit 450fbd4

Please sign in to comment.