Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws s3 sync returns non-zero code when all is fine #1125

Closed
lukaszbudnik opened this issue Feb 4, 2015 · 5 comments
Closed

aws s3 sync returns non-zero code when all is fine #1125

lukaszbudnik opened this issue Feb 4, 2015 · 5 comments
Labels

Comments

@lukaszbudnik
Copy link

Hi awscli team,

I'm using awscli from pip:

$ aws --version aws-cli/1.7.4 Python/2.7.8 Darwin/13.3.0

When I execute sync between bucket and local folder like this:

aws s3 sync "s3://${env}-yyy" "${env}-yyy" > output.txt 2>&1

Sync executes fine ${env} is substituted with the correct env variable. In test bucket I have some test files added: max file size is around 2 kb and the number of files is around 60. All files are fetched fine, but when I check the return code the return code is always 2.

When I execute my sync command with --debug and do this:

grep 'HTTP Response Code’ output.txt

all files were downloaded OK:

Thread-13 - awscli.errorhandler - DEBUG - HTTP Response Code: 200

doing:

grep 'Received print task' output.txt

gives for all files:

error=False, total_parts=None, warning=None

aws s3 sync is a part of much larger bash script for disaster recovery and I really need to distinguish when sync failed or not (error reporting is very important to me).

Could you take a look at it?

@lukaszbudnik
Copy link
Author

On my production Ubuntu machines I also get return code 2 for a successful sync. awscli used:

aws-cli/1.7.1 Python/2.7.3 Linux/3.2.0-69-virtual

and

aws-cli/1.7.4 Python/2.7.3 Linux/3.2.0-69-virtual

@kyleknap
Copy link
Contributor

kyleknap commented Feb 9, 2015

So a return code of 2 means that some files were skipped in your sync but all of the files that were transferred succeeded. A return code of 1 means that at least one of your transfers failed. The skipped files are printed to standard error (even when you do not add --debug). So if you could figure out what files are being skipped I can provide you with more information why. If I were to guess, the message you are getting is somewhat related to this issue: #1082

@jzt
Copy link

jzt commented Feb 12, 2015

One thing that can cause a return code of 2 is when you do something like:

aws s3 sync s3://mybucket ./newdirectory

The first thing you will see in the output is:
warning: Skipping file /path/to/cwd/new_directory/. File does not exist.

It will create /path/to/cwd/new_directory for you, the sync will complete successfully, and it will return 2.

So for @lukaszbudnik , does the ${env}-yyy directory exist before the sync is executed? If not, that is probably your problem.

Side question: are these return codes documented anywhere? It would be nice to have an idea how to handle these cases.

Edit: Sorry, just clicked on the link to #1082 and noticed that everything I said is spelled out there. Sorry for the noise.

@lukaszbudnik
Copy link
Author

hi guys,

Indeed I see this warning in the --debug output.

I added creating this directory before synchronising and now the return code is 0.

Feel free to close this issue.

thanks,
Łukasz

@jamesls
Copy link
Member

jamesls commented Feb 13, 2015

Good to hear, thanks for the update.

@jamesls jamesls closed this as completed Feb 13, 2015
thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this issue Feb 12, 2022
* chore(version): set 0.14.3.dev1 version (aws#1112) (aws#1113)

* Depend on development version of lambda-builders for dev builds (aws#1111)

* Depend on development version of lambda-builders for dev builds

* Adding prod.txt to manifest

* Splitting dev and tool dependencies

* fix(build): Resolve path after .aws-sam is created (aws#1110)

* fix(build): Resolve path after .aws-sam is created

* fix: build (make pr)

* Design and implementation for producing debug build artifacts (aws#1095)

* design: Initial Design for producing debug artifacts

* initial implementation

* Adding unit tests

* Integration test with debug build mode

* Adjust Design doc and add keyword arg to a call

* fix(dotnet): init template fixes (aws#1117)

* chore(version): set 0.15.0 (aws#1125)

* Revert "Depend on development version of lambda-builders for dev builds (aws#1111)" (aws#1128)

This reverts commit 7e9de790e23791ba176faff2030286db4007e503.

* Bumping to Lambda Builders 0.3.0 (aws#1129)

Bumping to Lambda Builders 0.3.0

* fix(func-tests): add dependency manager param (aws#1130)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants