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

removed usage of deprecated function for naming the pod in provider k8s pod.py #38638

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def create_unique_id(
name += task_id
base_name = slugify(name, lowercase=True)[:max_length].strip(".-")
if unique:
return add_pod_suffix(pod_name=base_name, rand_len=8, max_len=max_length)
return add_unique_suffix(name=base_name, rand_len=8, max_len=max_length)
else:
return base_name

Expand Down
8 changes: 4 additions & 4 deletions airflow/providers/cncf/kubernetes/operators/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
from airflow.providers.cncf.kubernetes.hooks.kubernetes import KubernetesHook
from airflow.providers.cncf.kubernetes.kubernetes_helper_functions import (
POD_NAME_MAX_LENGTH,
add_pod_suffix,
create_pod_id,
add_unique_suffix,
create_unique_id,
)
from airflow.providers.cncf.kubernetes.pod_generator import PodGenerator
from airflow.providers.cncf.kubernetes.triggers.pod import KubernetesPodTrigger
Expand Down Expand Up @@ -1049,12 +1049,12 @@ def build_pod_request_obj(self, context: Context | None = None) -> k8s.V1Pod:
pod = PodGenerator.reconcile_pods(pod_template, pod)

if not pod.metadata.name:
pod.metadata.name = create_pod_id(
pod.metadata.name = create_unique_id(
task_id=self.task_id, unique=self.random_name_suffix, max_length=POD_NAME_MAX_LENGTH
)
elif self.random_name_suffix:
# user has supplied pod name, we're just adding suffix
pod.metadata.name = add_pod_suffix(pod_name=pod.metadata.name)
pod.metadata.name = add_unique_suffix(name=pod.metadata.name)

if not pod.metadata.namespace:
hook_namespace = self.hook.get_namespace()
Expand Down
3 changes: 2 additions & 1 deletion airflow/providers/cncf/kubernetes/pod_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from airflow.providers.cncf.kubernetes.kubernetes_helper_functions import (
POD_NAME_MAX_LENGTH,
add_pod_suffix,
add_unique_suffix,
rand_str,
)
from airflow.providers.cncf.kubernetes.pod_generator_deprecated import (
Expand Down Expand Up @@ -397,7 +398,7 @@ def construct_pod(
UserWarning,
stacklevel=2,
)
pod_id = add_pod_suffix(pod_name=pod_id, max_len=POD_NAME_MAX_LENGTH)
pod_id = add_unique_suffix(name=pod_id, max_len=POD_NAME_MAX_LENGTH)
try:
image = pod_override_object.spec.containers[0].image # type: ignore
if not image:
Expand Down