Glances breaks if Podman container is started while it is running #3199

This commit is contained in:
nicolargo 2025-06-29 11:00:28 +02:00
parent 1434d3ad5c
commit 1268b58bbc
1 changed files with 8 additions and 1 deletions

View File

@ -49,9 +49,10 @@ class PodmanContainerStatsFetcher:
def get_streamed_stats(self) -> dict[str, Any]:
stats = self._streamer.stats
if stats["Error"]:
if stats is None or stats.get("Error", False):
logger.error(f"containers (Podman) Container({self._container.id}): Stats fetching failed")
logger.debug(f"containers (Podman) Container({self._container.id}): ", stats)
return None
return stats["Stats"][0]
@ -70,6 +71,12 @@ class PodmanContainerStatsFetcher:
stats = {"cpu": {}, "memory": {}, "io": {}, "network": {}}
api_stats = self.get_streamed_stats()
# Glances breaks if Podman container is started while it is running See #3199
if api_stats is None:
# If stats fetching failed, return empty stats
logger.error(f"containers (Podman) Container({self._container.id}): Failed to fetch stats")
return stats
if any(field not in api_stats for field in self.MANDATORY_FIELDS) or (
"Network" not in api_stats and any(k not in api_stats for k in ['NetInput', 'NetOutput'])
):