imgpkg: Copy fails when we try to copy to the root of the destination registry
What steps did you take:
When copying an image to a registry which has no repository or no folder beneath it, it fails.
imgpkg copy -i nginx --to-repo ip-10-0-0-146.ap-south-1.compute.internal/
or
imgpkg copy -i nginx --to-repo ip-10-0-0-146.ap-south-1.compute.internal
What happened: The image copy fails with the following error message:
root@ip-172-32-0-87:~# imgpkg copy -i nginx --to-repo ip-10-0-0-146.ap-south-1.compute.internal/
0 B / ? [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------=] 0.00% 2562047h47m16s
copy | done importing images
Error: Building import repository ref: repository must be between 2 and 255 runes in length:
root@ip-172-32-0-87:~# imgpkg copy -i nginx --to-repo ip-10-0-0-146.ap-south-1.compute.internal
copy | exporting 1 images...
copy | will export index.docker.io/library/nginx@sha256:1c70a669bbf07f9862f269162d776c35144b116938d1becb4e4676270cff8f75
copy | exported 1 images
copy | importing 1 images...
panic: send on closed channel
panic: close of closed channel
goroutine 1 [running]:
github.com/google/go-containerregistry/pkg/v1/remote.sendError(...)
github.com/google/go-containerregistry@v0.5.0/pkg/v1/remote/write.go:185
github.com/google/go-containerregistry/pkg/v1/remote.MultiWrite.func1(0xc000274380, 0xc0000e1360)
github.com/google/go-containerregistry@v0.5.0/pkg/v1/remote/multi_write.go:99 +0x85
github.com/google/go-containerregistry/pkg/v1/remote.MultiWrite(0xc00008e270, 0xc0002367c0, 0x4, 0x4, 0x98e400, 0xc0003030c0)
github.com/google/go-containerregistry@v0.5.0/pkg/v1/remote/multi_write.go:160 +0x1220
github.com/k14s/imgpkg/pkg/imgpkg/registry.Registry.MultiWrite.func1(0x3b9aca00, 0xc00009e1c0)
github.com/k14s/imgpkg/pkg/imgpkg/registry/registry.go:112 +0x89
github.com/k14s/imgpkg/pkg/imgpkg/util.Retry(0xc0000e1438, 0x60, 0xc025e0)
github.com/k14s/imgpkg/pkg/imgpkg/util/retry.go:25 +0xa3
github.com/k14s/imgpkg/pkg/imgpkg/registry.Registry.MultiWrite(0xc0002367c0, 0x3, 0x4, 0x0, 0x0, 0x0, 0xc00008e270, 0x5, 0x44132e, 0xc0000e14e0)
github.com/k14s/imgpkg/pkg/imgpkg/registry/registry.go:111 +0x99
github.com/k14s/imgpkg/pkg/imgpkg/imageset.(*ImageSet).Import(0xc0004c53e0, 0xc000030540, 0x1, 0x1, 0x0, 0x90079e, 0xf, 0x7ffdb9e077ee, 0x29, 0x99a458, ...)
github.com/k14s/imgpkg/pkg/imgpkg/imageset/image_set.go:114 +0x342
github.com/k14s/imgpkg/pkg/imgpkg/imageset.ImageSet.Relocate(0x5, 0x98e580, 0xc00026c1e0, 0xc00000e0a8, 0x0, 0x90079e, 0xf, 0x7ffdb9e077ee, 0x29, 0x99a458, ...)
github.com/k14s/imgpkg/pkg/imgpkg/imageset/image_set.go:48 +0x1d6
github.com/k14s/imgpkg/pkg/imgpkg/cmd.CopyRepoSrc.CopyToRepo(0x7ffdb9e077de, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x992360, 0xc00026c1e0, ...)
github.com/k14s/imgpkg/pkg/imgpkg/cmd/copy_repo_src.go:57 +0x257
github.com/k14s/imgpkg/pkg/imgpkg/cmd.(*CopyOptions).Run(0xc000150000, 0x0, 0x0)
github.com/k14s/imgpkg/pkg/imgpkg/cmd/copy.go:140 +0xd28
github.com/k14s/imgpkg/pkg/imgpkg/cmd.NewCopyCmd.func1(0xc000142f00, 0xc00009f080, 0x0, 0x4, 0x0, 0x0)
github.com/k14s/imgpkg/pkg/imgpkg/cmd/copy.go:44 +0x2a
github.com/cppforlife/cobrautil.WrapRunEForCmd.func1.1(0xc000142f00, 0xc00009f080, 0x0, 0x4, 0x0, 0x0)
github.com/cppforlife/cobrautil@v0.0.0-20200514214827-bb86e6965d72/misc.go:45 +0xb2
github.com/cppforlife/cobrautil.WrapRunEForCmd.func1.1(0xc000142f00, 0xc00009f080, 0x0, 0x4, 0x0, 0x0)
github.com/cppforlife/cobrautil@v0.0.0-20200514214827-bb86e6965d72/misc.go:45 +0xb2
github.com/cppforlife/cobrautil.WrapRunEForCmd.func1.1(0xc000142f00, 0xc00009f080, 0x0, 0x4, 0x0, 0x0)
github.com/cppforlife/cobrautil@v0.0.0-20200514214827-bb86e6965d72/misc.go:45 +0xb2
github.com/spf13/cobra.(*Command).execute(0xc000142f00, 0xc00009f040, 0x4, 0x4, 0xc000142f00, 0xc00009f040)
github.com/spf13/cobra@v1.1.3/command.go:852 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc000142500, 0xc000142500, 0xc00009ecc0, 0xc000040748)
github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.1.3/command.go:897
main.main()
github.com/k14s/imgpkg/cmd/imgpkg/imgpkg.go:30 +0x188
What did you expect: It should succeed or display a clear error message stating the reason for failure.
Anything else you would like to add: NA
Environment:
- imgpkg version (use
imgpkg --version
): imgpkg version 0.8.0 - Docker registry used (e.g.
Docker HUB
): source is Docker Hub and destination registry is private docker registry - OS (e.g. from
/etc/os-release
): Ubuntu 20.04.2 LTS (Focal Fossa)
Vote on this request
This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the “smiley face” up to the right of this comment to vote.
👍 “I would like to see this addressed as soon as possible” 👎 “There are other more important things to focus on right now”
We are also happy to receive and review Pull Requests if you want to help working on this issue.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 7
- Comments: 17 (7 by maintainers)
In skopeo or docker, you do not need to append the image name to the end of the destination repo, it would be good if we could do the same with imgpkg so the destination name automatically gets used if the user does not specify it
imgpkg copy -i nginx --to-repo ip-10-0-0-146.ap-south-1.compute.internal/
would result inimgpkg copy -i nginx --to-repo ip-10-0-0-146.ap-south-1.compute.internal/nginx
This makes it much easier to automate and loop over
{{.SrcRepo}}
would definitely work for my use case, where I just want to take a BundleLock file and move it from one place to the next, preserving the entirety of the path. So if my image was originalplace.com/someproject/somegroup/yadda/nginx:1.0.0 it would get moved to newplace.com/someproject/somegroup/yadda/nginx:1.0.0 and the contents of{{.SrcRepo}}
would besomeproject/somegroup/yadda/nginx
and the BundleLock file would contain the tag reference 1.0.0.While not ideal, one workaround that we’ve been using is some
sed
magic. Being able to replace this with a native capability would be fantastic. For those that need a temporary workaround, here’s how we’re doing it: https://gist.github.com/voor/7b63796b891297f04de7ac1a6b7d601dThanks @cppforlife for the suggestion!
Curious to hear what folk (@perithompson @mjangi9292) think about instead of a trailing slash, using a template structure
{{.SrcRepo}}
to indicate that the source repo should be retainedbut, with a slash (per original comment)