diff --git a/swift/obj/reconstructor.py b/swift/obj/reconstructor.py index cfe6239c2b..68b10cb73e 100644 --- a/swift/obj/reconstructor.py +++ b/swift/obj/reconstructor.py @@ -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"), { diff --git a/test/unit/obj/test_reconstructor.py b/test/unit/obj/test_reconstructor.py index 7aa5ebc60d..60bd9ac19c 100755 --- a/test/unit/obj/test_reconstructor.py +++ b/test/unit/obj/test_reconstructor.py @@ -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()