-
Notifications
You must be signed in to change notification settings - Fork 876
fix(sync): fix dry-run failing consecutive runs by creating directories in target dir #2660
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
base: main
Are you sure you want to change the base?
fix(sync): fix dry-run failing consecutive runs by creating directories in target dir #2660
Conversation
|
Ephemeral COPR build failed. @containers/packit-build please check. |
8dab1c6 to
aa1ea15
Compare
|
Tests failed. @containers/packit-build please check. |
aa1ea15 to
8b71882
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
attempts to create directories even when running in dry-run mode
That’s clearly undesirable.
and fails if these already exist.
I can’t see how? MkdirAll is not supposed to fail in that situation. What is failing exactly?
| return nil, fmt.Errorf("Error creating directory for image %s: %w", destination, err) | ||
| if !dryRun { | ||
| // the directory holding the image must be created here | ||
| if err = os.MkdirAll(destination, 0755); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m afraid I don’t think this works, in general: below, directory.Transport.ParseReference requires the parent directory to exist. We’d need to defer the parsing into a typed ImageReference, and deal with untyped strings in the meantime :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My personal preference would be to expect the parent directory to already exist since this would avoid creating unwanted directories due to mistyping (not that I ever did this 😆) but we should check that the directory exists here and provide a proper error message instead of relying on ParseReference to catch this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parent directory is not always user-specified: with --scoped, trailing paths of the path come from the source repository name.
8b71882 to
cbefcd4
Compare
Since the destination exists, |
Signed-off-by: Jonas Switala <[email protected]>
…es in target dir Signed-off-by: Jonas Switala <[email protected]>
cbefcd4 to
efbac99
Compare
|
A friendly reminder that this PR had no activity for 30 days. |
skopeo sync --dry-run --dest dircurrently fails consecutive executions since thefunc destinationReferenceattempts to create directories even when running in dry-run mode and fails if these already exist.