kaxil commented on a change in pull request #7507: [AIRFLOW-6885] Delete worker 
on success
URL: https://github.com/apache/airflow/pull/7507#discussion_r382946219
 
 

 ##########
 File path: airflow/executors/kubernetes_executor.py
 ##########
 @@ -848,10 +850,13 @@ def sync(self) -> None:
 
     def _change_state(self, key: TaskInstanceKeyType, state: Optional[str], 
pod_id: str) -> None:
         if state != State.RUNNING:
-            if self.kube_config.delete_worker_pods:
+            if self.kube_config.delete_on_success and state is State.SUCCESS:
                 if not self.kube_scheduler:
                     raise AirflowException(NOT_STARTED_MESSAGE)
                 self.kube_scheduler.delete_pod(pod_id)
+            elif self.kube_config.delete_worker_pods:
+                if not self.kube_scheduler:
+                    raise AirflowException(NOT_STARTED_MESSAGE)
                 self.log.info('Deleted pod: %s', str(key))
 
 Review comment:
   ```suggestion
                   self.kube_scheduler.delete_pod(pod_id)
                   self.log.info('Deleted pod: %s', str(key))
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to