Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] cloneset 发布的实例数与灰度比例不符 #1545

Closed
qswksp opened this issue Mar 27, 2024 · 2 comments
Closed

[BUG] cloneset 发布的实例数与灰度比例不符 #1545

qswksp opened this issue Mar 27, 2024 · 2 comments
Assignees
Labels
kind/bug Something isn't working

Comments

@qswksp
Copy link
Contributor

qswksp commented Mar 27, 2024

What happened: 一个 cloneset 的副本数设置为 4,灰度比例设置为 50%,出现了发布 3 个实例的情况

What you expected to happen: 副本数为 4,灰度比例为 50%,期望发布 2 个实例

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

  1. 首先将一个 cloneset 的副本数设置为 2,以灰度比例 50% 发布新版本,此时会得到 1 个新实例 1 个旧实例
  2. 删除步骤 1 中旧的那个实例
  3. 删除步骤 1 中新的那个实例,然后立即将 clonset 的副本数调整为 4
  4. 此时会得到 3 个新实例,1 个旧实例,与 50% 的灰度比例不符

Anything else we need to know?:

Environment:

  • Kruise version: v1.1
  • Kubernetes version (use kubectl version): client-go v0.20.2
  • Install details (e.g. helm install args):
  • Others: yaml 截图
image
@qswksp qswksp added the kind/bug Something isn't working label Mar 27, 2024
@zmberg zmberg assigned qswksp and unassigned FillZpp and zmberg Mar 27, 2024
@zmberg
Copy link
Member

zmberg commented Mar 27, 2024

@furykerry @Perlife I know why.

  1. Create cloneSet replicas=2, partition=50%
  2. Update image v2, and currently there have 1 v1 pod and 1 v2 pod.
  3. Delete v1 pod, and CloneSet controller will update status currentRevision=updateRevision, as follows:
status:
    availableReplicas: 1
    collisionCount: 0
    currentRevision: sample-58c8f45749
    expectedUpdatedReplicas: 1
    labelSelector: app=sample
    observedGeneration: 2
    readyReplicas: 1
    replicas: 1
    updateRevision: sample-58c8f45749
    updatedAvailableReplicas: 1
    updatedReadyReplicas: 1
    updatedReplicas: 1
  1. Then scale up replicas=4, kruise will create 2 v2 pods.

Cause analysis:
The third step above is actually wrong, currentRevision and updateRevision should not be equal in the batch process. It is because of the following code judgment error:
image

I think it should be judged as follows:

if newStatus.UpdatedReplicas == *cs.Spec.Replicas && newStatus.UpdatedReplicas == newStatus.Replicas {
         newStatus.CurrentRevision = newStatus.UpdateRevision
}

The failed pr: #501

@qswksp
Copy link
Contributor Author

qswksp commented Mar 27, 2024

Very clear, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants