Skip to content

Instantly share code, notes, and snippets.

@clayg
Created June 19, 2014 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/402957dc4c77b3236e9c to your computer and use it in GitHub Desktop.
Save clayg/402957dc4c77b3236e9c to your computer and use it in GitHub Desktop.
diff --git a/swift/common/db_replicator.py b/swift/common/db_replicator.py
index 2dc3d76..c03a137 100644
--- a/swift/common/db_replicator.py
+++ b/swift/common/db_replicator.py
@@ -652,13 +652,25 @@ class ReplicatorRpc(object):
remote_info = self._parse_sync_args(args)
return self._handle_sync_request(broker, remote_info)
+ def _get_synced_replication_info(self, broker, remote_info):
+ """
+ Apply any changes to the broker based on remote_info and return the
+ current replication info.
+
+ :param broker: the database broker
+ :param remote_info: the remote replication info
+
+ :returns: local broker replication info
+ """
+ return broker.get_replication_info()
+
def _handle_sync_request(self, broker, remote_info):
"""
Update metadata, timestamps, sync points.
"""
with self.debug_timing('info'):
try:
- info = broker.get_replication_info()
+ info = self._get_synced_replication_info(broker, remote_info)
except (Exception, Timeout) as e:
if 'no such table' in str(e):
self.logger.error(_("Quarantining DB %s"), broker)
diff --git a/swift/container/replicator.py b/swift/container/replicator.py
index 41140ab..9c55ba1 100644
--- a/swift/container/replicator.py
+++ b/swift/container/replicator.py
@@ -244,12 +244,21 @@ class ContainerReplicatorRpc(db_replicator.ReplicatorRpc):
remote_info['storage_policy_index'] = args[9]
return remote_info
- def _handle_sync_request(self, broker, remote_info):
- if incorrect_policy_index(broker.get_info(), remote_info):
+ def _get_synced_replication_info(self, broker, remote_info):
+ """
+ Sync the remote_info storage_policy_index if needed and return the
+ newly synced replication info.
+
+ :param broker: the database broker
+ :param remote_info: the remote replication info
+
+ :returns: local broker replication info
+ """
+ info = broker.get_replication_info()
+ if incorrect_policy_index(info, remote_info):
status_changed_at = Timestamp(time.time())
broker.set_storage_policy_index(
remote_info['storage_policy_index'],
timestamp=status_changed_at.internal)
- parent = super(ContainerReplicatorRpc, self)
- rv = parent._handle_sync_request(broker, remote_info)
- return rv
+ info = broker.get_replication_info()
+ return info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment