Merge "Consolidate Container-Update-Override headers"
This commit is contained in:
commit
196113f93e
@ -123,7 +123,7 @@ from swift.common.http import HTTP_MULTIPLE_CHOICES, is_success, HTTP_OK
|
|||||||
from swift.common.constraints import check_account_format, MAX_FILE_SIZE
|
from swift.common.constraints import check_account_format, MAX_FILE_SIZE
|
||||||
from swift.common.request_helpers import copy_header_subset, remove_items, \
|
from swift.common.request_helpers import copy_header_subset, remove_items, \
|
||||||
is_sys_meta, is_sys_or_user_meta, is_object_transient_sysmeta, \
|
is_sys_meta, is_sys_or_user_meta, is_object_transient_sysmeta, \
|
||||||
check_path_header
|
check_path_header, OBJECT_SYSMETA_CONTAINER_UPDATE_OVERRIDE_PREFIX
|
||||||
from swift.common.wsgi import WSGIContext, make_subrequest
|
from swift.common.wsgi import WSGIContext, make_subrequest
|
||||||
|
|
||||||
|
|
||||||
@ -405,7 +405,7 @@ class ServerSideCopyMiddleware(object):
|
|||||||
# since we're not copying the source etag, make sure that any
|
# since we're not copying the source etag, make sure that any
|
||||||
# container update override values are not copied.
|
# container update override values are not copied.
|
||||||
remove_items(sink_req.headers, lambda k: k.startswith(
|
remove_items(sink_req.headers, lambda k: k.startswith(
|
||||||
'X-Object-Sysmeta-Container-Update-Override-'))
|
OBJECT_SYSMETA_CONTAINER_UPDATE_OVERRIDE_PREFIX.title()))
|
||||||
|
|
||||||
# We no longer need these headers
|
# We no longer need these headers
|
||||||
sink_req.headers.pop('X-Copy-From', None)
|
sink_req.headers.pop('X-Copy-From', None)
|
||||||
|
@ -23,7 +23,8 @@ from swift.common.middleware.crypto.crypto_utils import CryptoWSGIContext, \
|
|||||||
load_crypto_meta, extract_crypto_meta, Crypto
|
load_crypto_meta, extract_crypto_meta, Crypto
|
||||||
from swift.common.exceptions import EncryptionException, UnknownSecretIdError
|
from swift.common.exceptions import EncryptionException, UnknownSecretIdError
|
||||||
from swift.common.request_helpers import get_object_transient_sysmeta, \
|
from swift.common.request_helpers import get_object_transient_sysmeta, \
|
||||||
get_sys_meta_prefix, get_user_meta_prefix
|
get_sys_meta_prefix, get_user_meta_prefix, \
|
||||||
|
get_container_update_override_key
|
||||||
from swift.common.swob import Request, HTTPException, \
|
from swift.common.swob import Request, HTTPException, \
|
||||||
HTTPInternalServerError, wsgi_to_bytes, bytes_to_wsgi
|
HTTPInternalServerError, wsgi_to_bytes, bytes_to_wsgi
|
||||||
from swift.common.utils import get_logger, config_true_value, \
|
from swift.common.utils import get_logger, config_true_value, \
|
||||||
@ -220,7 +221,7 @@ class DecrypterObjContext(BaseDecrypterContext):
|
|||||||
required=True)
|
required=True)
|
||||||
mod_hdr_pairs.append(('Etag', decrypted_etag))
|
mod_hdr_pairs.append(('Etag', decrypted_etag))
|
||||||
|
|
||||||
etag_header = 'X-Object-Sysmeta-Container-Update-Override-Etag'
|
etag_header = get_container_update_override_key('etag')
|
||||||
encrypted_etag = self._response_header_value(etag_header)
|
encrypted_etag = self._response_header_value(etag_header)
|
||||||
if encrypted_etag:
|
if encrypted_etag:
|
||||||
decrypted_etag = self._decrypt_header(
|
decrypted_etag = self._decrypt_header(
|
||||||
|
@ -22,7 +22,8 @@ from swift.common.http import is_success
|
|||||||
from swift.common.middleware.crypto.crypto_utils import CryptoWSGIContext, \
|
from swift.common.middleware.crypto.crypto_utils import CryptoWSGIContext, \
|
||||||
dump_crypto_meta, append_crypto_meta, Crypto
|
dump_crypto_meta, append_crypto_meta, Crypto
|
||||||
from swift.common.request_helpers import get_object_transient_sysmeta, \
|
from swift.common.request_helpers import get_object_transient_sysmeta, \
|
||||||
strip_user_meta_prefix, is_user_meta, update_etag_is_at_header
|
strip_user_meta_prefix, is_user_meta, update_etag_is_at_header, \
|
||||||
|
get_container_update_override_key
|
||||||
from swift.common.swob import Request, Match, HTTPException, \
|
from swift.common.swob import Request, Match, HTTPException, \
|
||||||
HTTPUnprocessableEntity, wsgi_to_bytes, bytes_to_wsgi
|
HTTPUnprocessableEntity, wsgi_to_bytes, bytes_to_wsgi
|
||||||
from swift.common.utils import get_logger, config_true_value, \
|
from swift.common.utils import get_logger, config_true_value, \
|
||||||
@ -100,8 +101,8 @@ class EncInputWrapper(object):
|
|||||||
# remove any Etag from headers, it won't be valid for ciphertext and
|
# remove any Etag from headers, it won't be valid for ciphertext and
|
||||||
# we'll send the ciphertext Etag later in footer metadata
|
# we'll send the ciphertext Etag later in footer metadata
|
||||||
client_etag = req.headers.pop('etag', None)
|
client_etag = req.headers.pop('etag', None)
|
||||||
container_listing_etag_header = req.headers.get(
|
override_header = get_container_update_override_key('etag')
|
||||||
'X-Object-Sysmeta-Container-Update-Override-Etag')
|
container_listing_etag_header = req.headers.get(override_header)
|
||||||
|
|
||||||
def footers_callback(footers):
|
def footers_callback(footers):
|
||||||
if inner_callback:
|
if inner_callback:
|
||||||
@ -152,8 +153,7 @@ class EncInputWrapper(object):
|
|||||||
# This may be None if no override was set and no data was read. An
|
# This may be None if no override was set and no data was read. An
|
||||||
# override value of '' will be passed on.
|
# override value of '' will be passed on.
|
||||||
container_listing_etag = footers.get(
|
container_listing_etag = footers.get(
|
||||||
'X-Object-Sysmeta-Container-Update-Override-Etag',
|
override_header, container_listing_etag_header)
|
||||||
container_listing_etag_header)
|
|
||||||
|
|
||||||
if container_listing_etag is None:
|
if container_listing_etag is None:
|
||||||
container_listing_etag = plaintext_etag
|
container_listing_etag = plaintext_etag
|
||||||
@ -174,7 +174,7 @@ class EncInputWrapper(object):
|
|||||||
self.crypto, container_listing_etag,
|
self.crypto, container_listing_etag,
|
||||||
self.keys['container'])
|
self.keys['container'])
|
||||||
crypto_meta['key_id'] = self.keys['id']
|
crypto_meta['key_id'] = self.keys['id']
|
||||||
footers['X-Object-Sysmeta-Container-Update-Override-Etag'] = \
|
footers[override_header] = \
|
||||||
append_crypto_meta(val, crypto_meta)
|
append_crypto_meta(val, crypto_meta)
|
||||||
# else: no override was set and no data was read
|
# else: no override was set and no data was read
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ import six
|
|||||||
from swift.common.swob import Range, bytes_to_wsgi
|
from swift.common.swob import Range, bytes_to_wsgi
|
||||||
from swift.common.utils import json, public, reiterate
|
from swift.common.utils import json, public, reiterate
|
||||||
from swift.common.db import utf8encode
|
from swift.common.db import utf8encode
|
||||||
|
from swift.common.request_helpers import get_container_update_override_key
|
||||||
|
|
||||||
from six.moves.urllib.parse import quote, urlparse
|
from six.moves.urllib.parse import quote, urlparse
|
||||||
|
|
||||||
@ -182,7 +183,7 @@ class PartController(Controller):
|
|||||||
'X-Object-Sysmeta-Swift3-Etag': '', # for legacy data
|
'X-Object-Sysmeta-Swift3-Etag': '', # for legacy data
|
||||||
'X-Object-Sysmeta-Slo-Etag': '',
|
'X-Object-Sysmeta-Slo-Etag': '',
|
||||||
'X-Object-Sysmeta-Slo-Size': '',
|
'X-Object-Sysmeta-Slo-Size': '',
|
||||||
'X-Object-Sysmeta-Container-Update-Override-Etag': '',
|
get_container_update_override_key('etag'): '',
|
||||||
})
|
})
|
||||||
resp = req.get_response(self.app)
|
resp = req.get_response(self.app)
|
||||||
|
|
||||||
@ -634,7 +635,7 @@ class UploadController(Controller):
|
|||||||
headers[sysmeta_header('object', 'etag')] = s3_etag
|
headers[sysmeta_header('object', 'etag')] = s3_etag
|
||||||
# Leave base header value blank; SLO will populate
|
# Leave base header value blank; SLO will populate
|
||||||
c_etag = '; s3_etag=%s' % s3_etag
|
c_etag = '; s3_etag=%s' % s3_etag
|
||||||
headers['X-Object-Sysmeta-Container-Update-Override-Etag'] = c_etag
|
headers[get_container_update_override_key('etag')] = c_etag
|
||||||
|
|
||||||
too_small_message = ('s3api requires that each segment be at least '
|
too_small_message = ('s3api requires that each segment be at least '
|
||||||
'%d bytes' % self.conf.min_segment_size)
|
'%d bytes' % self.conf.min_segment_size)
|
||||||
|
@ -339,7 +339,8 @@ from swift.common.utils import get_logger, config_true_value, \
|
|||||||
closing_if_possible, LRUCache, StreamingPile, strict_b64decode, \
|
closing_if_possible, LRUCache, StreamingPile, strict_b64decode, \
|
||||||
Timestamp
|
Timestamp
|
||||||
from swift.common.request_helpers import SegmentedIterable, \
|
from swift.common.request_helpers import SegmentedIterable, \
|
||||||
get_sys_meta_prefix, update_etag_is_at_header, resolve_etag_is_at_header
|
get_sys_meta_prefix, update_etag_is_at_header, resolve_etag_is_at_header, \
|
||||||
|
get_container_update_override_key
|
||||||
from swift.common.constraints import check_utf8, MAX_BUFFERED_SLO_SEGMENTS
|
from swift.common.constraints import check_utf8, MAX_BUFFERED_SLO_SEGMENTS
|
||||||
from swift.common.http import HTTP_NOT_FOUND, HTTP_UNAUTHORIZED, is_success
|
from swift.common.http import HTTP_NOT_FOUND, HTTP_UNAUTHORIZED, is_success
|
||||||
from swift.common.wsgi import WSGIContext, make_subrequest
|
from swift.common.wsgi import WSGIContext, make_subrequest
|
||||||
@ -1357,7 +1358,7 @@ class StaticLargeObject(object):
|
|||||||
|
|
||||||
# Ensure container listings have both etags. However, if any
|
# Ensure container listings have both etags. However, if any
|
||||||
# middleware to the left of us touched the base value, trust them.
|
# middleware to the left of us touched the base value, trust them.
|
||||||
override_header = 'X-Object-Sysmeta-Container-Update-Override-Etag'
|
override_header = get_container_update_override_key('etag')
|
||||||
val, sep, params = req.headers.get(
|
val, sep, params = req.headers.get(
|
||||||
override_header, '').partition(';')
|
override_header, '').partition(';')
|
||||||
req.headers[override_header] = '%s; slo_etag=%s' % (
|
req.headers[override_header] = '%s; slo_etag=%s' % (
|
||||||
|
@ -164,7 +164,7 @@ from swift.common.utils import get_logger, register_swift_info, split_path, \
|
|||||||
from swift.common.constraints import check_account_format
|
from swift.common.constraints import check_account_format
|
||||||
from swift.common.wsgi import WSGIContext, make_subrequest
|
from swift.common.wsgi import WSGIContext, make_subrequest
|
||||||
from swift.common.request_helpers import get_sys_meta_prefix, \
|
from swift.common.request_helpers import get_sys_meta_prefix, \
|
||||||
check_path_header
|
check_path_header, get_container_update_override_key
|
||||||
from swift.common.swob import Request, HTTPBadRequest, HTTPTemporaryRedirect, \
|
from swift.common.swob import Request, HTTPBadRequest, HTTPTemporaryRedirect, \
|
||||||
HTTPException, HTTPConflict, HTTPPreconditionFailed, wsgi_quote, \
|
HTTPException, HTTPConflict, HTTPPreconditionFailed, wsgi_quote, \
|
||||||
wsgi_unquote
|
wsgi_unquote
|
||||||
@ -455,7 +455,7 @@ class SymlinkObjectContext(WSGIContext):
|
|||||||
etag_override.append(
|
etag_override.append(
|
||||||
'symlink_target_account=%s' %
|
'symlink_target_account=%s' %
|
||||||
req.headers[TGT_ACCT_SYSMETA_SYMLINK_HDR])
|
req.headers[TGT_ACCT_SYSMETA_SYMLINK_HDR])
|
||||||
req.headers['X-Object-Sysmeta-Container-Update-Override-Etag'] = \
|
req.headers[get_container_update_override_key('etag')] = \
|
||||||
'; '.join(etag_override)
|
'; '.join(etag_override)
|
||||||
|
|
||||||
return self._app_call(req.environ)
|
return self._app_call(req.environ)
|
||||||
|
@ -44,6 +44,8 @@ from swift.common.wsgi import make_subrequest
|
|||||||
|
|
||||||
|
|
||||||
OBJECT_TRANSIENT_SYSMETA_PREFIX = 'x-object-transient-sysmeta-'
|
OBJECT_TRANSIENT_SYSMETA_PREFIX = 'x-object-transient-sysmeta-'
|
||||||
|
OBJECT_SYSMETA_CONTAINER_UPDATE_OVERRIDE_PREFIX = \
|
||||||
|
'x-object-sysmeta-container-update-override-'
|
||||||
|
|
||||||
|
|
||||||
def get_param(req, name, default=None):
|
def get_param(req, name, default=None):
|
||||||
@ -260,6 +262,17 @@ def get_object_transient_sysmeta(key):
|
|||||||
return '%s%s' % (OBJECT_TRANSIENT_SYSMETA_PREFIX, key)
|
return '%s%s' % (OBJECT_TRANSIENT_SYSMETA_PREFIX, key)
|
||||||
|
|
||||||
|
|
||||||
|
def get_container_update_override_key(key):
|
||||||
|
"""
|
||||||
|
Returns the full X-Object-Sysmeta-Container-Update-Override-* header key.
|
||||||
|
|
||||||
|
:param key: the key you want to override in the container update
|
||||||
|
:returns: the full header key
|
||||||
|
"""
|
||||||
|
header = '%s%s' % (OBJECT_SYSMETA_CONTAINER_UPDATE_OVERRIDE_PREFIX, key)
|
||||||
|
return header.title()
|
||||||
|
|
||||||
|
|
||||||
def remove_items(headers, condition):
|
def remove_items(headers, condition):
|
||||||
"""
|
"""
|
||||||
Removes items from a dict whose keys satisfy
|
Removes items from a dict whose keys satisfy
|
||||||
|
@ -43,6 +43,8 @@ from swift.common.exceptions import ConnectionTimeout, DiskFileQuarantined, \
|
|||||||
DiskFileNotExist, DiskFileCollision, DiskFileNoSpace, DiskFileDeleted, \
|
DiskFileNotExist, DiskFileCollision, DiskFileNoSpace, DiskFileDeleted, \
|
||||||
DiskFileDeviceUnavailable, DiskFileExpired, ChunkReadTimeout, \
|
DiskFileDeviceUnavailable, DiskFileExpired, ChunkReadTimeout, \
|
||||||
ChunkReadError, DiskFileXattrNotSupported
|
ChunkReadError, DiskFileXattrNotSupported
|
||||||
|
from swift.common.request_helpers import \
|
||||||
|
OBJECT_SYSMETA_CONTAINER_UPDATE_OVERRIDE_PREFIX
|
||||||
from swift.obj import ssync_receiver
|
from swift.obj import ssync_receiver
|
||||||
from swift.common.http import is_success, HTTP_MOVED_PERMANENTLY
|
from swift.common.http import is_success, HTTP_MOVED_PERMANENTLY
|
||||||
from swift.common.base_storage_server import BaseStorageServer
|
from swift.common.base_storage_server import BaseStorageServer
|
||||||
@ -583,7 +585,7 @@ class ObjectController(BaseStorageServer):
|
|||||||
# x-object-sysmeta-container-update-override-* headers take precedence
|
# x-object-sysmeta-container-update-override-* headers take precedence
|
||||||
# over x-backend-container-update-override-* headers
|
# over x-backend-container-update-override-* headers
|
||||||
override_prefixes = ['x-backend-container-update-override-',
|
override_prefixes = ['x-backend-container-update-override-',
|
||||||
'x-object-sysmeta-container-update-override-']
|
OBJECT_SYSMETA_CONTAINER_UPDATE_OVERRIDE_PREFIX]
|
||||||
for override_prefix in override_prefixes:
|
for override_prefix in override_prefixes:
|
||||||
for key, val in metadata.items():
|
for key, val in metadata.items():
|
||||||
if key.lower().startswith(override_prefix):
|
if key.lower().startswith(override_prefix):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user