You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by am...@apache.org on 2026/07/21 04:46:36 UTC

(airflow) branch main updated: Remove airflow.utils dependency from Docker provider (#69900)

This is an automated email from the ASF dual-hosted git repository.

amoghrajesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 1e7e525b00e Remove airflow.utils dependency from Docker provider (#69900)
1e7e525b00e is described below

commit 1e7e525b00ea8f4b1fa26d9d6337807c28c51129
Author: Shae Alhusayni <sh...@gmail.com>
AuthorDate: Mon Jul 20 21:46:25 2026 -0700

    Remove airflow.utils dependency from Docker provider (#69900)
---
 .../src/airflow/providers/docker/operators/docker_swarm.py    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/providers/docker/src/airflow/providers/docker/operators/docker_swarm.py b/providers/docker/src/airflow/providers/docker/operators/docker_swarm.py
index 3eb5db64c55..539cb1c2f7a 100644
--- a/providers/docker/src/airflow/providers/docker/operators/docker_swarm.py
+++ b/providers/docker/src/airflow/providers/docker/operators/docker_swarm.py
@@ -18,8 +18,10 @@
 
 from __future__ import annotations
 
+import random
 import re
 import shlex
+import string
 from datetime import datetime
 from time import sleep
 from typing import TYPE_CHECKING, Literal
@@ -29,12 +31,17 @@ from docker.errors import APIError
 
 from airflow.providers.common.compat.sdk import AirflowException
 from airflow.providers.docker.operators.docker import DockerOperator
-from airflow.utils.strings import get_random_string
 
 if TYPE_CHECKING:
     from airflow.providers.common.compat.sdk import Context
 
 
+def _generate_service_name(prefix: str) -> str:
+    """Generate a unique Docker Swarm service name."""
+    suffix = "".join(random.choices(string.ascii_letters + string.digits, k=8))
+    return f"{prefix}-{suffix}"
+
+
 class DockerSwarmOperator(DockerOperator):
     """
     Execute a command as an ephemeral docker swarm service.
@@ -191,7 +198,7 @@ class DockerSwarmOperator(DockerOperator):
                 placement=self.placement,
                 log_driver=self.log_driver_config,
             ),
-            name=f"{self.service_prefix}-{get_random_string()}",
+            name=_generate_service_name(self.service_prefix),
             labels={"name": f"airflow__{self.dag_id}__{self.task_id}"},
             mode=self.mode,
         )