From ec099738adbb0da62cdbe41f4354d7ee5f73fb45 Mon Sep 17 00:00:00 2001 From: zhaojing1987 Date: Fri, 23 Aug 2024 14:44:58 +0800 Subject: [PATCH] fix bug for get volumes --- apphub/src/services/portainer_manager.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apphub/src/services/portainer_manager.py b/apphub/src/services/portainer_manager.py index d0d1b03b..9379658a 100755 --- a/apphub/src/services/portainer_manager.py +++ b/apphub/src/services/portainer_manager.py @@ -274,7 +274,15 @@ class PortainerManager: if response.status_code == 200: try: volumes = response.json().get("Volumes", []) - volumes_info = [volume for volume in volumes if volume.get("Labels", {}).get("com.docker.compose.project") == stack_name] + # volumes_info = [volume for volume in volumes if volume.get("Labels", {}).get("com.docker.compose.project") == stack_name] + volumes_info = [ + volume for volume in volumes + if ( + isinstance(volume, dict) and + volume.get("Labels") and + volume.get("Labels", {}).get("com.docker.compose.project") == stack_name + ) + ] except Exception as e: logger.error(f"Get volumes by stack name:{stack_name} error: {e}") raise CustomException()