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

Fix build and use go modules for build #435

Merged
merged 3 commits into from
May 12, 2021

Conversation

gnufied
Copy link
Contributor

@gnufied gnufied commented May 22, 2020

Use go modules to pin dependency versions.

Fixes #434

@gnufied gnufied changed the title {WIP} Fix grpc build {WIP} Fix build and use go modules for build May 22, 2020
@gnufied gnufied changed the title {WIP} Fix build and use go modules for build Fix build and use go modules for build May 22, 2020
.travis.yml Outdated
@@ -29,7 +29,7 @@ jobs:
# Lang stage: Go
- stage: lang
language: go
go: 1.10.4
go: 1.13.8
Copy link
Contributor

Choose a reason for hiding this comment

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

may be we could use go version go1.14.2 linux/amd64

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to use slightly older version on purpose, since go 1.14 was released just couple of months ago. I can change it though.

lib/go/go.sum Outdated
@@ -0,0 +1,51 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
Copy link
Member

Choose a reason for hiding this comment

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

does go mod tidy clean up this dep list at all? there's a ton here..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it does not. If anything it seems to be adding one more (duplicate) dependecy:

diff --git a/lib/go/go.sum b/lib/go/go.sum
index 6f6d303..ca54368 100644
--- a/lib/go/go.sum
+++ b/lib/go/go.sum
@@ -12,6 +12,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
 github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
 github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
 github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=

lib/go/go.mod Outdated
@@ -0,0 +1,8 @@
module github.com/container-storage-interface/spec/lib/go/csi
Copy link
Member

Choose a reason for hiding this comment

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

maybe this go.mod file should be moved into lib/go/csi instead of keeping it adjacent to the Makefile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, it seems logical to have it here since top level csi package declaration exists in this directory.

Copy link
Member

Choose a reason for hiding this comment

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

it looks like the (empty) top level file was put there to satisfy go-dep, which didn't support multiple modules per repo unlike go mod. i'd rather be more precise with our module definitions.

would strongly prefer to move the go.mod file as suggested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, this is tricker. I am okay with moving go.mod file to csi directory but it looks like even though our build is green, having go.mod file in a subdirectory prevents the csi module from being usable.

afaict - if we want to use go modules, we will have to place go.mod at the root of the repo.

Copy link
Member

@jieyu jieyu left a comment

Choose a reason for hiding this comment

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

LGTM

@saad-ali
Copy link
Member

I'll let @jdef review and approve this.

@gnufied gnufied force-pushed the fix-grpc-build branch 3 times, most recently from b159550 to 1e5a9bd Compare May 28, 2020 20:04
@gnufied
Copy link
Contributor Author

gnufied commented May 28, 2020

@jdef @jieyu To fix the build and keep import paths same - I had to move go.mod file to root of the project. But I have verified by importing it in bunch of project and it works same as before. I do not see a way around this if we want to use go modules.

@jieyu
Copy link
Member

jieyu commented May 28, 2020

@gnufied have you tried placing go.mod in both the root dir and in lib/go/csi (like many multiple module go project)?

@gnufied
Copy link
Contributor Author

gnufied commented May 28, 2020

@jieyu I have and it looks like exporting/publishing a module from a subdirectory is treated different from how local multiple modules refer each other from same repo.

Take https://github.com/gnufied/sandbox2/tree/v1.8.0 for example. If you go get

~> go get github.com/gnufied/[email protected]
# you get an empty clone in pkg/mod/github.com/gnufied/[email protected] with just go.mod file

# get nested module
~> go get github.com/gnufied/sandbox2/lib/spec/[email protected]
go: finding github.com/gnufied/sandbox2/lib/spec v1.8.0
go: finding github.com v1.8.0
go: finding github.com/gnufied v1.8.0
go: finding github.com/gnufied/sandbox2/lib/spec/sandbox2 v1.8.0
go: finding github.com/gnufied/sandbox2/lib v1.8.0
go get github.com/gnufied/sandbox2/lib/spec/[email protected]: module github.com/gnufied/[email protected] found, but does not contain package github.com/gnufied/sandbox2/lib/spec/sandbox2

@jdef
Copy link
Member

jdef commented May 28, 2020 via email

@gnufied
Copy link
Contributor Author

gnufied commented May 28, 2020

@jdef the trick is - we will have to probably pin grpc-go and https://github.com/googleapis/go-genproto - so it gets bit uglier as time flies.

This PR however works at the cost of having go.mod file at root level. For example:

# This runs k8s unit tests by replacing github.com/container-storage-interface
# with github.com/gnufied/1.6.0 which is built from this PR.
go: downloading github.com/gnufied/spec v1.6.0
go: extracting github.com/gnufied/spec v1.6.0
go: finding github.com/gnufied/spec v1.6.0
=== RUN   TestNodeExpandVolume
--- PASS: TestNodeExpandVolume (0.00s)

Alternately we can start thinking about moving language bindings in their own repo, which will be more cleaner (and may be take the bitter pill of pinning version via Makefile for now)

@xing-yang
Copy link
Contributor

LGTM

@saad-ali
Copy link
Member

Discussed this offline. Given the concerns that @jdef raised, and since we are so close to cutting a CSI 1.3, we agreed to go with the less risky (but more hacky) approach (patch the makefile to pin the grpc-go version), and move to go mod approach afterwards for the CSI 1.4 release. This is just to mitigate unforeseen issues with switching to go modules and rushing the decision before we can think it though.

Thank you @gnufied for your patience and for driving this!

@saad-ali
Copy link
Member

saad-ali commented May 7, 2021

maybe we should not yet upgrade to go.mod and instead patch the makefile to
pin the grpc-go version like it already does for protobufs

Doesn't look like there is a cleaner way to do this. golang/go#34055 asks for the ability to serve a module from a subdirectory but the proposed solution won't work for us because it depends on being able to return a <meta name="go-import" ...> tag which we can't do on github repos (see golang/go#34055 (comment)).

maybe we should not yet upgrade to go.mod and instead patch the makefile to
pin the grpc-go version like it already does for protobufs

Pinning dependencies in this way is a game of whack-a-mole. For example, the build is broken again right now.

Alternately we can start thinking about moving language bindings in their own repo, which will be more cleaner (and may be take the bitter pill of pinning version via Makefile for now)

That seems like a lot of unnecessary overhead.

This PR however works at the cost of having go.mod file at root level. For example:

I am in favor of this approach. go.mod at root is a little ugly but not the end of the world. Overall the benefit of go modules to fix dependencies vs existing solution outweighs the drawback, IMO.

@gnufied
Copy link
Contributor Author

gnufied commented May 10, 2021

@saad-ali @jdef I have updated the branch and tested and verified that using via go get or go mod works.

@saad-ali
Copy link
Member

Thanks @gnufied

/lgtm

Anyone have any objections to this change?

Copy link
Contributor

@ddebroy ddebroy left a comment

Choose a reason for hiding this comment

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

/lgtm

@@ -29,10 +29,10 @@ jobs:
# Lang stage: Go
- stage: lang
language: go
go: 1.10.4
go: 1.16.4
Copy link
Contributor

@ddebroy ddebroy May 12, 2021

Choose a reason for hiding this comment

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

Huge bump here :-) but nice!

@humblec
Copy link
Contributor

humblec commented May 12, 2021

Thanks @gnufied

/lgtm

Anyone have any objections to this change?

lgtm from my side as well 👍

@saad-ali
Copy link
Member

Thanks everyone, merging!

@saad-ali saad-ali merged commit 5914b37 into container-storage-interface:master May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Floating grpc dependencies and build failures
7 participants