Sinsin1367 commented on a change in pull request #6261: [AIRFLOW-5141] Added 
optional resource usage logging to KubernetesPod…
URL: https://github.com/apache/airflow/pull/6261#discussion_r331702649
 
 

 ##########
 File path: airflow/kubernetes/pod_launcher.py
 ##########
 @@ -116,9 +124,27 @@ def run_pod(
                 time.sleep(1)
             self.log.debug('Pod not yet started')
 
-        return self._monitor_pod(pod, get_logs)
+        return self._monitor_pod(pod,
+                                 get_logs,
+                                 get_resource_usage_logs,
+                                 resource_usage_fetch_interval,
+                                 resource_usage_log_interval)
 
-    def _monitor_pod(self, pod: V1Pod, get_logs: bool) -> Tuple[State, 
Optional[str]]:
+    def _monitor_pod(self,
+                     pod: V1Pod,
+                     get_logs: bool,
+                     get_resource_usage_logs: bool,
+                     resource_usage_fetch_interval: int,
+                     resource_usage_log_interval: int) -> Tuple[State, 
Optional[str]]:
+        # Initialize the resource monitoring thread to do nothing.
+        resource_monitoring_thread = threading.Thread(target=lambda: None)
+        if get_resource_usage_logs:
+            metric_server_logger = PodUsageMetricsLogger(self,
 
 Review comment:
   Right now the logger object keeps a reference of the pod_launcher object to 
be able to call pod_is_running method to know when to finish making api calls. 
A cleaner way would be separating the pod status monitoring (like 
pod_is_running method) into a separate pod status util class so that all others 
can use without keeping pod_launcher. I can implement this util class and move 
the status methods out of pod_launcher if committers agree it is a cleaner 
implementation. 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to