diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index e9c3598a3..416d85e5d 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -249,14 +249,14 @@ class ConfigService: return config @staticmethod - def update_config_on_mode_set(mode: IslandModeEnum) -> None: + def update_config_on_mode_set(mode: IslandModeEnum) -> bool: config = ConfigService.get_config() - ConfigService.update_config_per_mode(mode, config, True) + return ConfigService.update_config_per_mode(mode, config, True) @staticmethod - def update_config_per_mode(mode: IslandModeEnum, config: Dict, should_encrypt: bool) -> None: + def update_config_per_mode(mode: IslandModeEnum, config: Dict, should_encrypt: bool) -> bool: config = ConfigService._set_default_config_values_per_mode(mode, config) - ConfigService.update_config(config_json=config, should_encrypt=True) + return ConfigService.update_config(config_json=config, should_encrypt=True) @staticmethod def _set_default_config_values_per_mode(mode: IslandModeEnum, config: Dict) -> Dict: diff --git a/monkey/monkey_island/cc/services/mode/set_island_mode_service.py b/monkey/monkey_island/cc/services/mode/set_island_mode_service.py index dd70070d1..2e9e71691 100644 --- a/monkey/monkey_island/cc/services/mode/set_island_mode_service.py +++ b/monkey/monkey_island/cc/services/mode/set_island_mode_service.py @@ -1,10 +1,17 @@ +import logging + from monkey_island.cc.models.island_mode_model import IslandMode from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.mode.mode_enum import IslandModeEnum +LOG = logging.getLogger(__name__) + def set_mode(mode: IslandModeEnum): island_mode_model = IslandMode() island_mode_model.mode = mode.value island_mode_model.save() - ConfigService.update_config_on_mode_set(mode) + if not ConfigService.update_config_on_mode_set(mode): + LOG.error( + "Could not apply configuration changes per mode. Using default advanced configuration." + )