Agent: Add logging in CachingAgentBinaryRepository._download_binary_from_island()

This commit is contained in:
Shreya Malviya 2022-09-20 15:18:03 +05:30
parent 3b3f39065d
commit 4605722874
1 changed files with 7 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import io
import logging
import threading
from functools import lru_cache
@ -7,6 +8,8 @@ from infection_monkey.island_api_client import IIslandAPIClient
from . import IAgentBinaryRepository
logger = logging.getLogger(__name__)
class CachingAgentBinaryRepository(IAgentBinaryRepository):
"""
@ -32,4 +35,7 @@ class CachingAgentBinaryRepository(IAgentBinaryRepository):
@lru_cache(maxsize=None)
def _download_binary_from_island(self, operating_system: OperatingSystem) -> bytes:
os_name = operating_system.value
return self._island_api_client.get_agent_binary(os_name)
try:
return self._island_api_client.get_agent_binary(os_name)
except Exception as exc:
logger.warning(f"Error connecting to control server: {exc}")