osd: exit immediately if pvc block has not changed

We don't need to run any `cp` command since a destination path already
exists. Using `--no-clobber` is not needed and it results in a noop
anyways.
Instead, let's print the reason why we exit the container.

Signed-off-by: Sébastien Han <seb@redhat.com>
(cherry picked from commit 4234216db8)
This commit is contained in:
Sébastien Han authored and Mergify committed 2022-05-12 17:52:19 +00:00
1 parent b948123b12
commit 8b4d6c6709
1 file changed
+2 -1
+2 -1
View File
@@ -213,7 +213,8 @@ if [ -b "$PVC_DEST" ]; then
PVC_SOURCE_MAJ_MIN=$(stat --format '%%t%%T' $PVC_SOURCE)
PVC_DEST_MAJ_MIN=$(stat --format '%%t%%T' $PVC_DEST)
if [[ "$PVC_SOURCE_MAJ_MIN" == "$PVC_DEST_MAJ_MIN" ]]; then
CP_ARGS+=(--no-clobber)
echo "PVC $PVC_DEST already exists and has the same major and minor as $PVC_SOURCE: "$PVC_SOURCE_MAJ_MIN""
exit 0
else
echo "PVC's source major/minor numbers changed"
CP_ARGS+=(--remove-destination)