RichardKnop/go-oauth2-server

docker-compose up fails

Closed this issue ยท 5 comments

What?

On doing docker-compose up it fails.

 ---> Running in d493c374f60e
# github.com/RichardKnop/go-oauth2-server/vendor/github.com/coreos/etcd/clientv3
vendor/github.com/coreos/etcd/clientv3/client.go:336:9: undefined: metadata.NewContext
vendor/github.com/coreos/etcd/clientv3/lease.go:326:14: undefined: metadata.FromContext
ERROR: Service 'app_testdata' failed to build: The command '/bin/sh -c go install github.com/RichardKnop/go-oauth2-server' returned a non-zero code: 2

I ran into the same issue, but had an old version kicking around that I knew was good so I ran a bisect...
Fyi revisions prior to 5643078b3726deec7b1fbe522cb55f7baa368512 seem to at least build correctly...

Didn't dig into why... just was happy to have a working version :)

5643078b3726deec7b1fbe522cb55f7baa368512 is the first bad commit
commit 5643078b3726deec7b1fbe522cb55f7baa368512
Author: Richard Knop <risoknop@gmail.com>
Date:   Wed Oct 11 12:26:19 2017 +0100

    Updated dependencies.

:100644 100644 eee370a1dc8006ec99bb6b61417709c636ce48f5 7700d1cc73131c28d3b7e1bc53d6e698f9b0dc02 M	Gopkg.lock
:100644 100644 b52736635ac54378f0fc5727deae9794be6c7282 21d4b93c06d973a68b447ff139556ae7ef4b4391 M	Gopkg.toml
:040000 040000 1a8e70e68ffd27ec2041e5c0dec5e662adc20c2e 4bd9ac19fb4ac02a18cd5dfc9ce0b3ea6d585652 M	vendor
bisect run success
stephen@stelau-ubuntu:~/code/go-oauth2-server$ git st

@alok87 thanks for bringing this to my attention. I think I can help here.

There are a couple of issues.

  • The undefined errors during build are caused by wrong version of google.golang.org/grpc (v1.6.0 according to Gopkg.lock), which is a transitive dependency, not directly used by go-oauth2-server but by github.com/coreos/etcd. coreos/etcd v3.2.9, works with grpc v1.5.x, but not with the latest releases of grpc. Since coreos/etcd isn't using dep and dep doesn't knows which version of grpc to use, it fetches the latest release. Hence, the build fails due to incompatible APIs of different versions of grpc. This can be fixed if coreos/etcd adopts dep and specifies a version constraint for grpc. But for now, we can fix it ourself by adding an override for grpc, constraining to ~v1.5.0. Overrides are not recommended, but for now it's fine to use it. Can be removed in the future.
  • The Gopkg.toml and Gopkg.lock files look old and are not compatible with new releases of dep. I think this was before dep's first release v0.1.0, at which dep made a promise to not change the two files.
  • Dependencies without any version, branch or revision in the Gopkg.toml file. The dependencies in Gopkg.toml should have a corresponding version constraint with them.

I spent some time and fixed these issues by touching only the Gopkg.toml and Gopkg.lockfiles, and vendoring the new versions of the dependencies. I'll submit a PR with the fix.

Hope it helps ๐Ÿ™‚

@alok87 i got these errors and made changes to vendor/github.com/coreos/etcd/clientv3/client.go and lease.go files
change line 336 in client.go "return metadata.NewOutgoingContext(ctx, md)" change NewContext to NewOutgoingContext as it is deprecated by gRPC (go-kit/kit#597)
change line 326 in lease.go "md, ok := metadata.FromIncomingContext(ctx)" change FromContext to FromIncomingContext as it is deprecated by gRPC (go-kit/kit#597)

then ran docker-compose up it worked like a charm

@telangovan @alok87 @toshi38 This should be fixed now thanks to @darkowlzz .

You might need to run docker-compose up --build for the first time. After that docker-compose up and docker-compose down should be sufficient to bring the server up and down.