swift/swift/common/middleware
Tim Burke 8ed74c2646 py3: Work with proper native string paths in crypto meta
Previously, we would work with these paths as WSGI strings -- this would
work fine when all data were read and written on the same major version
of Python, but fail pretty badly during and after upgrading Python.

In particular, if a py3 proxy-server tried to read existing data that
was written down by a py2 proxy-server, it would hit an error and
respond 500. Worse, if an un-upgraded py2 proxy tried to read data that
was freshly-written by a py3 proxy, it would serve corrupt data back to
the client (including a corrupt/invalid ETag and Content-Type).

Now, ensure that both py2 and py3 write down paths as native strings.
Make an effort to still work with WSGI-string metadata, though it can be
ambiguous as to whether a string is a WSGI string or not. The heuristic
used is if

 * the path from metadata does not match the (native-string) request
   path and
 * the path from metadata (when interpreted as a WSGI string) can be
   "un-wsgi-fied" without any encode/decode errors and
 * the native-string path from metadata *does* match the native-string
   request path

then trust the path from the request. By contrast, we usually prefer the
path from metadata in case there was a pipeline misconfiguration (see
related bug).

Add the ability to read and write a new, unambiguous version of metadata
that always has the path as a native string. To support rolling
upgrades, a new config option is added: meta_version_to_write. This
defaults to 2 to support rolling upgrades without configuration changes,
but the default may change to 3 in a future release.

UpgradeImpact
=============
When upgrading from Swift 2.20.0 or Swift 2.19.1 or earlier, set

    meta_version_to_write = 1

in your keymaster's configuration. Regardless of prior Swift version, set

    meta_version_to_write = 3

after upgrading all proxy servers.

When switching from Python 2 to Python 3, first upgrade Swift while on
Python 2, then upgrade to Python 3.

Change-Id: I00c6693c42c1a0220b64d8016d380d5985339658
Closes-Bug: #1888037
Related-Bug: #1813725
(cherry picked from commit 7d429318dd)
2020-08-30 17:24:24 +00:00
..
crypto py3: Work with proper native string paths in crypto meta 2020-08-30 17:24:24 +00:00
s3api Merge "Update hacking for Python3" 2020-04-09 15:05:28 +00:00
versioned_writes Merge "Apply limit to list versioned containers" 2020-03-07 01:17:03 +00:00
x_profile Update hacking for Python3 2020-04-03 21:21:07 +02:00
__init__.py Rewrite redirection in cname_lookup & domain_remap 2017-05-11 09:46:29 -04:00
account_quotas.py enforce account quotas on empty accounts 2020-01-31 09:39:17 -08:00
acl.py Use `==` to compare against the empty string, not `is` 2019-10-14 17:40:42 -07:00
bulk.py New Object Versioning mode 2020-01-24 17:39:56 -08:00
catch_errors.py Merge "Content-Length enforcement fixups" 2018-06-29 05:43:39 +00:00
cname_lookup.py Ensure domain stored in memcached gets utf8 decoded on py2 2020-02-11 14:42:33 -08:00
container_quotas.py Refactor server side copy as middleware 2016-05-11 14:55:51 -04:00
container_sync.py New Object Versioning mode 2020-01-24 17:39:56 -08:00
copy.py New Object Versioning mode 2020-01-24 17:39:56 -08:00
crossdomain.py py3: port crossdomain 2018-06-26 13:20:49 -07:00
dlo.py Have slo tell the object-server that it wants whole manifests 2020-01-02 15:48:39 -08:00
domain_remap.py swob: Stop auto-encoding unicode bodies 2018-06-28 09:58:44 -07:00
etag_quoter.py py3: Make etag-quoter work 2020-04-29 18:15:46 +00:00
formpost.py py3: Fix formpost unicode filename issues 2020-01-15 16:52:37 -08:00
gatekeeper.py Allow internal clients to use reserved namespace 2019-11-27 11:22:00 -06:00
healthcheck.py py3: port healthcheck 2018-06-26 13:20:49 -07:00
keystoneauth.py Fix small formatting issues in middleware docs 2017-11-20 12:22:18 +01:00
list_endpoints.py Increase some middleware test coverage 2019-06-05 06:19:04 +00:00
listing_formats.py Fix up some Content-Type handling in account/container listings 2020-02-28 18:32:38 -08:00
memcache.py Use six to fix imports on Python 3 2015-07-24 11:48:28 +02:00
name_check.py Update hacking for Python3 2020-04-03 21:21:07 +02:00
proxy_logging.py proxy-logging: add fields ttfb and pid 2020-01-27 15:54:52 -05:00
ratelimit.py [Trivial fix]Remove unnecessary slash 2019-05-06 14:23:05 +08:00
read_only.py Read-only middleware fixups 2018-06-11 10:05:49 -07:00
recon.py Have check_drive raise ValueError on errors 2018-06-20 17:15:07 -07:00
slo.py Merge "Return correct etag for raw manifest" 2020-01-31 18:53:27 +00:00
staticweb.py py38: cgi lost some names 2020-01-29 12:56:58 -08:00
symlink.py Allow clients to send quoted ETags for static links 2020-03-20 20:16:12 -05:00
tempauth.py Update hacking for Python3 2020-04-03 21:21:07 +02:00
tempurl.py py3: Port the tempurl middleware 2019-06-20 12:41:50 -07:00
xprofile.py Python3: fix test_xprofile.py 2018-12-12 20:26:10 +01:00