Skip to content

Conversation

@frq-asgard-josi
Copy link

@frq-asgard-josi frq-asgard-josi commented Jul 18, 2025

skopeo sync --dry-run --dest dir currently fails consecutive executions since the func destinationReference attempts to create directories even when running in dry-run mode and fails if these already exist.

@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@packit-as-a-service
Copy link

Tests failed. @containers/packit-build please check.

Copy link
Contributor

@mtrmac mtrmac left a 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 {
Copy link
Contributor

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 :/

Copy link
Author

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.

Copy link
Contributor

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.

@frq-asgard-josi
Copy link
Author

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?

Since the destination exists, os.Stat(destination) doesn't return any err and we return Refusing to overwrite destination directory (Line 179)

@mtrmac mtrmac added the kind/bug A defect in an existing functionality (or a PR fixing it) label Jul 28, 2025
@github-actions
Copy link

A friendly reminder that this PR had no activity for 30 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug A defect in an existing functionality (or a PR fixing it) stale-pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants