mc icon indicating copy to clipboard operation
mc copied to clipboard

mc mv returns non-zero on empty source

Open udf2457 opened this issue 1 year ago • 6 comments
trafficstars

mc mv returns non-zero on an empty source bucket.

This causes problems with scripts that check for bad exits, i.e. mc mv .... || report_bad_stuff

It would be nice to have one of the following:

  1. Do not return non-zero on empty source (since, technically it is not an error situation, it is a fact ... i.e. nothing to move)
  2. Add an igore-empty-source flag or similar to achieve the same effect (i.e. not consider empty sources an error)

mc version RELEASE.2024-07-15T17-46-06Z (commit-id=11034f9de1e9f993c36fbad961f76f876a753328) Runtime: go1.22.5 linux/amd64

udf2457 avatar Aug 05 '24 17:08 udf2457

Reviewing

allanrogerr avatar Aug 05 '24 18:08 allanrogerr

What is your minio version? Also, please post of a sample script where you provoke the error.

allanrogerr avatar Aug 05 '24 22:08 allanrogerr

minio version was already provided.....

You should be able to replicate the error by doing what I said, mc mv .... || report_bad_stuff, so for example mc mv ... || { logger -p user.error -t "mytag" "mc failed"; exit 1; }

udf2457 avatar Aug 06 '24 08:08 udf2457

mc mv returns non-zero on an empty source bucket.

This causes problems with scripts that check for bad exits, i.e. mc mv .... || report_bad_stuff

It would be nice to have one of the following:

  1. Do not return non-zero on empty source (since, technically it is not an error situation, it is a fact ... i.e. nothing to move)
  2. Add an igore-empty-source flag or similar to achieve the same effect (i.e. not consider empty sources an error)

mc version RELEASE.2024-07-15T17-46-06Z (commit-id=11034f9de1e9f993c36fbad961f76f876a753328) Runtime: go1.22.5 linux/amd64

Provide minio --version

allanrogerr avatar Aug 06 '24 11:08 allanrogerr

And that is what I posted ........ surely the Copyright and License lines are irrelevant ? I gave you the mc version and runtime lines.

udf2457 avatar Aug 06 '24 11:08 udf2457

@udf2457 You have provided the mc version - not the minio (server) version. It may or may not be relevant, but it is good to have for a precise reproducer in case the error is related to specific server behavior.

klauspost avatar Aug 06 '24 11:08 klauspost

Leaving this open a bit longer. @udf2457 Please provide the complete requested info.

allanrogerr avatar Dec 30 '24 17:12 allanrogerr

How does unix mv handle non existent path? @allanrogerr

harshavardhana avatar Mar 10 '25 19:03 harshavardhana

@udf2457 you can try mc ls <source_alias>/<source_prefix> --json | jq '.key' | xargs -I {} mc mv {} <target_alias>/<target_prefix> As @harshavardhana was probably getting at, unix mv work similarly, so does aws s3. Neither are idempotent. The above gives an example of how you may obtain the idempotent behaviour you require.

allanrogerr avatar Mar 10 '25 20:03 allanrogerr