diff --git a/doc/manpages/proxy-server.conf.5 b/doc/manpages/proxy-server.conf.5 index f99c97ce19..c8fdfd5735 100644 --- a/doc/manpages/proxy-server.conf.5 +++ b/doc/manpages/proxy-server.conf.5 @@ -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. diff --git a/doc/saio/swift/proxy-server.conf b/doc/saio/swift/proxy-server.conf index f424d5e519..76b85d5818 100644 --- a/doc/saio/swift/proxy-server.conf +++ b/doc/saio/swift/proxy-server.conf @@ -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 diff --git a/doc/source/deployment_guide.rst b/doc/source/deployment_guide.rst index 67ba2651b0..c8e24dbeea 100644 --- a/doc/source/deployment_guide.rst +++ b/doc/source/deployment_guide.rst @@ -1698,12 +1698,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 diff --git a/etc/proxy-server.conf-sample b/etc/proxy-server.conf-sample index 594bdba981..1cccc9bee9 100644 --- a/etc/proxy-server.conf-sample +++ b/etc/proxy-server.conf-sample @@ -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 diff --git a/swift/common/middleware/copy.py b/swift/common/middleware/copy.py index 34bf4f0f27..0c22a31f39 100644 --- a/swift/common/middleware/copy.py +++ b/swift/common/middleware/copy.py @@ -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): diff --git a/test/unit/common/middleware/test_copy.py b/test/unit/common/middleware/test_copy.py index f6453fa29f..60f2ba606b 100644 --- a/test/unit/common/middleware/test_copy.py +++ b/test/unit/common/middleware/test_copy.py @@ -1456,6 +1456,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] @@ -1503,12 +1507,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) diff --git a/tox.ini b/tox.ini index b1e9602fd3..3161b37371 100644 --- a/tox.ini +++ b/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}