Merge "Default object_post_as_copy to False"

This commit is contained in:
Jenkins 2017-01-24 20:58:34 +00:00 committed by Gerrit Code Review
commit 63b351893d
7 changed files with 72 additions and 29 deletions

View File

@ -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 user may create and delete accounts; if 'false' no one, even authorized, can. The default
is false. is false.
.IP \fBobject_post_as_copy\fR .IP \fBobject_post_as_copy\fR
Set object_post_as_copy = false to turn on fast posts where only the metadata changes Deprecated. The default is False.
are stored as new and the original data file is kept in place. This makes for quicker
posts. The default is True.
.IP \fBaccount_autocreate\fR .IP \fBaccount_autocreate\fR
If set to 'true' authorized accounts that do not yet exist within the Swift cluster 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. will be automatically created. The default is set to false.

View File

@ -70,7 +70,6 @@ allow_versioned_writes = true
[filter:copy] [filter:copy]
use = egg:swift#copy use = egg:swift#copy
object_post_as_copy = true
[app:proxy-server] [app:proxy-server]
use = egg:swift#proxy use = egg:swift#proxy

View File

@ -1698,12 +1698,7 @@ error_suppression_limit 10 Error count to consider a
node error limited node error limited
allow_account_management false Whether account PUTs and DELETEs allow_account_management false Whether account PUTs and DELETEs
are even callable are even callable
object_post_as_copy true Set object_post_as_copy = false object_post_as_copy false Deprecated.
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.
account_autocreate false If set to 'true' authorized account_autocreate false If set to 'true' authorized
accounts that do not yet exist accounts that do not yet exist
within the Swift cluster will within the Swift cluster will

View File

@ -808,12 +808,14 @@ use = egg:swift#versioned_writes
# If you don't put it in the pipeline, it will be inserted for you. # If you don't put it in the pipeline, it will be inserted for you.
[filter:copy] [filter:copy]
use = egg:swift#copy use = egg:swift#copy
# Set object_post_as_copy = false to turn on fast posts where only the metadata # By default object POST requests update metadata without modification of the
# changes are stored anew and the original data file is kept in place. This # original data file
# makes for quicker posts. # Set this to True to enable the old, slow behavior wherein object POST
# When object_post_as_copy is set to True, a POST request will be transformed # requests are transformed into COPY requests where source and destination are
# into a COPY request where source and destination objects are the same. # the same. All client-visible behavior (save response time) should be
# object_post_as_copy = true # 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 # 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 # middleware to the proxy-server pipeline. They should be to the right of all

View File

@ -117,18 +117,15 @@ Object Post as Copy
------------------- -------------------
Historically, this has been a feature (and a configurable option with default 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 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 When ``object_post_as_copy`` is set to ``true``, an incoming POST request is
POST request is morphed into a COPY request where source and destination morphed into a COPY request where source and destination objects are same.
objects are same.
This feature was necessary because of a previous behavior where POSTS would 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, 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 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 case and this option is now deprecated. It will be removed in a future release.
backwards compatibility. At first chance, set ``object_post_as_copy`` to
``false``.
""" """
import os import os
@ -277,7 +274,13 @@ class ServerSideCopyMiddleware(object):
# problems during upgrade. # problems during upgrade.
self._load_object_post_as_copy_conf(conf) self._load_object_post_as_copy_conf(conf)
self.object_post_as_copy = \ 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): def _load_object_post_as_copy_conf(self, conf):
if ('object_post_as_copy' in conf or '__file__' not in conf): if ('object_post_as_copy' in conf or '__file__' not in conf):

View File

@ -1456,6 +1456,10 @@ class TestServerSideCopyConfiguration(unittest.TestCase):
def tearDown(self): def tearDown(self):
shutil.rmtree(self.tmpdir) 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): def test_reading_proxy_conf_when_no_middleware_conf_present(self):
proxy_conf = dedent(""" proxy_conf = dedent("""
[DEFAULT] [DEFAULT]
@ -1503,12 +1507,49 @@ class TestServerSideCopyConfiguration(unittest.TestCase):
conffile.write(proxy_conf) conffile.write(proxy_conf)
conffile.flush() conffile.flush()
ssc = copy.filter_factory({ with mock.patch('swift.common.middleware.copy.get_logger',
'object_post_as_copy': 'no', return_value=debug_logger('copy')):
'__file__': conffile.name ssc = copy.filter_factory({
})("no app here") 'object_post_as_copy': 'no',
'__file__': conffile.name
})("no app here")
self.assertEqual(ssc.object_post_as_copy, False) 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) @patch_policies(with_ec_default=True)

View File

@ -62,7 +62,12 @@ commands = ./.functests {posargs}
[testenv:func-fast-post] [testenv:func-fast-post]
commands = ./.functests {posargs} commands = ./.functests {posargs}
setenv = SWIFT_TEST_IN_PROCESS=1 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] [testenv:func-encryption]
commands = ./.functests {posargs} commands = ./.functests {posargs}