dstandish commented on PR #32249:
URL: https://github.com/apache/airflow/pull/32249#issuecomment-1644448058

   Ah yes thanks @jedcunningham 
   
   yeah tried this out locally (manually watching pods and messing with them).  
i guess the idea is to use the pod's deletion_timestamp metadata attr to 
determine whether it was actually deleted.
   
   seems it should work
   
   ```python
   from kubernetes import client, config, watch
   
   if __name__ == '__main__':
       config.load_kube_config()
       v1 = client.CoreV1Api()
   
       kwargs = {"label_selector": "airflow-worker=scheduler-1"}
   
       w = watch.Watch()
       for event in w.stream(v1.list_namespaced_pod, "default", **kwargs):
           print("Event: %s %s %s" % (event['type'], event['object'].kind, 
event['object'].metadata.name))
           if event['type'] == "DELETED":
               if event['object'].metadata.deletion_timestamp:
                   print("Pod was deleted")
               else:
                   print("Pod was not actually deleted")
   ```
   


-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to