hussein-awala commented on PR #40568:
URL: https://github.com/apache/airflow/pull/40568#issuecomment-2209627933

   > "why load the whole pod when you just need the status" is, i think, the 
idea.
   
   Unfortunately, in K8S, the pod status is the pod manifest, so the result of 
`read_namespaced_pod_status` is the same as `read_namespaced_pod` with the same 
performance/cost:
   ```python
   import time
   
   from kubernetes import client as k8s, config
   
   config.load_kube_config(context="minikube")
   client = k8s.ApiClient()
   api = k8s.CoreV1Api(client)
   
   namespace = "some namepsace"
   pod_name = "some pod"
   
   status = api.read_namespaced_pod_status(name=pod_name, namespace=namespace)
   pod = api.read_namespaced_pod(name=pod_name, namespace=namespace)
   print(pod == status)
   ``` 
   the output of this script is:
   ```python
   True
   ```
   
   > but i'm curious -- can you tell us more what you're talking about with the 
caching?
   
   We have a caching mechanism in `read_pod` method:
   ```python
       def read_pod(self):
           _now = utcnow()
           if (
               self.read_pod_cache is None
               or self.last_read_pod_at + 
timedelta(seconds=self.read_pod_cache_timeout) < _now
           ):
               self.read_pod_cache = self.pod_manager.read_pod(self.pod)
               self.last_read_pod_at = _now
           return self.read_pod_cache
   ```
   I didn't dive into the code to check if we use/need it, but between two 
methods that return the same result, and one of them has a cache mechanism, I 
prefer the one with caching.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to