Skip to content

Commit

Permalink
Add config max_job_duration_hours for jobservice (#21390)
Browse files Browse the repository at this point in the history
Signed-off-by: stonezdj <[email protected]>
  • Loading branch information
stonezdj authored Jan 8, 2025
1 parent 8bf710a commit 8ca455e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions make/harbor.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ trivy:
jobservice:
# Maximum number of job workers in job service
max_job_workers: 10
# Maximum hours of task duration in job service, default 24
max_job_duration_hours: 24
# The jobLoggers backend name, only support "STD_OUTPUT", "FILE" and/or "DB"
job_loggers:
- STD_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion make/photon/prepare/templates/jobservice/config.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ metric:

reaper:
# the max time to wait for a task to finish, if unfinished after max_update_hours, the task will be mark as error, but the task will continue to run, default value is 24,
max_update_hours: 24
max_update_hours: {{ max_job_duration_hours }}
# the max time for execution in running state without new task created
max_dangling_hours: 168

Expand Down
1 change: 1 addition & 0 deletions make/photon/prepare/templates/jobservice/env.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ HTTPS_PROXY={{jobservice_https_proxy}}
NO_PROXY={{jobservice_no_proxy}}
REGISTRY_CREDENTIAL_USERNAME={{registry_username}}
REGISTRY_CREDENTIAL_PASSWORD={{registry_password}}
MAX_JOB_DURATION_SECONDS={{max_job_duration_seconds}}

{% if metric.enabled %}
METRIC_NAMESPACE=harbor
Expand Down
5 changes: 5 additions & 0 deletions make/photon/prepare/utils/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ def parse_yaml_config(config_file_path, with_trivy):
# jobservice config
js_config = configs.get('jobservice') or {}
config_dict['max_job_workers'] = js_config["max_job_workers"]
config_dict['max_job_duration_hours'] = js_config["max_job_duration_hours"] or 24
value = config_dict["max_job_duration_hours"]
if not isinstance(value, int) or value < 24:
config_dict["max_job_duration_hours"] = 24
config_dict['max_job_duration_seconds'] = config_dict['max_job_duration_hours'] * 3600
config_dict['job_loggers'] = js_config["job_loggers"]
config_dict['logger_sweeper_duration'] = js_config["logger_sweeper_duration"]
config_dict['jobservice_secret'] = generate_random_string(16)
Expand Down
2 changes: 2 additions & 0 deletions make/photon/prepare/utils/jobservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def prepare_job_service(config_dict):
gid=DEFAULT_GID,
internal_tls=config_dict['internal_tls'],
max_job_workers=config_dict['max_job_workers'],
max_job_duration_hours=config_dict['max_job_duration_hours'],
max_job_duration_seconds=config_dict['max_job_duration_seconds'],
job_loggers=config_dict['job_loggers'],
logger_sweeper_duration=config_dict['logger_sweeper_duration'],
redis_url=config_dict['redis_url_js'],
Expand Down

0 comments on commit 8ca455e

Please sign in to comment.