From 30d74af6534b754e6ad9bfdcbff4ec494277ca83 Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Wed, 27 Jan 2016 13:50:57 +0000 Subject: [PATCH] Insert versioned_writes in correct pipeline position If not explicitly configured the versioned_writes middleware should be auto-inserted in the pipeline after slo and dlo, which is where the versioned_writes filter section's comments say it should be in proxy-server.conf-sample. At the moment it can end up being placed ahead of slo and dlo if they have been explicitly configured, which results in the linked bug manifesting. Closes-Bug: #1537042 Change-Id: I6ac95a331f4ef0d4887311940acc6f8bc00fb4eb --- swift/proxy/server.py | 2 +- test/unit/common/test_wsgi.py | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/swift/proxy/server.py b/swift/proxy/server.py index 3ecf93dbe8..d4a31e5a9d 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -67,7 +67,7 @@ required_filters = [ 'staticweb', 'tempauth', 'keystoneauth', 'catch_errors', 'gatekeeper', 'proxy_logging']}, {'name': 'versioned_writes', 'after_fn': lambda _junk: [ - 'staticweb', 'tempauth', 'keystoneauth', + 'slo', 'dlo', 'staticweb', 'tempauth', 'keystoneauth', 'catch_errors', 'gatekeeper', 'proxy_logging']}] diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index da297d74a7..0ea4c19d9c 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -1470,6 +1470,45 @@ class TestPipelineModification(unittest.TestCase): 'swift.common.middleware.healthcheck', 'swift.proxy.server']) + def test_proxy_modify_wsgi_pipeline_inserts_versioned_writes(self): + config = """ + [DEFAULT] + swift_dir = TEMPDIR + + [pipeline:main] + pipeline = slo dlo healthcheck proxy-server + + [app:proxy-server] + use = egg:swift#proxy + conn_timeout = 0.2 + + [filter:healthcheck] + use = egg:swift#healthcheck + + [filter:dlo] + use = egg:swift#dlo + + [filter:slo] + use = egg:swift#slo + """ + + contents = dedent(config) + with temptree(['proxy-server.conf']) as t: + conf_file = os.path.join(t, 'proxy-server.conf') + with open(conf_file, 'w') as f: + f.write(contents.replace('TEMPDIR', t)) + _fake_rings(t) + app = wsgi.loadapp(conf_file, global_conf={}) + + self.assertEqual(self.pipeline_modules(app), + ['swift.common.middleware.catch_errors', + 'swift.common.middleware.gatekeeper', + 'swift.common.middleware.slo', + 'swift.common.middleware.dlo', + 'swift.common.middleware.versioned_writes', + 'swift.common.middleware.healthcheck', + 'swift.proxy.server']) + def test_proxy_modify_wsgi_pipeline_ordering(self): config = """ [DEFAULT]