kaxil commented on code in PR #29017:
URL: https://github.com/apache/airflow/pull/29017#discussion_r1081836212
##########
airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py:
##########
@@ -509,48 +535,154 @@ def execute(self, context: Context):
if self.do_xcom_push:
self.pod_manager.await_xcom_sidecar_container_start(pod=self.pod)
result = self.extract_xcom(pod=self.pod)
- remote_pod = self.pod_manager.await_pod_completion(self.pod)
+ self.remote_pod = self.pod_manager.await_pod_completion(self.pod)
finally:
self.cleanup(
pod=self.pod or self.pod_request_obj,
- remote_pod=remote_pod,
+ remote_pod=self.remote_pod,
)
ti = context["ti"]
ti.xcom_push(key="pod_name", value=self.pod.metadata.name)
ti.xcom_push(key="pod_namespace", value=self.pod.metadata.namespace)
if self.do_xcom_push:
return result
- def _read_pod_log_events(self, pod, *, reraise=True):
- """Will fetch and emit events from pod"""
- with _optionally_suppress(reraise=reraise):
- for event in self.pod_manager.read_pod_events(pod).items:
- self.log.error("Pod Event: %s - %s", event.reason,
event.message)
+ def execute_async(self, context: Context):
+ self.pod_request_obj = self.build_pod_request_obj(context)
+ self.pod = self.get_or_create_pod( # must set `self.pod` for `on_kill`
+ pod_request_obj=self.pod_request_obj,
+ context=context,
+ )
+ self.convert_config_file_to_dict()
+ self.invoke_defer_method()
+
+ def convert_config_file_to_dict(self):
+ """Converts passed config_file to dict format."""
+ config_file = self.config_file if self.config_file else
os.environ.get(KUBE_CONFIG_ENV_VAR)
+ if config_file:
+ with open(config_file) as f:
+ self._config_dict = yaml.safe_load(f)
+ else:
+ self._config_dict = None
+
+ def invoke_defer_method(self):
+ """Method to easily redefine triggers which are being used in child
classes."""
+ trigger_start_time = datetime.now(tz=pytz.UTC)
Review Comment:
nit: You can instead use `timezone.utcnow()`
https://github.com/apache/airflow/blob/5350be2194250366536db7f78b88dc8e49c9620e/airflow/utils/timezone.py#L55
--
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]