Skip to content
This repository was archived by the owner on Nov 19, 2026. It is now read-only.

Unit test for golang gzip backward compatibility - #136

Merged
runcom merged 1 commit into
containers:masterfrom
jwhonce:wip/validate_gzip
Oct 31, 2016
Merged

runcom merged 1 commit into
containers:masterfrom
jwhonce:wip/validate_gzip

Conversation

@jwhonce

@jwhonce jwhonce commented Oct 24, 2016

Copy link
Copy Markdown
Member

Signing and several other new features depend on golang's gzip returning
consistent results, this test is designed to fail if golang should
change its implementation

https://trello.com/c/xSzKLN6O

Signed-off-by: Jhon Honce [email protected]

@jwhonce

jwhonce commented Oct 24, 2016

Copy link
Copy Markdown
Member Author

@vbatts @runcom Please review. TIA

Comment thread copy/validate_gzip_test.go Outdated
require.NoError(t, err, "gzipWriterTest_")
//defer os.Remove(output.Name())

zip := gzip.NewWriter(output)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zip.Close() should be called after this line with defer zip.Close()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see it's in a for loop, maybe we just need to use if/else instead of NoError stuff and close the writer on errors /cc @mtrmac

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@runcom Writer needs to be closed before I can read back results.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm my bad then

Comment thread copy/validate_gzip_test.go Outdated
for _, test := range cases {
payload, err := ioutil.ReadFile(test.name)

output, err := ioutil.TempFile(os.TempDir(), "gzipWriterTest_")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn’t this just use a bytes.Buffer or something? (Not blocking as such, and does not resolve the fundamental issues of course.)

@mtrmac

mtrmac commented Oct 25, 2016

Copy link
Copy Markdown
Collaborator

Signing and several other new features depend on golang's gzip returning consistent results,

Um, no? What depends on this beside signing?

For signing,

  1. I still fundamentally disagree that “repeated $something push should preserve signatures” is a goal to be achieved. I am aware of no other case where there is any expectation that extracting and reassembling the archive will, without extra infrastructure, result in the unmodified original.
  2. copy.Image for signed images does not care: it knows when the source is signed, and knows to not re-compress the layers so that the signatures are preserved.
  3. For copy.Image as a workhorse for atomic push, this could preserve the layer digests but it does nothing for preserving the manifest; and an ABI promise that pushing a pulled image back, using a possibly different version of Docker and skopeo, will generate a byte-for-byte the same manifest, is never happening. Besides implementation concerns, Docker or OCI might add new fields to the the manifest format at any time in the future.
  4. As part of the “container image tracking” cards, we might be saving the original manifests, and perhaps even tracking where we got the original layer tarballs from. Using that kind of data to copy the original image content seems a much more plausible way to save the original image content elsewhere (but still a lot of complexity and overhead compared to a direct skopeo copy docker://… docker://…)

Finally, if this test ever fails, what is our plan?

@vbatts

vbatts commented Oct 25, 2016

Copy link
Copy Markdown
Contributor

On 25/10/16 07:15 -0700, Miloslav Trmač wrote:

Signing and several other new features depend on golang's gzip returning consistent results,

Um, no? What depends on this beside signing?

For signing,

  1. I still fundamentally disagree that “repeated $something push should preserve signatures” is a goal to be achieved. I am aware of no other case where there is any expectation that extracting and reassembling the archive will, without extra infrastructure, result in the unmodified original.
  2. copy.Image for signed images does not care: it knows when the source is signed, and knows to not re-compress the layers so that the signatures are preserved.
  3. For copy.Image as a workhorse for atomic push, this could preserve the layer digests but it does nothing for preserving the manifest; and an ABI promise that pushing a pulled image back, using a possibly different version of Docker and skopeo, will generate a byte-for-byte the same manifest, is never happening. Besides implementation concerns, Docker or OCI might add new fields to the the manifest format at any time in the future.
  4. As part of the “container image tracking” cards, we might be saving the original manifests, and perhaps even tracking where we got the original layer tarballs from. Using that kind of data to copy the original image content seems a much more plausible way to save the original image content elsewhere (but still a lot of complexity and overhead compared to a direct skopeo copy docker://… docker://…)

Finally, if this test ever fails, what is our plan?

This is not because the signing depends on it, but the stability of
the signed content does.
If it fails, then:

  • open issue upstream golang
  • carry a copy of the previous version

@vbatts

vbatts commented Oct 25, 2016

Copy link
Copy Markdown
Contributor

On 25/10/16 07:14 -0700, Miloslav Trmač wrote:

mtrmac commented on this pull request.

Couldn’t this just use a bytes.Buffer or something? (Not blocking as such, and does not resolve the fundamental issues of course.)

+1

@mtrmac

mtrmac commented Oct 26, 2016

Copy link
Copy Markdown
Collaborator

Signing and several other new features depend on golang's gzip returning consistent results,

Um, no? What depends on this beside signing?

This is not because the signing depends on it, but the stability of the signed content does.

The signed content is by definition stable when it is copied around as the blobs that are stored in registries (skopeo copy). The implied “stability” requirement AFAICT comes from the idea that atomic pull + atomic push should reproduce the original and preserve signatures. (While I disagree that this is a natural way to copy things, let’s take that as a given for the purposes of this comment:) Reproducing the original manifest and layers still isn’t sufficient for the use case, because atomic pull does not pull the signatures along to the local daemon, so atomic push does not copy them to the destination either. So, even if the content were completely preserved by pull+push, pull+push still drops all signatures as of now! And even if we added the code to store manifests+signatures on docker pull, that still wouldn’t work without the user setting up sigstores for the sources and destinations.

AFAICT, whatever we do, copying images around including the signatures and keeping the signatures valid requires users to change their workflow.

So, why not point them to a workflow which will 1) by definition and construction always reliably work 2) do a much more efficient direct copy without extracting tarballs and making temporary copies all over /var/tmp; instead of spending all of this effort and worry on a workflow which can be broken at any time for good reasons (what if gzip needs to change because right now it is compressing some inputs incorrectly? What if a new non-empty field will be added to the manifest by default in newer versions?), and will require extra maintenance effort, only to let users use a workflow a bit more similar to what they currently use (when what they currently use is already unnecessarily inefficient?).

@runcom runcom mentioned this pull request Oct 27, 2016
@mtrmac

mtrmac commented Oct 27, 2016 •

Copy link
Copy Markdown
Collaborator

👍 pending tests. (I still don’t like the concept, but it doesn’t break anything. Advance warning: If this test ever fails, and nobody else steps up to handle this, I will very likely “fix” the failure by dropping the test.)

Approved with PullApprove

@runcom

runcom commented Oct 27, 2016

Copy link
Copy Markdown
Member

tests busted with golang 1.6 (#137) figuring out how to fix them other than just refusing golang 1.6 and working with 1.7 from now on.

@rhatdan

rhatdan commented Oct 27, 2016

Copy link
Copy Markdown
Member

Why not just work with golang 1.7 and be done with it.

@runcom

runcom commented Oct 27, 2016

Copy link
Copy Markdown
Member

I will be fine with that I guess, @mtrmac ?

@mtrmac

mtrmac commented Oct 27, 2016

Copy link
Copy Markdown
Collaborator

If this works for relevant downstreams, sure, why not. I like new toys 😁

@runcom

runcom commented Oct 28, 2016

Copy link
Copy Markdown
Member

@jwhonce Please rebase, I'll merge afterward

Signing and several other new features depend on golang's gzip returning
  consistent results, this test is designed to fail if golang should
  change its implementation

https://trello.com/c/xSzKLN6O

Signed-off-by: Jhon Honce <[email protected]>
@runcom

runcom commented Oct 31, 2016 •

Copy link
Copy Markdown
Member

LGTM

Approved with PullApprove

@runcom
runcom merged commit afcad23 into containers:master Oct 31, 2016
@mtrmac

mtrmac commented Oct 31, 2016 •

Copy link
Copy Markdown
Collaborator

Hum, with F24, golang-1.6.3-3.fc24.x86_64 , gzip-1.6-10.fc24.x86_64 :

--- FAIL: TestGzipWriter (0.04s)
        Error Trace:    validate_gzip_test.go:52
    Error:      Not equal: "89ec079aa14317e6a96c53dc22081ec054c47533cea5858cc18644bfb148a363" (expected)
                    != "1d0271b822852793e787337dec0d8287e590260593f1c296f9f706df503d7b2c" (actual)
    Messages:   Invalid payload sha256: fixtures/random_512k.bin

Now what?

(This makes my development work noticeably harder.)

@jwhonce

jwhonce commented Oct 31, 2016

Copy link
Copy Markdown
Member Author

@mtrmac I will look into what is different here.

@mtrmac

mtrmac commented Nov 7, 2016

Copy link
Copy Markdown
Collaborator

A week later… I have taken a quick look, and based on https://go.googlesource.com/go/+log/master/src/compress I’m fairly sure we don’t have anyone available to commit to maintaining a viable fork of the upstream compression implementation. So, proposing #157 .

giuseppe pushed a commit to giuseppe/image that referenced this pull request Jan 24, 2017
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 this pull request may close these issues.

5 participants