diff --git a/swift/common/utils.py b/swift/common/utils.py index f19fd7a48d..8cfbf2b3dd 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -1796,8 +1796,7 @@ def affinity_key_function(affinity_str): priority values are what comes after the equals sign. If affinity_str is empty or all whitespace, then the resulting function - will not alter the ordering of the nodes. However, if affinity_str - contains an invalid value, then None is returned. + will not alter the ordering of the nodes. :param affinity_str: affinity config value, e.g. "r1z2=3" or "r1=1, r2z1=2, r2z2=2" diff --git a/swift/proxy/server.py b/swift/proxy/server.py index 1d5f968d3c..9721186ee5 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -138,7 +138,7 @@ class Application(object): raise ValueError( 'Invalid request_node_count value: %r' % ''.join(value)) try: - read_affinity = conf.get('read_affinity', '') + self._read_affinity = read_affinity = conf.get('read_affinity', '') self.read_affinity_sort_key = affinity_key_function(read_affinity) except ValueError as err: # make the message a little more useful @@ -200,6 +200,15 @@ class Application(object): max_container_name_length=constraints.MAX_CONTAINER_NAME_LENGTH, max_object_name_length=constraints.MAX_OBJECT_NAME_LENGTH) + def check_config(self): + """ + Check the configuration for possible errors + """ + if self._read_affinity and self.sorting_method != 'affinity': + self.logger.warn("sorting_method is set to '%s', not 'affinity'; " + "read_affinity setting will have no effect." % + self.sorting_method) + def get_controller(self, path): """ Get the controller to handle a request. @@ -530,4 +539,6 @@ def app_factory(global_conf, **local_conf): """paste.deploy app factory for creating WSGI proxy apps.""" conf = global_conf.copy() conf.update(local_conf) - return Application(conf) + app = Application(conf) + app.check_config() + return app