Description
Expected behavior
- A MinIO bucket has versioning.
- An older (non-current) version of an object is deleted from a MinIO bucket. (Either manually or by
ILMExpiry
.) mc mirror --remove --watch
watching for events from the bucket receives anObjectRemoved:Delete
event.- As the event is not related to the current version of the object, the object is not removed from the destination directory.
Actual behavior
- A MinIO bucket has versioning.
- An older (non-current) version of an object is deleted from a MinIO bucket. (Either manually or by
ILMExpiry
.) mc mirror --remove --watch
watching for events from the bucket receives anObjectRemoved:Delete
event.mc mirror
does not validate the object is actually removed from the source and deletes it from the destination.
Steps to reproduce the behavior
-
Add alias for the MinIO server:
export MC_HOST_alias=...
-
Enable versioning on your test bucket:
mc version enable alias/bucket
-
Create a local test file:
echo "version 1" > test.txt`
-
Copy it to the bucket:
mc cp test.txt alias/bucket/test.txt
-
You could alter the test file for clarity:
echo "version 2" > test.txt
-
Copy it again to have two versions of the object:
mc cp test.txt alias/bucket/test.txt
-
Leave
mc mirror --remove --watch
running (this is where the bug is):mc mirror --overwrite --remove --watch alias/bucket /path/to/local/directory
-
List versions of the test file:
mc ls --versions alias/bucket/test.txt
-
Remove the older (non-current) version of the object:
mc rm --version=UUID alias/bucket/test.txt
-
Observe how the
/path/to/local/directory/test.txt
gets removed despite the current version of the object still exists.
Possible fix
After receiving an ObjectRemoved:Delete
event, mc mirror
could validate with a HEAD
request whether the object still exist of not. This should work both with and without versioning and only takes one extra round-trip.
mc --version
mc version 2025-02-08T19-14-21Z
Runtime: go1.23.2 linux/amd64
System information
Ubuntu 22.04; 6.8.0-51-generic.