Browse Source

sharder: Send broker path as referer when updating root

When we send object updates, we get the object name in the request path;
let's get something similar for shard updates. Referer has the benefit
of already getting logged.

Change-Id: I4ee8f9f3056f5425c82d3bb1f538049815697088
changes/85/793485/1
Tim Burke 4 months ago
parent
commit
e495c3bbef
  1. 3
      swift/container/sharder.py
  2. 5
      test/unit/container/test_sharder.py

3
swift/container/sharder.py

@ -1888,7 +1888,8 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
include_deleted=True)
# send everything
if self._send_shard_ranges(
broker.root_account, broker.root_container, shard_ranges):
broker.root_account, broker.root_container, shard_ranges,
{'Referer': quote(broker.path)}):
# on success, mark ourselves as reported so we don't keep
# hammering the root
own_shard_range.reported = True

5
test/unit/container/test_sharder.py

@ -4688,12 +4688,14 @@ class TestSharder(BaseTestSharder):
def check_shard_ranges_sent(self, broker, expected_sent):
bodies = []
servers = []
referers = []
def capture_send(conn, data):
bodies.append(data)
def capture_connect(host, port, *a, **kw):
def capture_connect(host, port, _method, _path, headers, *a, **kw):
servers.append((host, port))
referers.append(headers.get('Referer'))
self.assertFalse(broker.get_own_shard_range().reported) # sanity
with self._mock_sharder() as sharder:
@ -4712,6 +4714,7 @@ class TestSharder(BaseTestSharder):
('10.0.1.1', 1101),
('10.0.1.2', 1102),
])
self.assertEqual([broker.path] * 3, referers)
self.assertTrue(broker.get_own_shard_range().reported)
def test_update_root_container_own_range(self):

Loading…
Cancel
Save