deletion error
iaon opened this issue · comments
./delete_docker_registry_image --image XXX/YYY:1.2.0-rc.1 -v
It works without error messages.
./delete_docker_registry_image --image XXX/YYY:1.1.0-rc.7 -v
And I see error
Traceback (most recent call last):
File "./delete_docker_registry_image", line 336, in
main()
File "./delete_docker_registry_image", line 325, in main
cleaner.delete_repository_tag(image, tag, force=args.force)
File "./delete_docker_registry_image", line 213, in delete_repository_tag
if self._layer_in_same_repo(repo, tag, layer):
File "./delete_docker_registry_image", line 165, in _layer_in_same_repo
layers = self._get_layers_from_blob(manifest)
File "./delete_docker_registry_image", line 85, in _get_layers_from_blob
return get_layers_from_blob(data_path)
File "./delete_docker_registry_image", line 38, in get_layers_from_blob
with open(path, "r") as blob:
IOError: [Errno 2] No such file or directory: '/mnt/registry-data/docker/registry/v2/blobs/sha256/9f/9fd95e11750dd5b53d8de7c2f5f77f122baf96fddba470f9085918fbb2bf5376/data'
Where 9fd95e11750dd5b53d8de7c2f5f77f122baf96fddba470f9085918fbb2bf5376 is a hash related to first tag 1.2.0-rc.1 -v
I think it happens because first command did't clean properly. And XX/YYY/_manifests/tags/1.2.0-rc.1 still not empty
root@ip-172-31-128-219:/mnt# grep -r 9fd95e11750dd5b53d8de7c2f5f77f122baf96fddba470f9085918fbb2bf5376 *
registry-data/docker/registry/v2/repositories/XXX/YYY/_manifests/tags/1.2.0-rc.1/current/link:sha256:9fd95e11750dd5b53d8de7c2f5f77f122baf96fddba470f9085918fbb2bf5376
Complete output can be found
https://gist.github.com/iaon/16e467e25b3c78234142
This issue exist only for python version of script, so I have to rollback to BASH revision.
Thanks for the report.
As the author of the python rewrite, I will try to fix this issue and add test for it, and will appreciate any help.
@abulimov i think the check at line 225 might be a causing the issue where @iaon sees the tag directory 1.2.0-rc.1 not getting fully deleted. the intent of checking if at_least_one_blob_was_used_elsewhere was a sort of extra precaution against the script corrupting data, and i assumed it wouldn't be a huge annoyance since generally at least one blob would in fact be used somewhere else. when the script noticed that it was deleting a bunch of blobs and absolutely none of them were used anywhere else, i guess i got a little scared and wondered if there might not be a bug in the script, therefore i didn't delete anything unless the user specified --force. in the python script, it's still deleting blobs/revisions/layers/etc in this case. in retrospect, this feature is confusing and i would be in favor of you removing it (all references to at_least_one_blob_was_used_elsewhere as well as the --force option) if you're willing.
so the missing unit tests might be when you're deleting a tag or a full repo (i think this bug would occur there, too) and nothing else is using any of the blobs being deleted.
👍 Great!