manta-node 0.5b0.dev254__py3-none-any.whl → 0.5b0.dev259__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ from datetime import datetime
2
2
 
3
3
  from aiodocker import Docker
4
4
  from aiodocker.docker import DockerContainer
5
+ from aiodocker.exceptions import DockerError
5
6
  from docker import DockerClient
6
7
  from manta_common.errors import MantaDockerError
7
8
  from manta_common.traces import Tracer
@@ -16,6 +17,10 @@ class DockerRaiser:
16
17
  """
17
18
  Start, pull or run a container
18
19
 
20
+ If the image is missing locally, Docker raises a 404 "No such
21
+ image" error on container creation. In that case the image is
22
+ pulled from the registry and the run is retried once.
23
+
19
24
  Parameters
20
25
  ----------
21
26
  config : dict
@@ -29,17 +34,41 @@ class DockerRaiser:
29
34
  Raises
30
35
  ------
31
36
  MantaDockerError
32
- Cannot run container
37
+ Cannot run container, or the missing image could not be pulled
33
38
  """
34
- container = None
35
39
  try:
36
- container = await self.async_client.containers.run(config)
40
+ return await self.async_client.containers.run(config)
41
+ except DockerError as exc:
42
+ image = config.get("Image")
43
+ # exc.message can be None/non-str on a bodiless or malformed Docker
44
+ # error response — guard so we never raise an uncaught AttributeError
45
+ # that escapes this function's MantaDockerError-only contract.
46
+ if (
47
+ exc.status == 404
48
+ and image
49
+ and "no such image" in str(exc.message or "").lower()
50
+ ):
51
+ self.tracer.info(f"Image {image} not found locally, pulling...")
52
+ await self.pull_image_or_raise(image)
53
+ else:
54
+ self.tracer.error("Task cannot be started")
55
+ raise MantaDockerError(
56
+ "Task cannot be started", metadata=self.tracer.metadata
57
+ ) from exc
58
+ except Exception as exc:
59
+ self.tracer.error("Task cannot be started")
60
+ raise MantaDockerError(
61
+ "Task cannot be started", metadata=self.tracer.metadata
62
+ ) from exc
63
+
64
+ # Image has been pulled; retry the run once before giving up.
65
+ try:
66
+ return await self.async_client.containers.run(config)
37
67
  except Exception as exc:
38
68
  self.tracer.error("Task cannot be started")
39
69
  raise MantaDockerError(
40
70
  "Task cannot be started", metadata=self.tracer.metadata
41
71
  ) from exc
42
- return container
43
72
 
44
73
  async def pull_image_or_raise(self, image: str):
45
74
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: manta_node
3
- Version: 0.5b0.dev254
3
+ Version: 0.5b0.dev259
4
4
  Summary: Node side software of the Manta platform. It is responsible for the communication with the Manta Core and the execution of the tasks.
5
5
  Author-email: Hugo Miralles <hugomiralles@manta-tech.io>, Matthew Thompson <matthew.thompson@manta-tech.io>
6
6
  License: GNU AFFERO GENERAL PUBLIC LICENSE
@@ -21,7 +21,7 @@ manta_node/infrastructure/__init__.py,sha256=yM60jKhdaD18BOsLb-0aR9D2XxGvrTnV92o
21
21
  manta_node/infrastructure/config/__init__.py,sha256=VnKidPAVfzlZMb5WM-MggtsDLM8tdAFFWlB7WSiawzc,617
22
22
  manta_node/infrastructure/config/node_config_manager.py,sha256=u9ga_z7EQ775wkgCVOT0oY4o2uYjAjhCzR1BZmmtNZ0,30605
23
23
  manta_node/infrastructure/container/__init__.py,sha256=EO4SndUwmXrHczM4qkleUbxC7lTGz3c3Hd3iGrPg6D8,262
24
- manta_node/infrastructure/container/docker_adapter.py,sha256=-9_J_7QUr10BZn3xwPn4CzhEGKWqa2XdY9nld-5yOTA,6958
24
+ manta_node/infrastructure/container/docker_adapter.py,sha256=v6tbwSyZp1eGe-rZUat-Y2vSNUKc3kz6zCafsRz7d7M,8395
25
25
  manta_node/infrastructure/container/image_executor.py,sha256=ueFl9q4BguZlkBwQMbkdcQ4SQOqMdpLE0Hb4p60GPEs,8499
26
26
  manta_node/infrastructure/container/manager.py,sha256=ZOMOZaeF0LZUEbcPWGIvpoAfmPmbtzXzayY_v7uP518,18198
27
27
  manta_node/infrastructure/filesystem/__init__.py,sha256=nf6Fakp3wuFKjSAm_oihI6WE_yyUY6Uelr7A1GwSvXs,145
@@ -35,9 +35,9 @@ manta_node/infrastructure/metrics/collector.py,sha256=9ESw__Pc2tV6ldG5yhos2IS7T5
35
35
  manta_node/infrastructure/metrics/metrics_collector.py,sha256=WKN3e4q5PANHMrBScaxNSpSoS5ObGLH8QGR0gE1IAOk,10428
36
36
  manta_node/infrastructure/mqtt/__init__.py,sha256=riXo1sXgO4YV6DHCmWRqK61BAmuGLdHiVdQFunAJadA,140
37
37
  manta_node/infrastructure/mqtt/command_handler.py,sha256=Oj1MORxriUvkBymKsSuXoLqVaOoZWgAcoXy537x35oU,17389
38
- manta_node-0.5b0.dev254.dist-info/licenses/LICENSE,sha256=P5HojupjKoAusNtHqWOvO-YFolwLFWQ7Uq0XVKK9nFQ,35291
39
- manta_node-0.5b0.dev254.dist-info/METADATA,sha256=scQRvKOLl6Bh9PM-gDAWUnmkU5IjAeEorEpACAgD2cY,44683
40
- manta_node-0.5b0.dev254.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
41
- manta_node-0.5b0.dev254.dist-info/entry_points.txt,sha256=C_zcw6mdmztNxVUZGLZ83UH5TwcSuqb2C-rB4e2CQoc,56
42
- manta_node-0.5b0.dev254.dist-info/top_level.txt,sha256=nbT5J5WETuXM9UPoQckl29uUOq8wMYdRb9QDx5kAFeo,11
43
- manta_node-0.5b0.dev254.dist-info/RECORD,,
38
+ manta_node-0.5b0.dev259.dist-info/licenses/LICENSE,sha256=P5HojupjKoAusNtHqWOvO-YFolwLFWQ7Uq0XVKK9nFQ,35291
39
+ manta_node-0.5b0.dev259.dist-info/METADATA,sha256=wmdFVZkG6LbgyuLCPVO4OrgfBu3fCDXPYfwMQt2GT_Y,44683
40
+ manta_node-0.5b0.dev259.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
41
+ manta_node-0.5b0.dev259.dist-info/entry_points.txt,sha256=C_zcw6mdmztNxVUZGLZ83UH5TwcSuqb2C-rB4e2CQoc,56
42
+ manta_node-0.5b0.dev259.dist-info/top_level.txt,sha256=nbT5J5WETuXM9UPoQckl29uUOq8wMYdRb9QDx5kAFeo,11
43
+ manta_node-0.5b0.dev259.dist-info/RECORD,,