Skip to content

Commit

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

Automated cherry pick of #5095: Fix the bug in interpreting the replicas of Job
  • Loading branch information
karmada-bot authored Jun 27, 2024
2 parents 4daf7f0 + 8727194 commit 91d633d
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 91d633d

Please sign in to comment.