Skip to content

Commit

Permalink
Merge pull request #5107 from whitewindmills/automated-cherry-pick-of…
Browse files Browse the repository at this point in the history
…-#5095-upstream-release-1.9

Automated cherry pick of #5095: Fix the bug in interpreting the replicas of Job
  • Loading branch information
karmada-bot committed Jun 27, 2024
2 parents 283a8a8 + 26eabda commit fdfd304
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/resourceinterpreter/default/native/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/pointer"

workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
"github.com/karmada-io/karmada/pkg/util"
Expand Down Expand Up @@ -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 := pointer.Int32Deref(job.Spec.Completions, replica)
if replica > completions {
replica = completions
}
requirement := helper.GenerateReplicaRequirements(&job.Spec.Template)

return replica, requirement, nil
Expand Down

0 comments on commit fdfd304

Please sign in to comment.