Skip to content

work's replicas set to 0 while resource template' replicas >0 and rb.spec.cluster is not nil #6361

@CharlesQQ

Description

@CharlesQQ

What happened:
To prevent extreme situations, when the number of replias of the resource template is zero in the scheduler, the number of replicas of the member cluster remains unchanged (implemented by a custom scheduler)

The problem is: now when workload.spec.replicas = 0, rb.spec.cluster > 0, the number of member cluster replicas all becomes zero;
Under normal circumstances, the number of member cluster replicas should be consistent with that in rb.spec.cluster, which is obviously not the case here

rb.spec.cluster
Image

work object

Image

Here only resource template replicas's >0, rb.spec.cluster will be merged to workload.

if needReviseReplicas(bindingSpec.Replicas, bindingSpec.Placement) {
if resourceInterpreter.HookEnabled(clonedWorkload.GroupVersionKind(), configv1alpha1.InterpreterOperationReviseReplica) {
clonedWorkload, err = resourceInterpreter.ReviseReplica(clonedWorkload, int64(targetCluster.Replicas))
if err != nil {
klog.Errorf("Failed to revise replica for %s/%s/%s in cluster %s, err is: %v",
workload.GetKind(), workload.GetNamespace(), workload.GetName(), targetCluster.Name, err)
errs = append(errs, err)
continue

func needReviseReplicas(replicas int32, placement *policyv1alpha1.Placement) bool {
return replicas > 0 && placement != nil && placement.ReplicaSchedulingType() == policyv1alpha1.ReplicaSchedulingTypeDivided
}

What you expected to happen:

work object's replias must same as rb.spec.cluster info

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

  • Karmada version:
  • kubectl-karmada or karmadactl version (the result of kubectl-karmada version or karmadactl version):
  • Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions