Reconstructor logging to omit 404 warnings
Currently, the replicator does not log warning messages for 404 responses. We would like the reconstructor to do the same, as 404s are not considered unusual, and are already handled by the object server. Change-Id: Ia927bf30362548832e9f451923ff94053e11b758 Closes-Bug: #1491883
This commit is contained in:
2 changed files with 18 additions and 2 deletions
@@ -36,7 +36,8 @@ from swift.common.bufferedhttp import http_connect
from swift.common.daemon import Daemon
from swift.common.ring.utils import is_local_device
from swift.obj.ssync_sender import Sender as ssync_sender
from swift.common.http import HTTP_OK, HTTP_INSUFFICIENT_STORAGE
from swift.common.http import HTTP_OK, HTTP_NOT_FOUND, \
HTTP_INSUFFICIENT_STORAGE
from swift.obj.diskfile import DiskFileRouter, get_data_dir, \
get_tmp_dir
from swift.common.storage_policy import POLICIES, EC_POLICY
@@ -203,12 +204,14 @@ class ObjectReconstructor(Daemon):
part, 'GET', path, headers=headers)
with Timeout(self.node_timeout):
resp = conn.getresponse()
if resp.status != HTTP_OK:
if resp.status not in [HTTP_OK, HTTP_NOT_FOUND]:
self.logger.warning(
_("Invalid response %(resp)s from %(full_path)s"),
{'resp': resp.status,
'full_path': self._full_path(node, part, path, policy)})
resp = None
elif resp.status == HTTP_NOT_FOUND:
resp = None
except (Exception, Timeout):
self.logger.exception(
_("Trying to GET %(full_path)s"), {
@@ -683,6 +683,19 @@ class TestGlobalSetupObjectReconstructor(unittest.TestCase):
self.assertEqual(
len(self.reconstructor.logger.log_dict['warning']), 1)
def test_reconstructor_does_not_log_on_404(self):
part = self.part_nums[0]
node = POLICIES[0].object_ring.get_part_nodes(int(part))[0]
with mocked_http_conn(404):
self.reconstructor._get_response(node, part,
path='some_path',
headers={},
policy=POLICIES[0])
# Make sure that no warnings are emitted for a 404
len_warning_lines = len(self.logger.get_lines_for_level('warning'))
self.assertEqual(len_warning_lines, 0)
def test_reconstructor_skips_bogus_partition_dirs(self):
# A directory in the wrong place shouldn't crash the reconstructor
self.reconstructor._reset_stats()
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.