Skip to content

Commit 7187d1d

Browse files
committed
Update DockerSwarmOperator auto_remove to align with DockerOperator
1 parent 5ff07fa commit 7187d1d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

providers/src/airflow/providers/docker/operators/docker_swarm.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ class DockerSwarmOperator(DockerOperator):
6060
If image tag is omitted, "latest" will be used.
6161
:param api_version: Remote API version. Set to ``auto`` to automatically
6262
detect the server's version.
63-
:param auto_remove: Auto-removal of the container on daemon side when the
64-
container's process exits.
65-
The default is False.
63+
:param auto_remove: Enable removal of the service when the service has terminated. Possible values:
64+
65+
- ``never``: (default) do not remove service
66+
- ``success``: remove on success
67+
- ``force``: always remove service
6668
:param command: Command to be run in the container. (templated)
6769
:param args: Arguments to the command.
6870
:param docker_url: URL of the host running the docker daemon.
@@ -221,12 +223,12 @@ def _run_service(self) -> None:
221223
if self.retrieve_output:
222224
return self._attempt_to_retrieve_results()
223225

224-
self.log.info("auto_removeauto_removeauto_removeauto_removeauto_remove : %s", str(self.auto_remove))
226+
self.log.info("auto_remove: %s", str(self.auto_remove))
225227
if self.service and self._service_status() != "complete":
226-
if self.auto_remove == "success":
228+
if self.auto_remove == "force":
227229
self.cli.remove_service(self.service["ID"])
228230
raise AirflowException(f"Service did not complete: {self.service!r}")
229-
elif self.auto_remove == "success":
231+
elif self.auto_remove in ["success", "force"]:
230232
if not self.service:
231233
raise RuntimeError("The 'service' should be initialized before!")
232234
self.cli.remove_service(self.service["ID"])

0 commit comments

Comments
 (0)