Skip to content

Commit

Permalink
fix local and hub digest diff problem
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLisin committed Nov 20, 2023
1 parent 2fe7dcc commit 2bbd3c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions agent/worker/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ def _update_net_client(self, dc: docker.DockerClient):
else:
# pull if update to old agent
agnet_checked_sly_net = os.getenv("AGNET_CHECKED_SLY_NET", None)
cur_id = sly_net_container.attrs.get("Image", None)
if agnet_checked_sly_net is None:
check_and_pull_sly_net(dc, cur_id, self.logger, sly_net_hub_name)
check_and_pull_sly_net(dc, sly_net_container, self.logger, sly_net_hub_name)

network = "supervisely-net-{}".format(constants.TOKEN())
command = sly_net_container.attrs.get("Args")
Expand Down
12 changes: 6 additions & 6 deletions agent/worker/task_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ def task_main_func(self):
"Something goes wrong: can't find sly-net-client attached to this agent"
)
else:
cur_id = sly_net_container.attrs.get("Image", None)
check_and_pull_sly_net(self._docker_api, cur_id, self.logger, sly_net_hub_name)
check_and_pull_sly_net(
self._docker_api, sly_net_container, self.logger, sly_net_hub_name
)

# start new agent
container = self._docker_api.containers.run(
Expand Down Expand Up @@ -119,17 +120,16 @@ def run_shell_command(cmd, print_output=False):

def check_and_pull_sly_net(
dc: docker.DockerClient,
cur_id: str,
cur_container: Container,
logger: Logger,
sly_net_hub_name: str = "supervisely/sly-net-client:latest",
):
ic = ImageCollection(dc)
docker_hub_image_info = ic.get_registry_data(sly_net_hub_name)
name_with_digest: str = cur_container.image.attrs.get("RepoDigests", [""])[0]

if cur_id == docker_hub_image_info.id:
if name_with_digest.endswith(docker_hub_image_info.id):
logger.info("sly-net-client is already updated")
else:
logger.info("Found new version of sly-net-client. Pulling...")
logger.info(f"Current ID: `{cur_id}`")
logger.info(f"New id: `{docker_hub_image_info.id}`")
sly.docker_utils._docker_pull_progress(dc, sly_net_hub_name, logger)

0 comments on commit 2bbd3c6

Please sign in to comment.