-
Notifications
You must be signed in to change notification settings - Fork 149
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
Switch to go modules #188
Switch to go modules #188
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bswartz If they are not already assigned, you can assign the PR to them by writing 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 |
/assign lpabon |
Is this still using the "vendor" directory? I ran "make test" in /tmp/csi-test and got lots of "finding" and "downloading" messages:
I think we still want to maintain and use the "vendor" directory, to avoid having to reach out to all those repos during a CI build. Also this:
|
From what I understand, go modules obsoletes the use of vendor directories. Now instead there is a "module cache" located at $GOPATH/pkg/mod which serves the same purpose the vendor directory used to serve. The benefit of the module cache is that it can store more than 1 version of each package, and it can be stored outside your git repo (dramatically reducing the size of most git repos). CI builds rely on module caches/mirrors like Athens to avoid hitting the internet. |
Thanks for reminding me that I forgot to delete the vendor directory with this change. That is done now. |
FYI, an overview of go modules: https://www.youtube.com/watch?v=OrMA16ASz2U |
Ben Swartzlander <[email protected]> writes:
> Is this still using the "vendor" directory?
>
> I think we still want to maintain and use the "vendor" directory, to avoid having to reach out to all those repos during a CI build.
From what I understand, go modules obsoletes the use of vendor
directories.
No, not necessarily:
https://github.com/golang/go/wiki/Modules#how-do-i-use-vendoring-with-modules-is-vendoring-going-away
"The initial series of vgo blog posts did propose dropping vendoring
entirely, but feedback from the community resulted in retaining support
for vendoring."
BTW, that FAQ also explains why I was seeing packages being downloaded:
one has to explicitly enable the use of the "vendor" directory with
-mod=vendor or GOFLAGS=-mod=vendor.
The benefit of the module cache is that it can store more than 1
version of each package,
That should also be true for the "vendor" directory.
and it can be stored outside your git repo
(dramatically reducing the size of most git repos).
Has that been a problem? Just wondering.
CI builds rely on module caches/mirrors like Athena to avoid hitting
the internet.
Do we have or will we have that when building in Prow?
|
Thanks for this helpful link. I didn't find that information in my reading about go modules.
I think that for most projects, the size of the vendor directory exceeds the size of the project's code by a factor of 10 or even 100. In practice this means that you'll hit any scaling problems 10-100x sooner than you otherwise would. For small projects this doesn't matter much, but I still don't like being wasteful.
That's a good question. Since k8s is switching to go modules fairly aggressively I assume some kind of solution is in place, but I haven't looked at the specifics. I will read up on how to keep the vendored stuff because I'd like to add go module support with minimal disruptions. |
Ben Swartzlander <[email protected]> writes:
>> CI builds rely on module caches/mirrors like Athena to avoid hitting the internet.
> Do we have or will we have that when building in Prow?
That's a good question. Since k8s is switching to go modules fairly
aggressively I assume some kind of solution is in place, but I haven't
looked at the specifics.
I asked on Slack. Catherine replied: "Currently everyone using modules
in kubernetes-land is still vendoring, I think. We do not currently have
a cache."
(https://kubernetes.slack.com/archives/C09QZ4DQB/p1554994915357100)
Ben and Steve confirmed that there is currently no cache.
Let's keep vendoring the files until we know for sure that dropping them
won't have a negative impact on the CI builds. CI builds happen in
$GOPATH with go 1.12, so they should be using the "vendor" dir
automatically.
Note that we have a CI test which runs "test-vendor". The build rules
for that currently assume that "dep" is used, and the check runs
entirely locally.
Writing a similar check for "go mod" will be a bit tricky. I don't know
whether "go mod verify" can be used without actually reaching out to all
repos. If so, then that would negate the purpose of having the vendor
directory.
|
I'll fix this. Thanks for the additional info |
@pohly PTAL |
You need to use a different trick for turning of test result caching:
But even then the /test pull-kubernetes-csi-csi-test |
You can try out a different implementation of the |
During the transition period, |
I checked that your branch can still be pulled into a project that uses |
Would one way to check be try loading all the pkgs and see if that results in a diff? |
If we do that for each PR, then it negates the purpose of having the sources vendored, because each build then needs to access all remote repos to do the checking. We could try to skip it in Prow under certain specific situations:
For normal developers, Sounds doable, albeit a bit complex. |
Here's a modified test-vendor check which implements that idea:
However, when I try that with go 1.12.1, I do get a test failure:
My version of go wrote the entries in a different order. I therefore only allow the test to be skipped if What do you think? Shall we put that into I created a PR, let's discuss there: kubernetes-csi/csi-release-tools#19 |
How a repo does vendoring is detected based on the presence of Gopkg.toml. The vendor check with `dep` was all done locally, but the corresponding check for `go mod` requires network access. The check therefore gets skipped when running in the Prow CI in situations where we are sure that it isn't needed (for example, in a periodic job).
@bswartz which version of go did you use to create the vendor directory? I am a bit worried that re-doing the vendoring with 1.12.1 leads to a small difference (see above). |
build.make: allow repos to use 'go mod' for vendoring
/assign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bswartz can you update release-tools
to the latest master, as described in release-tools/README/md
?
That should get rid of the test error.
I can't remember which go version I used. I currently have 1.12.4, and I'm going to switch to 1.12.5. I'll do what you suggest in your latest comment though. |
@pohly PTAL |
/hold Before merging let's have a chat how we'll roll this out to more repos. |
https://prow.k8s.io/view/gcs/kubernetes-jenkins/pr-logs/pull/kubernetes-csi_csi-test/188/pull-kubernetes-csi-csi-test/1129120593698885632 shows that the |
Discussed today in the CSI WG. The conclusion was to first finish the sidecar releases for 1.15 and do more experiments with "go mod" support in other repos (like csi-driver-host-path and csi-lib-utils). One question which needs to be answered: what happens if a repo switches to "go mod" and some other repo which still uses "dep" pulls that repo in? Will "dep" be able to apply the constraints specified in |
Looks like Kubernetes is going to rely on proxy.golang.org for caching dependencies: kubernetes/test-infra#13645 This means we could stop vendoring source code and just rely on that same cache? |
Sounds fine to me. We just need to set the GOPROXY env and update to go 1.13? |
Michelle Au <[email protected]> writes:
Sounds fine to me. We just need to set the GOPROXY env and update to
go 1.13?
The GOPROXY env var is only needed for go 1.12, 1.13 will enable it by
default.
If I read the test-infra issue correctly, all (?) Prow jobs will
automatically get GOPROXY set, so we might not have to do anything.
|
I'm sure someone has already thought about this, but using a proxy like that will dramatically increase reliance on network resources at build time compared to the vendoring approach. I'm surprised there's no plan to at least try to use a proxy that will be local to the build machines. |
Have a look at kubernetes/test-infra#13645. It has been discussed and the conclusion was that for all practical purposes, proxy.golang.org is local - it's apparently all hosted on Google Cloud. If that changes, then setting GOPROXY differently can still take care of that once the need arises. |
@pohly Thanks I forgot that golang is actually a google project and so it's unsurprising the proxy is hosted in the same place as the kubernetes build infra. Now I just need to figure out how to run my own proxy for my own builds. |
…-notes-docs SIDECAR_RELEASE_PROCESS.md: Update release-notes syntax
No description provided.