From 80bbc65dbee1ceeabb68fb9f1bef0f2d20e96a33 Mon Sep 17 00:00:00 2001 From: Seyeong Kim Date: Thu, 9 Apr 2015 05:36:21 +0000 Subject: [PATCH 1/4] add log configuration --- config.yaml | 12 ++++++++++++ hooks/swift_context.py | 11 +++++++++++ templates/icehouse/proxy-server.conf | 13 +++++++++++-- tests/basic_deployment.py | 7 ++++++- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index 3181bb0..1945170 100644 --- a/config.yaml +++ b/config.yaml @@ -122,6 +122,18 @@ options: Timeouts from these requests can be recovered from so setting this to something lower than node-timeout would provide quicker error recovery while allowing for a longer timeout for non-recoverable requests (PUTs). + # Logging configuration + debug: + default: False + type: boolean + description: | + Set log-name, log-facility, log-level, log-address + log-headers: + default: False + type: boolean + description: | + Enables the ability to log request headers. + The default is False. # Manual Keystone configuration. keystone-auth-host: type: string diff --git a/hooks/swift_context.py b/hooks/swift_context.py index 0c996c2..50c8826 100644 --- a/hooks/swift_context.py +++ b/hooks/swift_context.py @@ -81,6 +81,10 @@ class SwiftIdentityContext(OSContextGenerator): def __call__(self): bind_port = config('bind-port') workers = config('workers') + log_name = 'swift' + log_facility = 'LOG_LOCAL0' + log_level = 'INFO' + log_address = '/dev/log' if workers == 0: import multiprocessing workers = multiprocessing.cpu_count() @@ -100,8 +104,15 @@ class SwiftIdentityContext(OSContextGenerator): 'delay_auth_decision': config('delay-auth-decision'), 'node_timeout': config('node-timeout'), 'recoverable_node_timeout': config('recoverable-node-timeout'), + 'log_headers': config('log-headers') } + if config('debug'): + ctxt['log_name'] = log_name + ctxt['log_facility'] = log_facility + ctxt['log_level'] = log_level + ctxt['log_address'] = log_address + # Instead of duplicating code lets use charm-helpers to set signing_dir # TODO(hopem): refactor this context handler to use charm-helpers # code. diff --git a/templates/icehouse/proxy-server.conf b/templates/icehouse/proxy-server.conf index ed7d947..1b4c0cb 100644 --- a/templates/icehouse/proxy-server.conf +++ b/templates/icehouse/proxy-server.conf @@ -3,6 +3,12 @@ bind_port = {{ bind_port }} workers = {{ workers }} user = swift bind_ip = {{ bind_host }} +log_name = {{ log_name }} +log_facility = {{ log_facility }} +log_level = {{ log_level }} +log_address = {{ log_address }} +log_headers = {{ log_headers }} + {% if ssl %} cert_file = {{ ssl_cert }} key_file = {{ ssl_key }} @@ -10,10 +16,10 @@ key_file = {{ ssl_key }} {% if auth_type == 'keystone' %} [pipeline:main] -pipeline = gatekeeper healthcheck cache swift3 s3token container_sync bulk tempurl slo dlo formpost authtoken keystoneauth staticweb container-quotas account-quotas proxy-server +pipeline = gatekeeper healthcheck proxy-logging cache swift3 s3token container_sync bulk tempurl slo dlo formpost authtoken keystoneauth staticweb container-quotas account-quotas proxy-logging proxy-server {% else %} [pipeline:main] -pipeline = gatekeeper healthcheck cache container_sync bulk tempurl slo dlo formpost tempauth staticweb container-quotas account-quotas proxy-server +pipeline = gatekeeper healthcheck proxy-logging cache container_sync bulk tempurl slo dlo formpost tempauth staticweb container-quotas account-quotas proxy-logging proxy-server {% endif %} [app:proxy-server] @@ -40,6 +46,9 @@ use = egg:swift#account_quotas [filter:container-quotas] use = egg:swift#container_quotas +[filter:proxy-logging] +use = egg:swift#proxy_logging + [filter:staticweb] use = egg:swift#staticweb diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index c4c9e1d..dbab0b4 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -368,7 +368,12 @@ class SwiftProxyBasicDeployment(OpenStackAmuletDeployment): expected = { 'DEFAULT': { 'bind_port': '8070', - 'user': 'swift' + 'user': 'swift', +# 'log_name': 'swift', +# 'log_facility': 'LOG_LOCAL0', +# 'log_level': 'INFO', +# 'log_address': '/dev/log', +# 'log_headers': 'False' }, 'pipeline:main': { 'pipeline': 'gatekeeper healthcheck cache swift3 s3token ' From 58c1dc97096559ac42f65db758db6f9c2587fdf2 Mon Sep 17 00:00:00 2001 From: Seyeong Kim Date: Thu, 9 Apr 2015 07:43:53 +0000 Subject: [PATCH 2/4] remove comment --- tests/basic_deployment.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index dbab0b4..14f10f7 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -369,11 +369,6 @@ class SwiftProxyBasicDeployment(OpenStackAmuletDeployment): 'DEFAULT': { 'bind_port': '8070', 'user': 'swift', -# 'log_name': 'swift', -# 'log_facility': 'LOG_LOCAL0', -# 'log_level': 'INFO', -# 'log_address': '/dev/log', -# 'log_headers': 'False' }, 'pipeline:main': { 'pipeline': 'gatekeeper healthcheck cache swift3 s3token ' From 50ee45d837f767323d78e365f4e9608b93f01e14 Mon Sep 17 00:00:00 2001 From: Seyeong Kim Date: Fri, 10 Apr 2015 00:55:17 +0000 Subject: [PATCH 3/4] add tests --- tests/basic_deployment.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 14f10f7..cd9cf51 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -369,12 +369,18 @@ class SwiftProxyBasicDeployment(OpenStackAmuletDeployment): 'DEFAULT': { 'bind_port': '8070', 'user': 'swift', + 'log_name': 'swift', + 'log_facility': 'LOG_LOCAL0', + 'log_level': 'INFO', + 'log_headers': 'False', + 'log_address': '/dev/log' }, 'pipeline:main': { - 'pipeline': 'gatekeeper healthcheck cache swift3 s3token ' - 'container_sync bulk tempurl slo dlo formpost ' - 'authtoken keystoneauth staticweb ' - 'container-quotas account-quotas proxy-server' + 'pipeline': 'gatekeeper healthcheck proxy-logging cache swift3 ' + 's3token container_sync bulk tempurl slo dlo ' + 'formpost authtoken keystoneauth staticweb ' + 'container-quotas account-quotas proxy-logging ' + 'proxy-server' }, 'app:proxy-server': { 'use': 'egg:swift#proxy', @@ -395,6 +401,7 @@ class SwiftProxyBasicDeployment(OpenStackAmuletDeployment): }, 'filter:account-quotas': {'use': 'egg:swift#account_quotas'}, 'filter:container-quotas': {'use': 'egg:swift#container_quotas'}, + 'filter:proxy-logging': {'use': 'egg:swift#proxy_logging'}, 'filter:staticweb': {'use': 'egg:swift#staticweb'}, 'filter:bulk': {'use': 'egg:swift#bulk'}, 'filter:slo': {'use': 'egg:swift#slo'}, From 1d715e8bca203d3ca984b94199dfd9618946ad3b Mon Sep 17 00:00:00 2001 From: Seyeong Kim Date: Mon, 13 Apr 2015 22:57:02 +0000 Subject: [PATCH 4/4] default things to template, more option on if branch --- hooks/swift_context.py | 11 +++-------- templates/icehouse/proxy-server.conf | 6 +++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/hooks/swift_context.py b/hooks/swift_context.py index 50c8826..f9b2519 100644 --- a/hooks/swift_context.py +++ b/hooks/swift_context.py @@ -81,10 +81,6 @@ class SwiftIdentityContext(OSContextGenerator): def __call__(self): bind_port = config('bind-port') workers = config('workers') - log_name = 'swift' - log_facility = 'LOG_LOCAL0' - log_level = 'INFO' - log_address = '/dev/log' if workers == 0: import multiprocessing workers = multiprocessing.cpu_count() @@ -108,10 +104,9 @@ class SwiftIdentityContext(OSContextGenerator): } if config('debug'): - ctxt['log_name'] = log_name - ctxt['log_facility'] = log_facility - ctxt['log_level'] = log_level - ctxt['log_address'] = log_address + ctxt['log_level'] = 'DEBUG' + else: + ctxt['log_level'] = 'INFO' # Instead of duplicating code lets use charm-helpers to set signing_dir # TODO(hopem): refactor this context handler to use charm-helpers diff --git a/templates/icehouse/proxy-server.conf b/templates/icehouse/proxy-server.conf index 1b4c0cb..561d457 100644 --- a/templates/icehouse/proxy-server.conf +++ b/templates/icehouse/proxy-server.conf @@ -3,10 +3,10 @@ bind_port = {{ bind_port }} workers = {{ workers }} user = swift bind_ip = {{ bind_host }} -log_name = {{ log_name }} -log_facility = {{ log_facility }} +log_name = swift +log_facility = LOG_LOCAL0 log_level = {{ log_level }} -log_address = {{ log_address }} +log_address = /dev/log log_headers = {{ log_headers }} {% if ssl %}