Skip to content

Commit

Permalink
Merge pull request #432 from vantage6/hotfix/pull-image-docker-hub
Browse files Browse the repository at this point in the history
Fix to pull docker images from docker hub if not found locally or remotely
  • Loading branch information
frankcorneliusmartin committed Jan 6, 2023
2 parents 895d49d + 83e3f99 commit 679c615
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion vantage6-common/vantage6/common/docker/addons.py
Expand Up @@ -242,14 +242,17 @@ 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:
docker_client.images.pull(image)
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:
Expand Down
8 changes: 6 additions & 2 deletions vantage6-node/vantage6/node/docker/vpn_manager.py
Expand Up @@ -9,7 +9,7 @@

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 (
Expand Down Expand Up @@ -337,8 +337,12 @@ def _find_exposed_ports(self, image: str) -> List[Dict]:
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:
Expand Down

0 comments on commit 679c615

Please sign in to comment.