feat: add config for job_loggers (#18970)

Signed-off-by: Shengwen Yu <yshengwen@vmware.com>
This commit is contained in:
Shengwen YU 2023-07-24 22:10:36 +08:00 committed by GitHub
parent 8ff095d68f
commit 320c0d63ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 1 deletions

View File

@ -114,6 +114,11 @@ trivy:
jobservice:
# Maximum number of job workers in job service
max_job_workers: 10
# The jobLoggers backend name, only support "STD_OUTPUT", "FILE" and/or "DB"
job_loggers:
- STD_OUTPUT
- FILE
# - DB
# The jobLogger sweeper duration (ignored if `jobLogger` is `stdout`)
logger_sweeper_duration: 1 #days

View File

@ -29,8 +29,13 @@ worker_pool:
idle_timeout_second: 3600
#Loggers for the running job
job_loggers:
- name: "STD_OUTPUT" # logger backend name, only support "FILE" and "STD_OUTPUT"
# The jobLoggers backend name, only support "STD_OUTPUT", "FILE" and/or "DB"
{% for component in job_loggers %}
{% if component == 'STD_OUTPUT' %}
- name: "STD_OUTPUT"
level: "{{level}}" # INFO/DEBUG/WARNING/ERROR/FATAL
{% endif %}
{% if component == 'FILE' %}
- name: "FILE"
level: "{{level}}"
settings: # Customized settings of logger
@ -39,6 +44,14 @@ job_loggers:
duration: {{logger_sweeper_duration}} #days
settings: # Customized settings of sweeper
work_dir: "/var/log/jobs"
{% endif %}
{% if component == 'DB' %}
- name: "DB"
level: "{{level}}"
sweeper:
duration: {{logger_sweeper_duration}} #days
{% endif %}
{% endfor %}
#Loggers for the job service
loggers:

View File

@ -221,6 +221,7 @@ 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['job_loggers'] = js_config["job_loggers"]
config_dict['logger_sweeper_duration'] = js_config["logger_sweeper_duration"]
config_dict['jobservice_secret'] = generate_random_string(16)

View File

@ -33,6 +33,7 @@ def prepare_job_service(config_dict):
gid=DEFAULT_GID,
internal_tls=config_dict['internal_tls'],
max_job_workers=config_dict['max_job_workers'],
job_loggers=config_dict['job_loggers'],
logger_sweeper_duration=config_dict['logger_sweeper_duration'],
redis_url=config_dict['redis_url_js'],
level=log_level,