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..f9b2519 100644 --- a/hooks/swift_context.py +++ b/hooks/swift_context.py @@ -100,8 +100,14 @@ 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_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 # code. diff --git a/templates/icehouse/proxy-server.conf b/templates/icehouse/proxy-server.conf index ed7d947..561d457 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 = swift +log_facility = LOG_LOCAL0 +log_level = {{ log_level }} +log_address = /dev/log +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/templates/kilo/proxy-server.conf b/templates/kilo/proxy-server.conf index 24406a3..3b9e9ae 100644 --- a/templates/kilo/proxy-server.conf +++ b/templates/kilo/proxy-server.conf @@ -3,6 +3,12 @@ bind_port = {{ bind_port }} workers = {{ workers }} user = swift bind_ip = {{ bind_host }} +log_name = swift +log_facility = LOG_LOCAL0 +log_level = {{ log_level }} +log_address = /dev/log +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 a781d65..c80c9ca 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -368,13 +368,19 @@ class SwiftProxyBasicDeployment(OpenStackAmuletDeployment): expected = { 'DEFAULT': { 'bind_port': '8070', - 'user': 'swift' + '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'},