Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Error: conversion error: error generating ACI: archive/tar: cannot encode header #259

Closed
zhsj opened this issue Feb 26, 2018 · 4 comments · Fixed by #260
Closed

Error: conversion error: error generating ACI: archive/tar: cannot encode header #259

zhsj opened this issue Feb 26, 2018 · 4 comments · Fixed by #260

Comments

@zhsj
Copy link
Contributor

zhsj commented Feb 26, 2018

While running docker2aci -debug docker://docker.elastic.co/kibana/kibana:6.1.3 it shows:

Error: conversion error: error generating ACI: archive/tar: cannot encode header: Format specifies USTAR; and USTAR cannot encode Linkname="rootfs/var/lib/yum/yumdb/a/6f8ba1fc41ecc5f60aac5b4b7aa28d2566c55481-audit-libs-2.7.6-3.el7-x86_64/from_repo"

The error comes from

if err := trw.WriteHeader(t.Header); err != nil {

t.Header.Format is USTAR here. The call to tar.WriteHeader triggers the error.

t.Header is parsed from

hdr, err := tarReader.Next()

which is also from Go std lib archive/tar.

So, I think the fault is not docker2aci. But should dokcer2aci do some tricks to work around this?

One approach is to unset the t.Header.Format, at least it works for me currently.

diff --git a/lib/internal/internal.go b/lib/internal/internal.go
index 1f811fc..d694c39 100644
--- a/lib/internal/internal.go
+++ b/lib/internal/internal.go
@@ -609,6 +609,7 @@ func writeACI(layer io.ReadSeeker, manifest schema.ImageManifest, curPwl []strin
        fileMap := make(map[string]struct{})
        var whiteouts []string
        convWalker := func(t *tarball.TarFile) error {
+               t.Header.Format = tar.FormatUnknown
                name := t.Name()
                if name == "./" {
                        return nil

Any suggestions?

@zhsj
Copy link
Contributor Author

zhsj commented Feb 26, 2018

The previous comment is false, the error is still in appc/docker2aci

t.Header.Linkname = path.Join("rootfs", t.Linkname())

Here, the len(Linkname) > 100, making the t.Header.Format which is USTAR invalid.

zhsj added a commit to zhsj/docker2aci that referenced this issue Feb 26, 2018
fix tar header format after manipulating the Name and Linkname.

Closes: appc#259
Signed-off-by: Shengjing Zhu <i@zhsj.me>
@lucab
Copy link
Contributor

lucab commented Apr 12, 2018

How did you build this docker2aci binary? I'm starting to suspect that this is a regression in Go 1.10. If I try with the binary attached to the github release or with one locally built with go-1.9, I can't seem to reproduce this.

@zhsj
Copy link
Contributor Author

zhsj commented Apr 12, 2018

@lucab tried myself, and I can confirm the binary on github release is fine. And the one built by Go 1.10 failed.

The build method is nothing special, just go build.

@lucab
Copy link
Contributor

lucab commented Apr 12, 2018

Thanks for confirming, that's also the behavior I see with a local go-1.10 build. I reported the regression to golang/go#24821, and I'd be happier if this turns out to be directly fixed in archive/tar.

lucab added a commit to lucab/coreos-overlay that referenced this issue Apr 12, 2018
This downgrade the golang toolchain used to build rkt, keeping it at
go1.9.
This is a temporary workaround for a go-1.10 regression in `archive/tar`.

Ref: coreos/bugs#2402
Ref: appc/docker2aci#259
Ref: golang/go#24821
lucab added a commit to lucab/coreos-overlay that referenced this issue Apr 12, 2018
This downgrades the golang toolchain used to build rkt, keeping it at
go1.9.
This is a temporary workaround for a go-1.10 regression in `archive/tar`.

Ref: coreos/bugs#2402
Ref: appc/docker2aci#259
Ref: golang/go#24821
lucab added a commit to lucab/coreos-overlay that referenced this issue Apr 12, 2018
This downgrades the golang toolchain used to build rkt, keeping it at
go1.9.
This is a temporary workaround for a go-1.10 regression in `archive/tar`.

Ref: coreos/bugs#2402
Ref: appc/docker2aci#259
Ref: golang/go#24821
zhsj added a commit to zhsj/docker2aci that referenced this issue Apr 12, 2018
After manipulating the Name and Linkname, the orignal Header format may
be invalid.

Start from Go 1.10, the Header format is stored in the Header struct.

>For forward compatibility, users that retrieve a Header from Reader.Next,
>mutate it in some ways, and then pass it back to Writer.WriteHeader should
>do so by creating a new Header and copying the fields that they are
>interested in preserving.

The copied fields are taken from all the fields presented in Go 1.6.

Ref: golang/go#24821
Closes: appc#259
Signed-off-by: Shengjing Zhu <i@zhsj.me>
zhsj added a commit to zhsj/docker2aci that referenced this issue Apr 12, 2018
After manipulating the Name and Linkname, the orignal Header format may
be invalid.

Starting from Go 1.10, the Header format is stored in the Header struct.

>For forward compatibility, users that retrieve a Header from Reader.Next,
>mutate it in some ways, and then pass it back to Writer.WriteHeader should
>do so by creating a new Header and copying the fields that they are
>interested in preserving.

The copied fields are taken from all the fields presented in Go 1.6.

Ref: golang/go#24821
Closes: appc#259
Signed-off-by: Shengjing Zhu <i@zhsj.me>
lucab added a commit to lucab/coreos-overlay that referenced this issue Apr 13, 2018
This downgrades the golang toolchain used to build rkt, keeping it at
go1.9.
This is a temporary workaround for a go-1.10 regression in `archive/tar`.

Ref: coreos/bugs#2402
Ref: appc/docker2aci#259
Ref: golang/go#24821
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants