Skip to content

Commit

Permalink
fixup! Add support for deletion of AWS snapshot backups
Browse files Browse the repository at this point in the history
PR feedback: Log a message when a snapshot being deleted cannot be
found.
  • Loading branch information
mikewallace1979 committed Jul 11, 2023
1 parent 6b441c9 commit e3f1ddc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion barman/cloud_providers/aws_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,9 @@ def _delete_snapshot(self, snapshot_id):
error_code = exc.response["Error"]["Code"]
# If the snapshot could not be found then deletion is considered successful
# otherwise we raise a CloudProviderError
if error_code != "InvalidSnapshot.NotFound":
if error_code == "InvalidSnapshot.NotFound":
logging.warning("Snapshot {} could not be found".format(snapshot_id))
else:
raise CloudProviderError(
"Deletion of snapshot %s failed with error code %s: %s"
% (snapshot_id, error_code, exc.response["Error"])
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cloud_snapshot_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3269,6 +3269,8 @@ def test_delete_snapshot_not_found(self, mock_ec2_client, caplog):
mock_ec2_client.delete_snapshot.assert_called_once_with(SnapshotId=snapshot_id)
# AND a success message was logged
assert "Snapshot {} deleted".format(snapshot_id) in caplog.text
# AND a warning message was logged
assert "Snapshot {} could not be found".format(snapshot_id) in caplog.text

def test_delete_snapshot_failed(self, mock_ec2_client, caplog):
"""Verify that a failed deletion results in a CloudProviderError."""
Expand Down

0 comments on commit e3f1ddc

Please sign in to comment.