Skip to content

Commit

Permalink
Use image mapper in docker executor
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorjerse committed Dec 6, 2024
1 parent 2dd390f commit 5528f7d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Changed
- Fix stop null executor processing in the preparation phase
- Reduce the maximal number of threads for downolad data in the init container
- Respect image mapper in ``list_docker_images`` management command
- Use image mapper in docker executor

Fixed
-----
Expand Down
33 changes: 24 additions & 9 deletions resolwe/flow/executors/docker/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,17 @@ def _processing_volumes(self) -> Dict:
]
return dict([self._new_volume(*mount_point) for mount_point in mount_points])

def _map_docker_image(self, docker_image: str) -> str:
"""Transform the given Docker image according to the mapper.
If image starts with the prefix in the mapper keys, it is replaced with the
corresponding value. If no prefix matches, the image is returned unchanged.
"""
for prefix, replacement in SETTINGS.get("FLOW_DOCKER_IMAGE_MAPPER", {}).items():
if docker_image.startswith(prefix):
return replacement + docker_image[len(prefix) :]
return docker_image

async def start(self):
"""Start process execution."""
memory = (
Expand All @@ -316,16 +327,20 @@ async def start(self):
else:
network_mode = "none"

processing_image = self.requirements.get(
"image",
SETTINGS.get(
"FLOW_DOCKER_DEFAULT_PROCESSING_CONTAINER_IMAGE",
"public.ecr.aws/s4q6j6e8/resolwe/base:ubuntu-20.04",
),
processing_image = self._map_docker_image(
self.requirements.get(
"image",
SETTINGS.get(
"FLOW_DOCKER_DEFAULT_PROCESSING_CONTAINER_IMAGE",
"public.ecr.aws/s4q6j6e8/resolwe/base:ubuntu-20.04",
),
)
)
communicator_image = SETTINGS.get(
"FLOW_DOCKER_COMMUNICATOR_IMAGE",
"public.ecr.aws/s4q6j6e8/resolwe/com:latest",
communicator_image = self._map_docker_image(
SETTINGS.get(
"FLOW_DOCKER_COMMUNICATOR_IMAGE",
"public.ecr.aws/s4q6j6e8/resolwe/com:latest",
)
)
ulimits = []
if (
Expand Down

0 comments on commit 5528f7d

Please sign in to comment.