Skip to content

Commit

Permalink
[Automation] Fix patch remote script docker registry (#5735)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerShor committed Jun 13, 2024
1 parent 32e7888 commit 83ca487
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
8 changes: 6 additions & 2 deletions automation/patch_igz/patch_env_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ SSH_PASSWORD:

# Docker registry you can push to. Make sure you are logged into it before running the script (required)
# e.g. docker.io/my_user
# For iguazio datanode registry use <data-node-ip>:8009/mlrun
# For iguazio datanode registry use <data-node-ip>:8009
DOCKER_REGISTRY:

# Docker repository to push to
# If you are using the iguazio datanode registry, use "mlrun"
DOCKER_REPO:

# Optional - Use when your registry is connected to a DNS which is accessible from the cluster
# For iguazio datanode registry use:
# datanode-registry.iguazio-platform.app.<system-name>.<lab.iguazeng/cloud-cd>.com:80/mlrun
# datanode-registry.iguazio-platform.app.<system-name>.<lab.iguazeng/cloud-cd>.com:80
OVERWRITE_IMAGE_REGISTRY:

# Optional - will attempt docker login if defined, need to login manually otherwise
Expand Down
26 changes: 22 additions & 4 deletions automation/patch_igz/patch_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,20 @@ def _get_current_version(self) -> str:

def _make_mlrun(self, target, image_tag, image_name) -> str:
logger.info(f"Building mlrun docker image: {target}:{image_tag}")
mlrun_docker_registry = self._config["DOCKER_REGISTRY"]
mlrun_docker_repo = self._config.get("DOCKER_REPO", "")

if not mlrun_docker_registry.endswith("/"):
mlrun_docker_registry += "/"

env = {
"MLRUN_VERSION": image_tag,
"MLRUN_DOCKER_REPO": self._config["DOCKER_REGISTRY"],
"MLRUN_DOCKER_REGISTRY": mlrun_docker_registry,
"MLRUN_DOCKER_REPO": mlrun_docker_repo,
}
cmd = ["make", target]
self._exec_local(cmd, live=True, env=env)
return f"{self._config['DOCKER_REGISTRY']}/{image_name}:{image_tag}"
return f"{mlrun_docker_registry}{mlrun_docker_repo}/{image_name}:{image_tag}"

def _connect_to_node(self, node):
logger.debug(f"Connecting to {node}")
Expand Down Expand Up @@ -219,9 +226,10 @@ def _replace_deploy_policy(self):
def _replace_deployment_images(self, container, built_image):
logger.info("Replace mlrun-api-chief")
if self._config.get("OVERWRITE_IMAGE_REGISTRY"):
docker_registry, overwrite_registry = self._resolve_overwrite_registry()
built_image = built_image.replace(
self._config["DOCKER_REGISTRY"],
self._config["OVERWRITE_IMAGE_REGISTRY"],
docker_registry,
overwrite_registry,
)

self._exec_remote(
Expand Down Expand Up @@ -501,6 +509,16 @@ def _exec_remote(self, cmd: list[str], live=False) -> str:

return stdout

def _resolve_overwrite_registry(self):
docker_registry = self._config["DOCKER_REGISTRY"]
overwrite_registry = self._config["OVERWRITE_IMAGE_REGISTRY"]
if docker_registry.endswith("/"):
docker_registry = docker_registry[:-1]
if overwrite_registry.endswith("/"):
overwrite_registry = overwrite_registry[:-1]

return docker_registry, overwrite_registry


@click.command(help="mlrun-api deployer to remote system")
@click.option("-v", "--verbose", is_flag=True, help="Print what we are doing")
Expand Down

0 comments on commit 83ca487

Please sign in to comment.