patch_namespaced_deployment_scale returns None instead of 0 when scaling a deployment to 0 replicas
What happened (please include outputs or screenshots): After scaling down a deployment to 0 replicas using patch_namespaced_deployment_scale, the resulting V1ScaleSpec replicas is None instead of 0.
e.g. With this piece of code:
scale = _app_client.patch_namespaced_deployment_scale(<deployment-name>, <namespace>, body={'spec': {'replicas': 0}})
The resulting V1Scale.spec.replicas is supposed to return an Integer, but returns None instead.
What you expected to happen: V1Scale.spec.replicas should return an integer, even if the number of replicas is 0.
How to reproduce it (as minimally and precisely as possible):
- Create a deployment with N number of replicas
- Scale that deployment to 0 replicas using patch_namespaced_deployment_scale as shown above
- Capture the output of V1Scale.spec.replicas
Anything else we need to know?:
Environment:
- Kubernetes version (
kubectl version): v1.27.4 - OS (e.g., MacOS 10.13.6): ubuntu:22.04
- Python version (
python --version): 3.10.12 - Python client version (
pip list | grep kubernetes): 28.1.0 (Also reproducible with 27.2.0)
/assign @yliaog
patch_namespaced_deployment_scale is generated by open api generator, so the any fix needs to be at the generator.
for the particular question raised in this issue, what issue does returning None instead of 0 cause?
Hello @yliaog. Given the documentation for V1ScaleSpec https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1ScaleSpec.md replicas is supposed to be an integer.
While 0 is an integer and None is not, I assumed this was a bug. Of course I can addapt my code to this, but I think the current behaviour is not as straight forward as it should be, neither it matches the documentation.
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle stale - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle rotten - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Reopen this issue with
/reopen - Mark this issue as fresh with
/remove-lifecycle rotten - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
@k8s-triage-robot: Closing this issue, marking it as "Not Planned".
In response to this:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied- After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied- After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closedYou can:
- Reopen this issue with
/reopen- Mark this issue as fresh with
/remove-lifecycle rotten- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.