Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get images clean interval parameter from instance #98

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions agent/worker/agent_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 6 additions & 3 deletions agent/worker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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():
Expand Down
Loading