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

client.CoreV1Api.read_namespaced_pod(pod_name, pod_namespace) returning incomplete data for several minutes after pod is deployed #2201

Open
chickling123 opened this issue Feb 28, 2024 · 2 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@chickling123
Copy link

client.CoreV1Api.read_namespaced_pod(pod_name, pod_namespace) returns incomplete data for several minutes after pod is deployed if it is queried as soon as pod is deployed.

A bit more detail ...
I am deploying a pod and then immediately using the read_namespaced_pod method to determine the pod IP. Here is an outline of the code I am running. pod_ip is set to None for several minutes after the pod is deployed, and well after I can query the pod IP using kubectl describe pod <pod_name> . Presumably the read_namespaced_pod is returning a cached result that contains incomplete data.

pod = read_namespaced_pod(pod_name, pod_namespace)
pod_ip = pod.status.pod_ip

I've worked around this for now by inserting a 10s sleep after a pod is deployed before attempting to determine the pod_ip. That appears to be consistently working.

@chickling123 chickling123 added the kind/bug Categorizes issue or PR as related to a bug. label Feb 28, 2024
@showjason
Copy link
Contributor

Hi, I guess it's due to the pod status is not running, the network is creating and ip for this pod is not ready.
When the pod status is running, which means a certain ip has been assigned to the pod, meanwhile it also has been added to the pod status section and stored in etcd. After that you can run your code to get the pod ip.

@roycaihw
Copy link
Member

/assign @showjason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants