python icon indicating copy to clipboard operation
python copied to clipboard

patch_namespaced_deployment_scale returns None instead of 0 when scaling a deployment to 0 replicas

Open dandres-stratio opened this issue 2 years ago • 4 comments

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)

dandres-stratio avatar Oct 10 '23 10:10 dandres-stratio

/assign @yliaog

roycaihw avatar Oct 23 '23 16:10 roycaihw

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?

yliaog avatar Oct 27 '23 17:10 yliaog

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.

dandres-stratio avatar Oct 30 '23 08:10 dandres-stratio

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar Jan 31 '24 09:01 k8s-triage-robot

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar Mar 01 '24 10:03 k8s-triage-robot

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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 avatar Mar 31 '24 11:03 k8s-triage-robot

@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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

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.

k8s-ci-robot avatar Mar 31 '24 11:03 k8s-ci-robot