Skip to content

Commit

Permalink
fix: pod replacement policy should be failed
Browse files Browse the repository at this point in the history
  • Loading branch information
buroa committed Aug 29, 2024
1 parent de72632 commit 2b22f62
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/upgrade/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
defaultKubectlImage = "rancher/kubectl:v1.30.3"
defaultImagePullPolicy = corev1.PullIfNotPresent
defaultTTLSecondsAfterFinished = int32(900)
defaultPodReplacementPolicy = batchv1.PodReplacementPolicy("TerminatingOrFailed")
)

func allowUserDefinedSecurityContext(defaultValue bool) bool {
Expand Down Expand Up @@ -111,6 +112,13 @@ var (
}
return defaultValue
}(defaultTTLSecondsAfterFinished)

PodReplacementPolicy = func(defaultValue batchv1.PodReplacementPolicy) batchv1.PodReplacementPolicy {
if str := os.Getenv("SYSTEM_UPGRADE_JOB_POD_REPLACEMENT_POLICY"); str != "" {
return batchv1.PodReplacementPolicy(str)
}
return defaultValue
}(defaultPodReplacementPolicy)
)

var (
Expand Down Expand Up @@ -160,6 +168,7 @@ func New(plan *upgradeapiv1.Plan, node *corev1.Node, controllerName string) *bat
Labels: jobLabels,
},
Spec: batchv1.JobSpec{
PodReplacementPolicy: &PodReplacementPolicy,
BackoffLimit: &BackoffLimit,
TTLSecondsAfterFinished: &TTLSecondsAfterFinished,
Template: corev1.PodTemplateSpec{
Expand Down

0 comments on commit 2b22f62

Please sign in to comment.