python icon indicating copy to clipboard operation
python copied to clipboard

Calling NetworkingV1Api().list_namespaced_ingress(namespace=namespace) raises 404 error instead of empty list

Open ckkz-it opened this issue 3 years ago • 7 comments

What happened (please include outputs or screenshots): The call to method list_namespaced_ingress() of NetworkingV1Api is raising 404 error. image

What you expected to happen: It should return an empty list, as other list methods do (e.g. list_namespaced_config_map, list_namespaced_deployment, list_namespaced_horizontal_pod_autoscaler, etc)

How to reproduce it (as minimally and precisely as possible): Call NetworkingV1Api().list_namespaced_ingress(namespace=...) for a namespace that doesn't have ingresses. In my case, it was the default namespace.

Anything else we need to know?: Running inside GitHub Actions.

Environment:

  • Kubernetes version (kubectl version): -
  • OS (e.g., MacOS 10.13.6): Ubuntu 20.04
  • Python version (python --version): 3.10.2
  • Python client version (pip list | grep kubernetes): 21.7.0

ckkz-it avatar Feb 23 '22 16:02 ckkz-it

Hi @ckkz-it , please try this script and it's working in my cluster.

from kubernetes import client, config


def main():

    config.load_kube_config()
    net_api = client.NetworkingV1Api()
    print(net_api.list_namespaced_ingress("default"))


if __name__ == "__main__":
    main()

showjason avatar Feb 24 '22 02:02 showjason

Hi @showjason, thanks for the answer.

Looks like this occurs sometimes even if we have ingresses in the default namespace, but I don't have exact steps for reproducing the issue. I'll try to update once we will have more info.

ckkz-it avatar Feb 25 '22 13:02 ckkz-it

cc @roycaihw

roycaihw avatar Feb 28 '22 17:02 roycaihw

Thanks @showjason @ckkz-it. Yes please let us know when you have more info.

roycaihw avatar Feb 28 '22 17:02 roycaihw

i try this script but this error

kubernetes.client.exceptions.ApiException: (404) Reason: Not Found HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 07 Apr 2022 03:04:39 GMT', 'Content-Length': '174'}) HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"the server could not find the requested resource","reason":"NotFound","details":{},"code":404}

zxl00 avatar Apr 07 '22 03:04 zxl00

kubernetes 版本和 kubernetes-client 版本不匹配,换成匹配的版本可以解决问题。

client 9.y.z: Kubernetes 1.12 or below (+-), Kubernetes 1.13 (✓), Kubernetes 1.14 or above (+-) client 10.y.z: Kubernetes 1.13 or below (+-), Kubernetes 1.14 (✓), Kubernetes 1.14 or above (+-) client 11.y.z: Kubernetes 1.14 or below (+-), Kubernetes 1.15 (✓), Kubernetes 1.16 or above (+-) client 12.y.z: Kubernetes 1.15 or below (+-), Kubernetes 1.16 (✓), Kubernetes 1.17 or above (+-) client 17.y.z: Kubernetes 1.16 or below (+-), Kubernetes 1.17 (✓), Kubernetes 1.18 or above (+-) client 18.y.z: Kubernetes 1.17 or below (+-), Kubernetes 1.18 (✓), Kubernetes 1.19 or above (+-) client 19.y.z: Kubernetes 1.18 or below (+-), Kubernetes 1.19 (✓), Kubernetes 1.20 or above (+-) client 20.y.z: Kubernetes 1.19 or below (+-), Kubernetes 1.20 (✓), Kubernetes 1.21 or above (+-) client 21.y.z: Kubernetes 1.20 or below (+-), Kubernetes 1.21 (✓), Kubernetes 1.22 or above (+-) client 22.y.z: Kubernetes 1.21 or below (+-), Kubernetes 1.22 (✓), Kubernetes 1.23 or above (+-) client 23.y.z: Kubernetes 1.22 or below (+-), Kubernetes 1.23 (✓), Kubernetes 1.24 or above (+-)

moyanach avatar Jun 06 '22 09:06 moyanach

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs 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 or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR 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 Sep 04 '22 10:09 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs 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 or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR 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 Oct 04 '22 10:10 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 Nov 03 '22 11:11 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 Nov 03 '22 11:11 k8s-ci-robot