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

StatefulSet using OnDelete update strategy have stale currentRevision #1242

Open
ebensom opened this issue Feb 24, 2025 · 3 comments
Open

StatefulSet using OnDelete update strategy have stale currentRevision #1242

ebensom opened this issue Feb 24, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@ebensom
Copy link
Contributor

ebensom commented Feb 24, 2025

The vmoperator manages the StatefulSets belonging to VMClusters and VMAlertmanagers using OnDelete updateStrategy.type. In such case, K8s statefulset controller does not update the status.currentRevision to the value of status.updateRevision when the last pod was successfully deleted and hence updated to the current controllerrevision. This cause stale information to be exposed in the status block, and moreover the currentReplicas to be missing:

status:
  availableReplicas: 6
  collisionCount: 0
  currentRevision: vmstorage-skr-697c996f7b
  observedGeneration: 38
  readyReplicas: 6
  replicas: 6
  updateRevision: vmstorage-skr-74c4bd7697
  updatedReplicas: 6

vmoperator could patch the statefulset/status subresource to have the currentRevision equal to the updateRevision when the last pod is deleted.

@Haleygo
Copy link
Contributor

Haleygo commented Feb 25, 2025

Hi @ebensom ,
Could you elaborate why you want to update the currentRevision to updateRevision?
Or, why not set updateStrategy: RollingUpdate if you need the correct currentRevision?
As I can see, k8s doesn't attempt to update it for statefulset with updateStrategy: OnDelete.

@Haleygo Haleygo added enhancement New feature or request question Further information is requested labels Feb 25, 2025
@Haleygo Haleygo self-assigned this Feb 25, 2025
@ebensom
Copy link
Contributor Author

ebensom commented Feb 25, 2025

Hi @Haleygo ,

You are right, I see the updateStrategy of vmstorage, vmselect, etc. can be changed. May I ask why the default OnDelete strategy was chosen, i.e. why vmoperator handles manually the statefulsert pod deletions during reconciliation?

Yes, I'm aware of the long outstanding kubernetes/kubernetes#106055 issue, and there the consensus is that K8s will not (and never in the future) update the currentRevision for when updateStrategy: OnDelete is used. Hence my original question/suggestion, because when it comes to the statefulsets owned by CRs managed by vmoperator, this seems like the responsibility of the vmoperator to patch the currentRevision when updateStrategy: OnDelete is used.

However if you say it's absolutely OK to use RollingUpdate strategy with VMCluster components instead of the default OnDelete, we will adjust accordingly.

@Haleygo
Copy link
Contributor

Haleygo commented Feb 26, 2025

May I ask why the default OnDelete strategy was chosen, i.e. why vmoperator handles manually the statefulsert pod deletions during reconciliation?

You can find the differences in rolling updates between vm-operator and Kubernetes at #389 (comment).
Basically, we think vm-operator can do better than kubernetes, and we allow user to choose.

Yes, I'm aware of the long outstanding kubernetes/kubernetes#106055 issue, and there the consensus is that K8s will not (and never in the future) update the currentRevision for when updateStrategy: OnDelete is used. Hence my original question/suggestion, because when it comes to the statefulsets owned by CRs managed by vmoperator, this seems like the responsibility of the vmoperator to patch the currentRevision when updateStrategy: OnDelete is used.

I'm unsure if the currentRevision needs to be accurate in this case, like you said, Kubernetes allows it to be incorrect for updateStrategy: OnDelete. That's why I asked why you want it updated.
If we update the currentRevision, it must happen after all pods finish updating. It requires an additional update call and we try to avoid unnecessary update to ease pressure on API server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants