Default object_post_as_copy to False
Additionally, emit deprecation warnings when running POST-as-COPY Change-Id: I11324e711057f7332577fd38f9bff82bdc6aac90
This commit is contained in:
parent
b90f2d7a23
commit
4ee20dba48
@ -991,9 +991,7 @@ Whether account PUTs and DELETEs are even callable. If set to 'true' any authori
|
||||
user may create and delete accounts; if 'false' no one, even authorized, can. The default
|
||||
is false.
|
||||
.IP \fBobject_post_as_copy\fR
|
||||
Set object_post_as_copy = false to turn on fast posts where only the metadata changes
|
||||
are stored as new and the original data file is kept in place. This makes for quicker
|
||||
posts. The default is True.
|
||||
Deprecated. The default is False.
|
||||
.IP \fBaccount_autocreate\fR
|
||||
If set to 'true' authorized accounts that do not yet exist within the Swift cluster
|
||||
will be automatically created. The default is set to false.
|
||||
|
@ -70,7 +70,6 @@ allow_versioned_writes = true
|
||||
|
||||
[filter:copy]
|
||||
use = egg:swift#copy
|
||||
object_post_as_copy = true
|
||||
|
||||
[app:proxy-server]
|
||||
use = egg:swift#proxy
|
||||
|
@ -1690,12 +1690,7 @@ error_suppression_limit 10 Error count to consider a
|
||||
node error limited
|
||||
allow_account_management false Whether account PUTs and DELETEs
|
||||
are even callable
|
||||
object_post_as_copy true Set object_post_as_copy = false
|
||||
to turn on fast posts where only
|
||||
the metadata changes are stored
|
||||
anew and the original data file
|
||||
is kept in place. This makes for
|
||||
quicker posts.
|
||||
object_post_as_copy false Deprecated.
|
||||
account_autocreate false If set to 'true' authorized
|
||||
accounts that do not yet exist
|
||||
within the Swift cluster will
|
||||
|
@ -808,12 +808,14 @@ use = egg:swift#versioned_writes
|
||||
# If you don't put it in the pipeline, it will be inserted for you.
|
||||
[filter:copy]
|
||||
use = egg:swift#copy
|
||||
# Set object_post_as_copy = false to turn on fast posts where only the metadata
|
||||
# changes are stored anew and the original data file is kept in place. This
|
||||
# makes for quicker posts.
|
||||
# When object_post_as_copy is set to True, a POST request will be transformed
|
||||
# into a COPY request where source and destination objects are the same.
|
||||
# object_post_as_copy = true
|
||||
# By default object POST requests update metadata without modification of the
|
||||
# original data file
|
||||
# Set this to True to enable the old, slow behavior wherein object POST
|
||||
# requests are transformed into COPY requests where source and destination are
|
||||
# the same. All client-visible behavior (save response time) should be
|
||||
# identical.
|
||||
# This option is deprecated and will be ignored in a future release.
|
||||
# object_post_as_copy = false
|
||||
|
||||
# Note: To enable encryption, add the following 2 dependent pieces of crypto
|
||||
# middleware to the proxy-server pipeline. They should be to the right of all
|
||||
|
@ -117,18 +117,15 @@ Object Post as Copy
|
||||
-------------------
|
||||
Historically, this has been a feature (and a configurable option with default
|
||||
set to True) in proxy server configuration. This has been moved to server side
|
||||
copy middleware.
|
||||
copy middleware and the default changed to False.
|
||||
|
||||
When ``object_post_as_copy`` is set to ``true`` (default value), an incoming
|
||||
POST request is morphed into a COPY request where source and destination
|
||||
objects are same.
|
||||
When ``object_post_as_copy`` is set to ``true``, an incoming POST request is
|
||||
morphed into a COPY request where source and destination objects are same.
|
||||
|
||||
This feature was necessary because of a previous behavior where POSTS would
|
||||
update the metadata on the object but not on the container. As a result,
|
||||
features like container sync would not work correctly. This is no longer the
|
||||
case and the plan is to deprecate this option. It is being kept now for
|
||||
backwards compatibility. At first chance, set ``object_post_as_copy`` to
|
||||
``false``.
|
||||
case and this option is now deprecated. It will be removed in a future release.
|
||||
"""
|
||||
|
||||
import os
|
||||
@ -277,7 +274,13 @@ class ServerSideCopyMiddleware(object):
|
||||
# problems during upgrade.
|
||||
self._load_object_post_as_copy_conf(conf)
|
||||
self.object_post_as_copy = \
|
||||
config_true_value(conf.get('object_post_as_copy', 'true'))
|
||||
config_true_value(conf.get('object_post_as_copy', 'false'))
|
||||
if self.object_post_as_copy:
|
||||
msg = ('object_post_as_copy=true is deprecated; remove all '
|
||||
'references to it from %s to disable this warning. This '
|
||||
'option will be ignored in a future release' % conf.get(
|
||||
'__file__', 'proxy-server.conf'))
|
||||
self.logger.warning(msg)
|
||||
|
||||
def _load_object_post_as_copy_conf(self, conf):
|
||||
if ('object_post_as_copy' in conf or '__file__' not in conf):
|
||||
|
@ -1454,6 +1454,10 @@ class TestServerSideCopyConfiguration(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmpdir)
|
||||
|
||||
def test_post_as_copy_defaults_to_false(self):
|
||||
ssc = copy.filter_factory({})("no app here")
|
||||
self.assertEqual(ssc.object_post_as_copy, False)
|
||||
|
||||
def test_reading_proxy_conf_when_no_middleware_conf_present(self):
|
||||
proxy_conf = dedent("""
|
||||
[DEFAULT]
|
||||
@ -1501,12 +1505,49 @@ class TestServerSideCopyConfiguration(unittest.TestCase):
|
||||
conffile.write(proxy_conf)
|
||||
conffile.flush()
|
||||
|
||||
ssc = copy.filter_factory({
|
||||
'object_post_as_copy': 'no',
|
||||
'__file__': conffile.name
|
||||
})("no app here")
|
||||
with mock.patch('swift.common.middleware.copy.get_logger',
|
||||
return_value=debug_logger('copy')):
|
||||
ssc = copy.filter_factory({
|
||||
'object_post_as_copy': 'no',
|
||||
'__file__': conffile.name
|
||||
})("no app here")
|
||||
|
||||
self.assertEqual(ssc.object_post_as_copy, False)
|
||||
self.assertFalse(ssc.logger.get_lines_for_level('warning'))
|
||||
|
||||
def _test_post_as_copy_emits_warning(self, conf):
|
||||
with mock.patch('swift.common.middleware.copy.get_logger',
|
||||
return_value=debug_logger('copy')):
|
||||
ssc = copy.filter_factory(conf)("no app here")
|
||||
|
||||
self.assertEqual(ssc.object_post_as_copy, True)
|
||||
log_lines = ssc.logger.get_lines_for_level('warning')
|
||||
self.assertEqual(1, len(log_lines))
|
||||
self.assertIn('object_post_as_copy=true is deprecated', log_lines[0])
|
||||
|
||||
def test_post_as_copy_emits_warning(self):
|
||||
self._test_post_as_copy_emits_warning({'object_post_as_copy': 'yes'})
|
||||
|
||||
proxy_conf = dedent("""
|
||||
[DEFAULT]
|
||||
bind_ip = 10.4.5.6
|
||||
|
||||
[pipeline:main]
|
||||
pipeline = catch_errors copy ye-olde-proxy-server
|
||||
|
||||
[filter:copy]
|
||||
use = egg:swift#copy
|
||||
|
||||
[app:ye-olde-proxy-server]
|
||||
use = egg:swift#proxy
|
||||
object_post_as_copy = yes
|
||||
""")
|
||||
|
||||
conffile = tempfile.NamedTemporaryFile()
|
||||
conffile.write(proxy_conf)
|
||||
conffile.flush()
|
||||
|
||||
self._test_post_as_copy_emits_warning({'__file__': conffile.name})
|
||||
|
||||
|
||||
@patch_policies(with_ec_default=True)
|
||||
|
7
tox.ini
7
tox.ini
@ -62,7 +62,12 @@ commands = ./.functests {posargs}
|
||||
[testenv:func-fast-post]
|
||||
commands = ./.functests {posargs}
|
||||
setenv = SWIFT_TEST_IN_PROCESS=1
|
||||
SWIFT_TEST_IN_PROCESS_OBJECT_POST_AS_COPY=False
|
||||
SWIFT_TEST_IN_PROCESS_OBJECT_POST_AS_COPY=True
|
||||
|
||||
[testenv:func-post-as-copy]
|
||||
commands = ./.functests {posargs}
|
||||
setenv = SWIFT_TEST_IN_PROCESS=1
|
||||
SWIFT_TEST_IN_PROCESS_OBJECT_POST_AS_COPY=True
|
||||
|
||||
[testenv:func-encryption]
|
||||
commands = ./.functests {posargs}
|
||||
|
Loading…
Reference in New Issue
Block a user