Skip to content

Commit

Permalink
fix: Invalid image format log spam in Agent (#2894)
Browse files Browse the repository at this point in the history
Backported-from: main (24.09)
Backported-to: 24.03
Backport-of: 2894
  • Loading branch information
jopemachine committed Oct 8, 2024
1 parent c4cab2b commit 3baad04
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions changes/2894.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix invalid image format log spam in Agent
17 changes: 11 additions & 6 deletions src/ai/backend/agent/docker/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ class DockerAgent(AbstractAgent[DockerKernel, DockerKernelCreationContext]):
metadata_server: MetadataServer
docker_ptask_group: aiotools.PersistentTaskGroup
gwbridge_subnet: Optional[str]
checked_invalid_images: Set[str]

def __init__(
self,
Expand All @@ -1074,6 +1075,7 @@ def __init__(
skip_initial_scan=skip_initial_scan,
agent_public_key=agent_public_key,
)
self.checked_invalid_images = set()

async def __ainit__(self) -> None:
async with closing_async(Docker()) as docker:
Expand Down Expand Up @@ -1254,12 +1256,15 @@ async def scan_images(self) -> Mapping[str, str]:
if repo_tag.endswith("<none>"):
continue
try:
ImageRef(repo_tag, ["*"])
except ValueError:
log.warning(
"Image name {} does not conform to Backend.AI's image naming rule. This image will be ignored.",
repo_tag,
)
ImageRef.parse_image_str(repo_tag, "*")
except (InvalidImageName, InvalidImageTag) as e:
if repo_tag not in self.checked_invalid_images:
log.warning(
"Image name {} does not conform to Backend.AI's image naming rule. This image will be ignored. Details: {}",
repo_tag,
e,
)
self.checked_invalid_images.add(repo_tag)
continue

img_detail = await docker.images.inspect(repo_tag)
Expand Down

0 comments on commit 3baad04

Please sign in to comment.