Skip to content
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

gomod-zip: use golang.org/x/mod/zip for creating zip file #254

Merged
merged 1 commit into from
Apr 26, 2021

Conversation

nikhita
Copy link
Member

@nikhita nikhita commented Apr 21, 2021

The zip file created by gomod-zip no longer matches the zip file created
by go mod directly. The initial gomod-zip code copied Go's code
(at https://github.com/golang/go/blob/4d56576ec02e3e3b4459bc23eb1601e6e96f3cfc/src/cmd/go/internal/modfetch/coderepo.go#L940)
but has diverged now.

Go now extracts the logic to create the zip file in golang.org/x/mod/zip:
https://github.com/golang/mod/blob/master/zip/zip.go so this commit
updates gomod-zip to use modzip.

The version of golang.org/x/mod is pinned to the version that
go uses - https://github.com/golang/go/blob/952187af12485eb665ae122f6d0bdb36e4a11ed7/src/cmd/go.mod#L9
i.e. v0.4.3-0.20210409134425-858fdbee9c24.
We will need to update this version whenever go changes it to ensure that
we don't create different zip files. Otherwise, this will lead to a
checksum error.

/assign @sttts @dims

The zip file created by gomod-zip no longer matches the zip file created
by go mod directly. The initial gomod-zip code copied Go's code
(at https://github.com/golang/go/blob/4d56576ec02e3e3b4459bc23eb1601e6e96f3cfc/src/cmd/go/internal/modfetch/coderepo.go#L940)
but has diverged now.

Go now extracts the logic to create the zip file in `golang.org/x/mod/zip`:
https://github.com/golang/mod/blob/master/zip/zip.go so this commit
updates gomod-zip to use modzip.

The version of `golang.org/x/mod` is pinned to the version that
go uses - https://github.com/golang/go/blob/952187af12485eb665ae122f6d0bdb36e4a11ed7/src/cmd/go.mod#L9
i.e. `v0.4.3-0.20210409134425-858fdbee9c24`.
We will need to update this version whenever go changes it to ensure that
we don't create different zip files. Otherwise, this will lead to a
checksum error.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 21, 2021
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 21, 2021
@nikhita
Copy link
Member Author

nikhita commented Apr 21, 2021

/hold
I'd like to test this against all our branches/go versions to ensure this doesn't have different behavior across different go versions

Opened the PR in case anyone had initial reviews

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 21, 2021
@nikhita
Copy link
Member Author

nikhita commented Apr 21, 2021

We will need to update this version whenever go changes it to ensure that
we don't create different zip files. Otherwise, this will lead to a
checksum error.

We can get rid of this when (and if) go implements golang/go#33312

@dims
Copy link
Member

dims commented Apr 21, 2021

the unified diff looks awful :) the side-by-side diff shows the new code looks much better. thanks @nikhita

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 21, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims, nikhita

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@nikhita
Copy link
Member Author

nikhita commented Apr 26, 2021

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 26, 2021
@k8s-ci-robot k8s-ci-robot merged commit 29bcc9a into kubernetes:master Apr 26, 2021
@nikhita nikhita deleted the gomod-zip-fix branch April 26, 2021 06:27
@nikhita
Copy link
Member Author

nikhita commented Apr 26, 2021

This fixed the error for release-1.19 and release-1.20 branches, but the bot still tripped for release-1.21 because the current published go.sum already contains wrong hash values. Created #255 to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants