Fix log level issue in registry

1. fix level issue in registry.jinja
2. add log level to registryctl

Signed-off-by: DQ <dengq@vmware.com>
This commit is contained in:
DQ 2020-12-14 11:52:42 +08:00
parent 0a38ae1843
commit 19e8527cc1
4 changed files with 11 additions and 5 deletions

View File

@ -1,6 +1,6 @@
version: 0.1
log:
level: {{log_level}}
level: {{level}}
fields:
service: registry
storage:

View File

@ -11,5 +11,5 @@ https_config:
protocol: "http"
port: 8080
{% endif %}
log_level: "INFO"
log_level: {{level}}
registry_config: "/etc/registry/config.yml"

View File

@ -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)

View File

@ -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)