Skip to content

Commit

Permalink
image pulling as debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed May 12, 2023
1 parent afb9b0e commit 5c7fbe9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ async def _progress_cb(current: int, total: int) -> None:
float(current / (total or 1)),
)

async def _log_cb(msg: str) -> None:
await post_sidecar_log_message(app, msg, log_level=logging.INFO)
async def _log_cb(msg: str, log_level: int) -> None:
await post_sidecar_log_message(app, msg, log_level=log_level)

await pull_images(list_of_images, registry_settings, _progress_cb, _log_cb)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
from contextlib import asynccontextmanager
from enum import Enum
from typing import Any, AsyncGenerator, Awaitable, Callable, Final, Optional, TypedDict
from typing import Any, AsyncGenerator, Awaitable, Callable, Final, TypedDict

import aiodocker
import yaml
Expand Down Expand Up @@ -69,7 +69,8 @@ def get_docker_service_images(compose_spec_yaml: str) -> set[str]:


ProgressCB = Callable[[int, int], Awaitable[None]]
LogCB = Callable[[str], Awaitable[None]]
LogLevel = int
LogCB = Callable[[str, LogLevel], Awaitable[None]]


async def pull_images(
Expand Down Expand Up @@ -137,7 +138,7 @@ def _parse_docker_pull_progress(
# {'status': 'Digest: sha256:27cb6e6ccef575a4698b66f5de06c7ecd61589132d5a91d098f7f3f9285415a9'}
# {'status': 'Status: Downloaded newer image for ubuntu:latest'}

status: Optional[str] = docker_pull_progress.get("status")
status: str | None = docker_pull_progress.get("status")

if status in list(_TargetPullStatus):
assert "id" in docker_pull_progress # nosec
Expand Down Expand Up @@ -238,4 +239,4 @@ async def _pull_image_with_progress(
total_current, total_total = _compute_sizes(all_image_pulling_data)
await progress_cb(total_current, total_total)

await log_cb(f"pulling {shorter_image_name}: {pull_progress}...")
await log_cb(f"pulling {shorter_image_name}: {pull_progress}...", logging.DEBUG)
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async def task_create_service_containers(
application_health.error_message = message
logger.error("Marked sidecar as unhealthy, see below for details\n:%s", message)
await post_sidecar_log_message(
app, "could not start service containers", log_level=logging.INFO
app, "could not start service containers", log_level=logging.ERROR
)

return shared_store.container_names
Expand Down

0 comments on commit 5c7fbe9

Please sign in to comment.