...
1
16
17 package job
18
19 import (
20 "context"
21 "fmt"
22
23 "k8s.io/apimachinery/pkg/util/validation/field"
24 "k8s.io/kubernetes/pkg/api/pod"
25 "k8s.io/kubernetes/pkg/apis/batch"
26 "k8s.io/kubernetes/pkg/apis/core"
27 "k8s.io/utils/ptr"
28 )
29
30 const (
31 completionsSoftLimit = 100_000
32 parallelismSoftLimitForUnlimitedCompletions = 10_000
33 )
34
35
36 func WarningsForJobSpec(ctx context.Context, path *field.Path, spec, oldSpec *batch.JobSpec) []string {
37 var warnings []string
38 if spec.CompletionMode != nil && *spec.CompletionMode == batch.IndexedCompletion {
39 completions := ptr.Deref(spec.Completions, 0)
40 parallelism := ptr.Deref(spec.Parallelism, 0)
41 if completions > completionsSoftLimit && parallelism > parallelismSoftLimitForUnlimitedCompletions {
42 msg := "In Indexed Jobs with a number of completions higher than 10^5 and a parallelism higher than 10^4, Kubernetes might not be able to track completedIndexes when a big number of indexes fail"
43 warnings = append(warnings, fmt.Sprintf("%s: %s", path, msg))
44 }
45 }
46 var oldPodTemplate *core.PodTemplateSpec
47 if oldSpec != nil {
48 oldPodTemplate = &oldSpec.Template
49 }
50 warnings = append(warnings, pod.GetWarningsForPodTemplate(ctx, path.Child("template"), &spec.Template, oldPodTemplate)...)
51 return warnings
52 }
53
View as plain text