mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-07-17 06:05:13 +00:00
fix(backup): re-raise inspect failures for containers that still exist
Treating every failed swarm-task inspect as skippable opened a false-green window: a transient inspect failure on a still-running, non-whitelisted container skipped the stop and backed the volume up hot while the run reported success. Re-check whether the container is still listed; only a genuinely vanished container skips, an existing one re-raises so a broken daemon keeps failing the run loudly. Covered by unit tests for both paths. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,7 @@ class TestIsSwarmTask(unittest.TestCase):
|
||||
@patch.object(
|
||||
docker_mod,
|
||||
"execute_shell_command",
|
||||
side_effect=BackupException("gone"),
|
||||
side_effect=[BackupException("gone"), []],
|
||||
)
|
||||
def test_vanished_container_counts_as_not_stoppable(self, _mock) -> None:
|
||||
# A container removed between listing and inspect must not abort the
|
||||
@@ -29,6 +29,18 @@ class TestIsSwarmTask(unittest.TestCase):
|
||||
# stop/start and image-inspect path.
|
||||
self.assertTrue(docker_mod.is_swarm_task("gone-container"))
|
||||
|
||||
@patch.object(
|
||||
docker_mod,
|
||||
"execute_shell_command",
|
||||
side_effect=[BackupException("daemon hiccup"), ["still-here"]],
|
||||
)
|
||||
def test_inspect_failure_on_existing_container_still_fails(self, _mock) -> None:
|
||||
# If the container still exists, an inspect failure must keep failing
|
||||
# the run: silently skipping the stop would back up a hot volume and
|
||||
# report green without the stop guarantee.
|
||||
with self.assertRaises(BackupException):
|
||||
docker_mod.is_swarm_task("still-here")
|
||||
|
||||
|
||||
class TestFilterStoppable(unittest.TestCase):
|
||||
@patch.object(docker_mod, "is_swarm_task", side_effect=[False, True, False])
|
||||
|
||||
Reference in New Issue
Block a user