From 19e8527cc19b3bcd08363054d8797eecc0c67dc5 Mon Sep 17 00:00:00 2001 From: DQ Date: Mon, 14 Dec 2020 11:52:42 +0800 Subject: [PATCH] Fix log level issue in registry 1. fix level issue in registry.jinja 2. add log level to registryctl Signed-off-by: DQ --- make/photon/prepare/templates/registry/config.yml.jinja | 2 +- .../prepare/templates/registryctl/config.yml.jinja | 2 +- make/photon/prepare/utils/registry.py | 3 --- make/photon/prepare/utils/registry_ctl.py | 9 +++++++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/make/photon/prepare/templates/registry/config.yml.jinja b/make/photon/prepare/templates/registry/config.yml.jinja index 6831daad3..3c2e0d4a2 100644 --- a/make/photon/prepare/templates/registry/config.yml.jinja +++ b/make/photon/prepare/templates/registry/config.yml.jinja @@ -1,6 +1,6 @@ version: 0.1 log: - level: {{log_level}} + level: {{level}} fields: service: registry storage: diff --git a/make/photon/prepare/templates/registryctl/config.yml.jinja b/make/photon/prepare/templates/registryctl/config.yml.jinja index dfcb72046..f3c8ec5c7 100644 --- a/make/photon/prepare/templates/registryctl/config.yml.jinja +++ b/make/photon/prepare/templates/registryctl/config.yml.jinja @@ -11,5 +11,5 @@ https_config: protocol: "http" port: 8080 {% endif %} -log_level: "INFO" +log_level: {{level}} registry_config: "/etc/registry/config.yml" diff --git a/make/photon/prepare/utils/registry.py b/make/photon/prepare/utils/registry.py index 79401a947..8d8e1e995 100644 --- a/make/photon/prepare/utils/registry.py +++ b/make/photon/prepare/utils/registry.py @@ -20,7 +20,6 @@ levels_map = { 'fatal': 'fatal' } - def prepare_registry(config_dict): prepare_dir(registry_data_dir, uid=DEFAULT_UID, gid=DEFAULT_GID) prepare_dir(registry_config_dir) @@ -42,7 +41,6 @@ def prepare_registry(config_dict): storage_provider_info=storage_provider_info, **config_dict, **redis_ops) - def parse_redis(redis_url): u = urlsplit(redis_url) if not u.scheme or u.scheme == 'redis': @@ -81,7 +79,6 @@ def get_storage_provider_info(provider_name, provider_config): storage_provider_info = ('\n' + ' ' * 4).join(storage_provider_conf_list) return storage_provider_info - def gen_passwd_file(config_dict): return subprocess.call(["/usr/bin/htpasswd", "-bcB", registry_passwd_path, config_dict['registry_username'], config_dict['registry_password']], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) diff --git a/make/photon/prepare/utils/registry_ctl.py b/make/photon/prepare/utils/registry_ctl.py index 0541c3804..b7b92a402 100644 --- a/make/photon/prepare/utils/registry_ctl.py +++ b/make/photon/prepare/utils/registry_ctl.py @@ -10,6 +10,14 @@ registryctl_conf = os.path.join(config_dir, "registryctl", "config.yml") registryctl_env_template_path = os.path.join(templates_dir, "registryctl", "env.jinja") registryctl_conf_env = os.path.join(config_dir, "registryctl", "env") +levels_map = { + 'debug': 'debug', + 'info': 'info', + 'warning': 'warn', + 'error': 'error', + 'fatal': 'fatal' +} + def prepare_registry_ctl(config_dict): # prepare dir prepare_dir(registryctl_config_dir) @@ -26,4 +34,5 @@ def prepare_registry_ctl(config_dict): registryctl_conf, uid=DEFAULT_UID, gid=DEFAULT_GID, + level=levels_map[config_dict['log_level']], **config_dict)