Skip to content

Conversation

@aeber
Copy link
Contributor

@aeber aeber commented Feb 10, 2025

According to 0 and 1 kube_statefulset_status_replicas returns "the number of Pods created by the StatefulSet controller". Therefore this alert only fires when the StatefulSet controller is able to create the pod, but it does not get ready.

In cases where the controller is unable to create the pod (e.g. invalid pod spec) this alert does not fire.
This is contrary to the expectation of firing when the statefulset does not match the configured amount of replicas.

According to [0] and [1] `kube_statefulset_status_replicas` returns
"the number of Pods created by the StatefulSet controller". Therefore
this alert only fires when the StatefulSet controller is able to create
the pod, but it does not get ready.

In cases where the controller is unable to create the pod (e.g. invalid
pod spec) this alert does not fire.
This is contrary to the expectation of firing when the statefulset does
not match the configured amount of replicas.

[0]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#statefulsetstatus-v1-apps
[1]: https://github.com/kubernetes/kube-state-metrics/blob/2a95d4649b2fea55799032fb9c0b571c4ba7f776/internal/store/statefulset.go#L75
@aeber aeber requested review from povilasv and skl as code owners February 10, 2025 14:26
@skl
Copy link
Collaborator

skl commented Feb 13, 2025

Thank you, @aeber. That was a very well-written description! Would you be interested in adding test cases for this alert KubeStatefulSetReplicasMismatch? It seems to be missing coverage:

I'm here to help if you have any questions.

@aeber
Copy link
Contributor Author

aeber commented Feb 14, 2025

I gave it a try, not sure if this is the right way to do it though.

I've added two test cases: one covering the old behavior and one demonstrating the issue that led to this PR. If there is anything i can improve, please let me know.

Copy link
Collaborator

@skl skl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@skl skl merged commit 4ff562d into kubernetes-monitoring:master Feb 14, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants