vincbeck commented on code in PR #75479:
URL: https://github.com/apache/airflow/pull/75479#discussion_r4630344897
##########
providers/google/src/airflow/providers/google/cloud/triggers/kubernetes_engine.py:
##########
@@ -135,30 +136,33 @@ def __init__(
self._ssl_ca_cert = ssl_ca_cert
def serialize(self) -> tuple[str, dict[str, Any]]:
+ kwargs: dict[str, Any] = {
+ "pod_name": self.pod_name,
+ "pod_namespace": self.pod_namespace,
+ "cluster_url": self._cluster_url,
+ "ssl_ca_cert": self._ssl_ca_cert,
+ "poll_interval": self.poll_interval,
+ "cluster_context": self.cluster_context,
+ "in_cluster": self.in_cluster,
+ "use_dns_endpoint": self.use_dns_endpoint,
+ "get_logs": self.get_logs,
+ "startup_timeout": self.startup_timeout,
+ "schedule_timeout": self.schedule_timeout,
+ "trigger_start_time": self.trigger_start_time,
+ "base_container_name": self.base_container_name,
+ "should_delete_pod": None,
+ "on_finish_action": self.on_finish_action.value,
+ "gcp_conn_id": self.gcp_conn_id,
+ "impersonation_chain": self.impersonation_chain,
+ "logging_interval": self.logging_interval,
+ "last_log_time": self.last_log_time,
+ "trigger_kwargs": self.trigger_kwargs,
+ }
+ if not self.log_events_on_startup:
Review Comment:
Any chance to reuse `super().serialize()` like `EksPodTrigger` does? This
block is now a copy of the base class logic, and the next parameter added to
`KubernetesPodTrigger` will get lost the same way.
##########
providers/amazon/tests/unit/amazon/aws/triggers/test_eks.py:
##########
@@ -439,6 +439,21 @@ def test_serialize_roundtrip(self):
assert classpath == classpath2
assert kwargs == kwargs2
+ def test_serialize_emits_log_events_on_startup_only_when_disabled(self):
Review Comment:
nit: same here, `test_serialize_roundtrip` could be parametrized on
`log_events_on_startup`.
##########
providers/amazon/tests/unit/amazon/aws/operators/test_eks.py:
##########
@@ -1499,6 +1499,38 @@ def test_invoke_defer_method_uses_eks_trigger(self,
mock_convert_config):
assert trigger._aws_conn_id == "aws_default"
assert trigger.pod_name == "test-pod-abc123"
assert trigger.pod_namespace == "default"
+ assert trigger.log_events_on_startup is True
+
+ @mock.patch(
+
"airflow.providers.cncf.kubernetes.operators.pod.KubernetesPodOperator.convert_config_file_to_dict"
+ )
+ def test_invoke_defer_method_passes_log_events_on_startup_to_trigger(self,
mock_convert_config):
Review Comment:
nit: this is almost a copy of `test_invoke_defer_method_uses_eks_trigger`,
can you parametrize that test instead, as you did for GKE?
##########
providers/cncf/kubernetes/docs/operators.rst:
##########
@@ -92,14 +92,10 @@ pods in one namespace this adds noticeable API server load.
Keeping unrelated high-churn pods (for example Spark executors) in a separate
namespace reduces the cost.
To turn it off, set ``log_events_on_startup=False``. The parameter is honoured
by ``KubernetesPodOperator``,
-``KubernetesPodTrigger``, ``@task.kubernetes`` and ``@task.kubernetes_cmd``.
In deferrable mode the opt-out
-is sent to the trigger, so the triggerer needs a provider version that knows
the parameter. ``GKEStartPodOperator`` and
-``EksPodOperator`` apply it in synchronous mode only; in deferrable mode their
own triggers do not receive
-it yet. It is separate from ``log_events_on_failure``, which controls the
one-shot read of events after a
-failure.
-
-.. Forwarding the parameter to the GKE and EKS triggers is tracked at
- https://github.com/apache/airflow/issues/75014
+``KubernetesPodTrigger``, ``@task.kubernetes`` and ``@task.kubernetes_cmd``,
as well as the ``GKEStartPodOperator``
+and ``EksPodOperator`` in both synchronous and deferrable mode. In deferrable
mode the opt-out
+is sent to the trigger, so the triggerer needs a provider version that knows
the parameter. It is separate
Review Comment:
nit: for `EksPodOperator` the triggerer also needs the new Amazon provider,
an older `EksPodTrigger` fails with a `TypeError` on this parameter. Should we
mention it?
##########
providers/google/src/airflow/providers/google/cloud/operators/kubernetes_engine.py:
##########
@@ -965,6 +965,7 @@ def invoke_defer_method(
last_log_time=last_log_time,
use_dns_endpoint=self.use_dns_endpoint,
trigger_kwargs=trigger_kwargs,
+ log_events_on_startup=self.log_events_on_startup,
Review Comment:
Not related to this PR but `startup_check_interval`, `on_kill_action` and
`termination_grace_period` are not forwarded to the trigger either, so
deferrable mode ignores them. Maybe worth a follow-up?
--
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]