pulp / pulpcore

Pulp 3 pulpcore package https://pypi.org/project/pulpcore/
GNU General Public License v2.0
301 stars 116 forks source link

Deleting repository versions can loose track of later content deletion #2267

Closed mdellweg closed 2 years ago

mdellweg commented 2 years ago

Version pulpcore 3.18

Describe the bug When deleting a repository version that deletes a content that is added back in the subsequent version, but deleted again in a later version that deletion in the later version is lost.

To Reproduce Steps to reproduce the behavior:

#!/bin/bash

set -eu

pulp file repository destroy --name test_delete_versions || true
pulp file repository create --name test_delete_versions

for NAME in "aaaa" "bbbb" "cccc" "dddd" "eeee" "ffff" "gggg" "hhhh" "jjjj"
do
  echo "$NAME" > "$NAME"
  pulp file content upload --relative-path "$NAME" --file "$NAME" || true
  declare $NAME='{"sha256": "'"$(sha256sum --binary $NAME | cut -d" " -f1)"'", "relative_path": "'"$NAME"'"}'
done

pulp file repository content modify --repository test_delete_versions --add-content '['"$aaaa"', '"$bbbb"', '"$cccc"', '"$dddd"', '"$eeee"']'
pulp file repository content modify --repository test_delete_versions --remove-content '['"$bbbb"', '"$cccc"', '"$dddd"', '"$eeee"']' --add-content '['"$ffff"', '"$gggg"', '"$hhhh"', '"$jjjj"']'
pulp file repository content modify --repository test_delete_versions --remove-content '['"$gggg"', '"$jjjj"']' --add-content '['"$cccc"', '"$dddd"']'
pulp file repository content modify --repository test_delete_versions --remove-content '['"$dddd"', '"$hhhh"']' --add-content '['"$eeee"', '"$jjjj"']'

pulp file repository version list --repository test_delete_versions
# pulp file repository content list --repository test_delete_versions

pulp file repository version destroy --repository test_delete_versions --version 2
pulp file repository version list --repository test_delete_versions

if [ ! "$(pulp file repository content list --repository test_delete_versions --version 1 | jq -r '.[].relative_path' | sort)" = $'aaaa\nbbbb\ncccc\ndddd\neeee' ]
then
  echo Version 1 is wrong.
fi
if [ ! "$(pulp file repository content list --repository test_delete_versions --version 3 | jq -r '.[].relative_path' | sort)" = $'aaaa\ncccc\ndddd\nffff\nhhhh' ]
then
  echo Version 3 is wrong.
fi
if [ ! "$(pulp file repository content list --repository test_delete_versions --version 4 | jq -r '.[].relative_path' | sort)" = $'aaaa\ncccc\neeee\nffff\njjjj' ]
then
  echo Version 4 is wrong.
fi

Expected behavior Content in the respository versions should not change.

Additional context

mdellweg commented 2 years ago

Also observe that the content counts for repository version 4 are correct for what that version should contain. They differ from what it actually contains.

mdellweg commented 2 years ago

This is actually a duplicate of #2047