From 4df20cce1eb17ca92bd88366e9087931767e7f5c Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Wed, 30 Sep 2020 21:04:32 +0000 Subject: [PATCH] fix for when modules are already in sync during agent install --- api/tacticalrmm/apiv2/views.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/tacticalrmm/apiv2/views.py b/api/tacticalrmm/apiv2/views.py index 84c56726..f578a185 100644 --- a/api/tacticalrmm/apiv2/views.py +++ b/api/tacticalrmm/apiv2/views.py @@ -276,12 +276,17 @@ class SaltMinion(APIView): def patch(self, request): # sync modules agent = get_object_or_404(Agent, agent_id=request.data["agent_id"]) - r = agent.salt_api_cmd(timeout=20, func="saltutil.sync_modules") + r = agent.salt_api_cmd(timeout=45, func="saltutil.sync_modules") - if r == "timeout" or r == "error" or not r: + if r == "timeout" or r == "error": return notify_error("Failed to sync salt modules") - return Response("Successfully synced salt modules") + if isinstance(r, list) and any("modules" in i for i in r): + return Response("Successfully synced salt modules") + elif isinstance(r, list) and not r: + return Response("Modules are already in sync") + else: + return notify_error(f"Failed to sync salt modules: {str(r)}") def put(self, request): agent = get_object_or_404(Agent, agent_id=request.data["agent_id"])