Fix the bug in interpreting the replicas of Job
Signed-off-by: whitewindmills <jayfantasyhjh@gmail.com>
This commit is contained in:
parent
1255a08f5d
commit
bf9eaf05ec
|
@ -23,6 +23,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
|
||||
"github.com/karmada-io/karmada/pkg/util"
|
||||
|
@ -86,6 +87,13 @@ func jobReplica(object *unstructured.Unstructured) (int32, *workv1alpha2.Replica
|
|||
if job.Spec.Parallelism != nil {
|
||||
replica = *job.Spec.Parallelism
|
||||
}
|
||||
// For fixed completion count Jobs, the actual number of pods running in parallel will not exceed the number of remaining completions.
|
||||
// Higher values of .spec.parallelism are effectively ignored.
|
||||
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/job/
|
||||
completions := ptr.Deref[int32](job.Spec.Completions, replica)
|
||||
if replica > completions {
|
||||
replica = completions
|
||||
}
|
||||
requirement := helper.GenerateReplicaRequirements(&job.Spec.Template)
|
||||
|
||||
return replica, requirement, nil
|
||||
|
|
Loading…
Reference in New Issue