Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KPO xcom sidecar PodDefault usage #38951

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions airflow/providers/cncf/kubernetes/pod_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
rand_str,
)
from airflow.providers.cncf.kubernetes.pod_generator_deprecated import (
PodDefaults,
PodDefaults as PodDefaultsDeprecated,
PodGenerator as PodGeneratorDeprecated,
)
from airflow.utils import yaml
Expand Down Expand Up @@ -180,10 +180,10 @@ def add_xcom_sidecar(pod: k8s.V1Pod) -> k8s.V1Pod:
"""Add sidecar."""
pod_cp = copy.deepcopy(pod)
pod_cp.spec.volumes = pod.spec.volumes or []
pod_cp.spec.volumes.insert(0, PodDefaults.VOLUME)
pod_cp.spec.volumes.insert(0, PodDefaultsDeprecated.VOLUME)
pod_cp.spec.containers[0].volume_mounts = pod_cp.spec.containers[0].volume_mounts or []
pod_cp.spec.containers[0].volume_mounts.insert(0, PodDefaults.VOLUME_MOUNT)
pod_cp.spec.containers.append(PodDefaults.SIDECAR_CONTAINER)
pod_cp.spec.containers[0].volume_mounts.insert(0, PodDefaultsDeprecated.VOLUME_MOUNT)
pod_cp.spec.containers.append(PodDefaultsDeprecated.SIDECAR_CONTAINER)

return pod_cp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

from airflow.exceptions import AirflowException, RemovedInAirflow3Warning
from airflow.providers.cncf.kubernetes.kube_client import get_kube_client
from airflow.providers.cncf.kubernetes.pod_generator import PodDefaults
from airflow.providers.cncf.kubernetes.pod_generator import PodDefaultsDeprecated
from airflow.settings import pod_mutation_hook
from airflow.utils.log.logging_mixin import LoggingMixin
from airflow.utils.state import State
Expand Down Expand Up @@ -272,7 +272,7 @@ def _extract_xcom(self, pod: V1Pod):
self._client.connect_get_namespaced_pod_exec,
pod.metadata.name,
pod.metadata.namespace,
container=PodDefaults.SIDECAR_CONTAINER_NAME,
container=PodDefaultsDeprecated.SIDECAR_CONTAINER_NAME,
command=["/bin/sh"],
stdin=True,
stdout=True,
Expand All @@ -281,7 +281,7 @@ def _extract_xcom(self, pod: V1Pod):
_preload_content=False,
)
try:
result = self._exec_pod_command(resp, f"cat {PodDefaults.XCOM_MOUNT_PATH}/return.json")
result = self._exec_pod_command(resp, f"cat {PodDefaultsDeprecated.XCOM_MOUNT_PATH}/return.json")
self._exec_pod_command(resp, "kill -s SIGINT 1")
finally:
resp.close()
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/cncf/kubernetes/utils/pod_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.providers.cncf.kubernetes.callbacks import ExecutionMode, KubernetesPodOperatorCallback
from airflow.providers.cncf.kubernetes.pod_generator import PodDefaults
from airflow.providers.cncf.kubernetes.utils.xcom_sidecar import PodDefaults
jedcunningham marked this conversation as resolved.
Show resolved Hide resolved
from airflow.utils.log.logging_mixin import LoggingMixin
from airflow.utils.timezone import utcnow

Expand Down
4 changes: 2 additions & 2 deletions tests/providers/cncf/kubernetes/test_pod_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from airflow.exceptions import AirflowConfigException
from airflow.providers.cncf.kubernetes.executors.kubernetes_executor import PodReconciliationError
from airflow.providers.cncf.kubernetes.pod_generator import (
PodDefaults,
PodDefaultsDeprecated,
PodGenerator,
datetime_to_label_safe_datestring,
extend_object_field,
Expand Down Expand Up @@ -174,7 +174,7 @@ def test_gen_pod_extract_xcom(self, mock_rand_str, data_file):
container_two = {
"name": "airflow-xcom-sidecar",
"image": "alpine",
"command": ["sh", "-c", PodDefaults.XCOM_CMD],
"command": ["sh", "-c", PodDefaultsDeprecated.XCOM_CMD],
"volumeMounts": [{"name": "xcom", "mountPath": "/airflow/xcom"}],
"resources": {"requests": {"cpu": "1m"}},
}
Expand Down