From 5bccbc20d9dad1059d1c613b3d88aa263d2940ce Mon Sep 17 00:00:00 2001 From: Nikolai Petukhov Date: Wed, 11 Dec 2024 15:09:30 -0300 Subject: [PATCH 1/2] get images clean interval parameter from instance --- agent/worker/agent_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/agent/worker/agent_utils.py b/agent/worker/agent_utils.py index bc3f474..7eab498 100644 --- a/agent/worker/agent_utils.py +++ b/agent/worker/agent_utils.py @@ -61,6 +61,7 @@ class AgentOptionsJsonFields: DOCKER_IMAGE = "dockerImage" FORCE_CPU_ONLY = "forceCPUOnly" LOG_LEVEL = "logLevel" + IMAGES_CLEAN_INTERVAL = "imagesCleanInterval" def create_img_meta_str(img_size_bytes, width, height): @@ -784,6 +785,12 @@ def update_env_param(name, value, default=None): update_env_param(constants._AGENT_HOST_DIR, agent_host_dir) + update_env_param( + constants._REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS, + options.get(AgentOptionsJsonFields.IMAGES_CLEAN_INTERVAL, None), + optional_defaults[constants._REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS], + ) + volumes = {} def add_volume(src: str, dst: str) -> dict: From 6ba6a32628baa85bf7a9d4269f8e6969c7450559 Mon Sep 17 00:00:00 2001 From: Nikolai Peukhov Date: Tue, 17 Dec 2024 16:58:42 -0300 Subject: [PATCH 2/2] add env conversion --- agent/worker/constants.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/agent/worker/constants.py b/agent/worker/constants.py index 45a96f6..3b4f8de 100644 --- a/agent/worker/constants.py +++ b/agent/worker/constants.py @@ -189,8 +189,11 @@ def get_optional_defaults(): return _OPTIONAL_DEFAULTS.copy() -def read_optional_setting(name): - return os.getenv(name, _OPTIONAL_DEFAULTS[name]) +def read_optional_setting(name, postprocess_fn = None): + value = os.getenv(name, _OPTIONAL_DEFAULTS[name]) + if postprocess_fn is not None: + return postprocess_fn(value) + return value def HOST_DIR(): @@ -544,7 +547,7 @@ def DISABLE_TELEMETRY(): def REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS(): - return read_optional_setting(_REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS) + return read_optional_setting(_REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS, lambda x: int(x)) def AGENT_ID():