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

Operator assumes all pods are ready when there are no pods at all #126

Closed
colega opened this issue Jan 24, 2024 · 0 comments · Fixed by #127
Closed

Operator assumes all pods are ready when there are no pods at all #126

colega opened this issue Jan 24, 2024 · 0 comments · Fixed by #127
Labels
bug Something isn't working

Comments

@colega
Copy link
Contributor

colega commented Jan 24, 2024

We're currently checking hasStatefulSetNotReadyPods before considering the zone reconciled:

func (c *RolloutController) hasStatefulSetNotReadyPods(sts *v1.StatefulSet) (bool, error) {
// We can quickly check the number of ready replicas reported by the StatefulSet.
// If they don't match the total number of replicas, then we're sure there are some
// not ready pods.
if sts.Status.Replicas != sts.Status.ReadyReplicas {
return true, nil
}
// The number of ready replicas reported by the StatefulSet matches the total number of
// replicas. However, there's still no guarantee that all pods are running. For example,
// a terminating pod (which we don't consider "ready") may have not yet failed the
// readiness probe for the consecutive number of times required to switch its status
// to not-ready. For this reason, we list all StatefulSet pods and check them one-by-one.
notReadyPods, err := c.listNotReadyPodsByStatefulSet(sts)
if err != nil {
return false, err
}
if len(notReadyPods) == 0 {
return false, nil
}
// Log which pods have been detected as not-ready. This may be useful for debugging.
level.Info(c.logger).Log(
"msg", "StatefulSet status is reporting all pods ready, but the rollout operator has found some not-Ready pods",
"statefulset", sts.Name,
"not_ready_pods", strings.Join(util.PodNames(notReadyPods), " "))
return true, nil
}

However, we've seen a case where all pods of a statefulset were deleted, but no new pods were created yet. This caused the listNotReadyPodsByStatefulSet method return no pods at all, as there were no pods in any state.

This caused an outage, as next zone was terminated immediately, before no pods were available in the first one.

I think that the code should check that there are at least as many pods as replicas desired by the statefulset, and then it should check whether some of them are unready.

@colega colega added the bug Something isn't working label Jan 24, 2024
colega added a commit that referenced this issue Jan 24, 2024
If all pods are missing, we can't say there are no "not ready pods".

Fixes: #126

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
colega added a commit that referenced this issue Jan 25, 2024
* Consider missing pods as not ready

If all pods are missing, we can't say there are no "not ready pods".

Fixes: #126

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Rename method

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Move the comment

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Update CHANGELOG.md

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* fmt

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

---------

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant