Repository: vantage6/vantage6
Issue: [Bug] Docker hub images are not pulled

**Describe the bug**
When an image is run that is not local and not on harbor, it is not pulled from docker hub.

```python
2022-12-06 09:33:17 - task_manager   - WARNING  - Could not construct remote URL, are you using a local image?
2022-12-06 09:33:17 - task_manager   - WARNING  - Or an image from docker hub?
2022-12-06 09:33:17 - task_manager   - WARNING  - We'll make an final attempt when running the image to pull it without any checks...
2022-12-06 09:33:17 - task_manager   - ERROR    - Cannot locate image itisfoundation/sleeper
2022-12-06 09:33:18 - node           - ERROR    - 404 Client Error: Not Found ("no such image: itisfoundation/sleeper: No such image: itisfoundation/sleeper:latest")
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/docker/api/client.py", line 261, in _raise_for_status
    response.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.35/images/itisfoundation/sleeper/json

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/vantage6/vantage6-node/vantage6/node/__init__.py", line 792, in run_forever
    self.__start_task(task)
  File "/vantage6/vantage6-node/vantage6/node/__init__.py", line 351, in __start_task
    database=task.get('database', 'default')
  File "/vantage6/vantage6-node/vantage6/node/docker/docker_manager.py", line 301, in run
    database=database
  File "/vantage6/vantage6-node/vantage6/node/docker/task_manager.py", line 205, in run
    vpn_ports = self._run_algorithm()
  File "/vantage6/vantage6-node/vantage6/node/docker/task_manager.py", line 258, in _run_algorithm
    algo_image_name=self.image
  File "/vantage6/vantage6-node/vantage6/node/docker/vpn_manager.py", line 226, in forward_vpn_traffic
    helper_container, algo_image_name)
  File "/vantage6/vantage6-node/vantage6/node/docker/vpn_manager.py", line 289, in _forward_traffic_to_algorithm
    ports = self._find_exposed_ports(algo_image_name)
  File "/vantage6/vantage6-node/vantage6/node/docker/vpn_manager.py", line 340, in _find_exposed_ports
    n2n_image = self.docker.images.get(image)
  File "/usr/local/lib/python3.7/site-packages/docker/models/images.py", line 316, in get
    return self.prepare_model(self.client.api.inspect_image(name))
  File "/usr/local/lib/python3.7/site-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/docker/api/image.py", line 246, in inspect_image
    self._get(self._url("/images/{0}/json", image)), True
  File "/usr/local/lib/python3.7/site-packages/docker/api/client.py", line 267, in _result
    self._raise_for_status(response)
  File "/usr/local/lib/python3.7/site-packages/docker/api/client.py", line 263, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/usr/local/lib/python3.7/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.ImageNotFound: 404 Client Error: Not Found ("no such image: itisfoundation/sleeper: No such image: itisfoundation/sleeper:latest")
```

**To Reproduce**
Steps to reproduce the behavior:
1. run task using a docker image (which is not local)
2. see node logs

I can fix it by pulling the image manually


Changed files:
vantage6-node/vantage6/node/docker/vpn_manager.py, vantage6-common/vantage6/common/docker/addons.py

diff --git a/vantage6-common/vantage6/common/docker/addons.py b/vantage6-common/vantage6/common/docker/addons.py
index c267d549..29cdead1 100644
--- a/vantage6-common/vantage6/common/docker/addons.py
+++ b/vantage6-common/vantage6/common/docker/addons.py
@@ -242,7 +242,9 @@ def pull_if_newer(docker_client, image: str, log=ClickLogger):
         log.debug("No local image found, pulling from remote!")
         pull = True
     elif not local_ and not remote_:
-        log.error(f"Cannot locate image {image}")
+        log.warn(f"Cannot locate image {image} locally or remotely")
+        # we will try to pull it from the docker hub
+        pull = True
 
     if pull:
         try:
@@ -250,6 +252,7 @@ def pull_if_newer(docker_client, image: str, log=ClickLogger):
         except docker.errors.APIError as e:
             log.error(f"Failed to pull image! {image}")
             log.debug(e)
+            raise
 
 
 def get_container(docker_client: DockerClient, **filters) -> Container:
diff --git a/vantage6-node/vantage6/node/docker/vpn_manager.py b/vantage6-node/vantage6/node/docker/vpn_manager.py
index a5bc7a0c..28a6f2c1 100644
--- a/vantage6-node/vantage6/node/docker/vpn_manager.py
+++ b/vantage6-node/vantage6/node/docker/vpn_manager.py
@@ -9,7 +9,7 @@ from docker.models.containers import Container
 
 from vantage6.common.globals import APPNAME, VPN_CONFIG_FILE
 from vantage6.common.docker.addons import (
-    remove_container_if_exists, remove_container
+    remove_container_if_exists, remove_container, pull_if_newer
 )
 from vantage6.node.util import logger_name
 from vantage6.node.globals import (
@@ -337,8 +337,12 @@ class VPNManager(DockerBaseManager):
             List of ports forward VPN traffic to. For each port, a dictionary
             containing port number and label is given
         """
-        n2n_image = self.docker.images.get(image)
         default_ports = [{'algo_port': DEFAULT_ALGO_VPN_PORT, 'label': None}]
+        try:
+            n2n_image = pull_if_newer(self.docker, image, self.log)
+        except Exception:
+            self.log.warn(f"Could not locate algorithm docker image {image}!")
+            return default_ports
 
         exposed_ports = []
         try: