Etcd: Unable to get a working etcd client via go get

Created on 10 Nov 2020  路  4Comments  路  Source: etcd-io/etcd

After following instructions from both master and the v3.4.14 tag I am unable to install the etcd client given a clean install environment.

v3.4.14 - https://github.com/etcd-io/etcd/blob/v3.4.13/clientv3/README.md#install
master - https://github.com/etcd-io/etcd/blob/master/client/v3/README.md#install

Master

Given the following Dockerfile

FROM golang:1.15.4 as build

WORKDIR /go/src
ADD . /go/src

# As documented in 'master'
RUN go get go.etcd.io/etcd/client/v3

The following error results

Step 4/5 : RUN go get go.etcd.io/etcd/client/v3
 ---> Running in 406bea2a85e8
go: downloading go.etcd.io/etcd v0.5.0-alpha.5
go: downloading go.etcd.io/etcd/client/v3 v3.0.0-20201109164711-01844fd28560
go: downloading go.etcd.io/etcd v3.3.25+incompatible
go: go.etcd.io/etcd/client/v3 upgrade => v3.0.0-20201109164711-01844fd28560
go get: go.etcd.io/etcd/client/[email protected] requires
        go.etcd.io/etcd/api/[email protected]: invalid version: unknown revision 000000000000

v3.4.14

Given the following Dockerfile

FROM golang:1.15.4 as build

WORKDIR /go/src
ADD . /go/src

RUN go get go.etcd.io/etcd/clientv3

The following error results

Step 4/5 : RUN go get go.etcd.io/etcd/clientv3
 ---> Running in dbe5b02874c0
go: downloading go.etcd.io/etcd v0.5.0-alpha.5
go: downloading go.etcd.io/etcd v3.3.25+incompatible
go: found go.etcd.io/etcd/clientv3 in go.etcd.io/etcd v3.3.25+incompatible
go: finding module for package google.golang.org/grpc/credentials
go: finding module for package github.com/coreos/etcd/clientv3/balancer
go: finding module for package github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes
go: finding module for package github.com/coreos/etcd/clientv3/credentials
go: finding module for package google.golang.org/grpc/codes
go: finding module for package github.com/coreos/pkg/capnslog
go: finding module for package google.golang.org/grpc/keepalive
go: finding module for package google.golang.org/grpc/metadata
go: finding module for package google.golang.org/grpc/grpclog
go: finding module for package github.com/coreos/etcd/auth/authpb
go: downloading github.com/coreos/etcd v0.5.0-alpha.5
go: downloading github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f
go: downloading google.golang.org/grpc v1.33.2
go: downloading github.com/coreos/etcd v3.3.25+incompatible
go: finding module for package github.com/coreos/etcd/etcdserver/etcdserverpb
go: finding module for package github.com/coreos/etcd/pkg/types
go: finding module for package google.golang.org/grpc
go: finding module for package github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
go: finding module for package github.com/coreos/etcd/clientv3/balancer/picker
go: finding module for package github.com/coreos/etcd/pkg/logutil
go: finding module for package github.com/coreos/etcd/mvcc/mvccpb
go: finding module for package go.uber.org/zap
go: finding module for package google.golang.org/grpc/status
go: finding module for package github.com/coreos/etcd/version
go: finding module for package github.com/google/uuid
go: downloading go.uber.org/zap v1.16.0
go: downloading github.com/google/uuid v1.1.2
go: found github.com/coreos/etcd/auth/authpb in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/clientv3/balancer in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/clientv3/balancer/picker in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/clientv3/balancer/resolver/endpoint in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/clientv3/credentials in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/etcdserver/etcdserverpb in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/mvcc/mvccpb in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/pkg/logutil in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/pkg/types in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/version in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/pkg/capnslog in github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f
go: found github.com/google/uuid in github.com/google/uuid v1.1.2
go: found go.uber.org/zap in go.uber.org/zap v1.16.0
go: found google.golang.org/grpc in google.golang.org/grpc v1.33.2
go: found google.golang.org/grpc/codes in google.golang.org/grpc v1.33.2
go: found google.golang.org/grpc/credentials in google.golang.org/grpc v1.33.2
go: found google.golang.org/grpc/grpclog in google.golang.org/grpc v1.33.2
go: found google.golang.org/grpc/keepalive in google.golang.org/grpc v1.33.2
go: found google.golang.org/grpc/metadata in google.golang.org/grpc v1.33.2
go: found google.golang.org/grpc/status in google.golang.org/grpc v1.33.2
go: downloading golang.org/x/net v0.0.0-20190620200207-3b0461eec859
go: downloading google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
go: downloading github.com/golang/protobuf v1.4.1
go: downloading go.uber.org/atomic v1.6.0
go: downloading golang.org/x/sys v0.0.0-20190412213103-97732733099d
go: downloading go.uber.org/multierr v1.5.0
go: finding module for package github.com/coreos/go-systemd/journal
go: finding module for package github.com/coreos/go-semver/semver
go: downloading google.golang.org/protobuf v1.25.0
go: downloading golang.org/x/text v0.3.0
go: downloading github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
go: finding module for package github.com/gogo/protobuf/gogoproto
go: downloading github.com/coreos/go-semver v0.3.0
go: downloading github.com/gogo/protobuf v1.3.1
go: found github.com/gogo/protobuf/gogoproto in github.com/gogo/protobuf v1.3.1
go: found github.com/coreos/go-systemd/journal in github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
go: found github.com/coreos/go-semver/semver in github.com/coreos/go-semver v0.3.0
# github.com/coreos/etcd/clientv3/balancer/picker
../pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/err.go:37:44: undefined: balancer.PickOptions
../pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/roundrobin_balanced.go:55:54: undefined: balancer.PickOptions
# github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
../pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:78: undefined: resolver.BuildOption
../pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:182:31: undefined: resolver.ResolveNowOption
The command '/bin/sh -c go get go.etcd.io/etcd/clientv3' returned a non-zero code: 2

The second error appears to be related to #11563 and #11931.

The fix for this appears to be to use master or to cut a v3.5 tag with the associated fix. The master branch appears to do the right thing in respects to mod versioning with client/v3 etc, I feel like that is the appropriate way for new projects to use the client. However, as noted above go get go.etcd.io/etcd/client/v3 does not work. I'm assuming this is a transitory problem as the project transitions to client/v3. I'm making this issue only to ensure the maintainers are aware of the issue.

Thanks for a great project guys!

Full source for my docker files and main.go are here https://github.com/thrawn01/test-etcd

Most helpful comment

I'm in a similar situation. After switching a project over to gomodules from the old gopath style, I stared having the same type of error:

go: finding module for package github.com/coreos/etcd/clientv3/concurrency
go: finding module for package github.com/coreos/etcd/clientv3
go: found github.com/coreos/etcd/clientv3 in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/clientv3/concurrency in github.com/coreos/etcd v3.3.25+incompatible
# github.com/coreos/etcd/clientv3/balancer/picker
../../../../../../go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/err.go:37:44: undefined: balancer.PickOptions
../../../../../../go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/roundrobin_balanced.go:55:54: undefined: balancer.PickOptions
# github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
../../../../../../go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:78: undefined: resolver.BuildOption
../../../../../../go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:182:31: undefined: resolver.ResolveNowOption

So I removed the go.mod entries and changed my imports from:

"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/clientv3/concurrency"

to

clientv3 "github.com/etcd-io/etcd/client/v3"
"github.com/etcd-io/etcd/client/v3/concurrency"

However, that just lead to:

> go get go.etcd.io/etcd/client/v3
go: go.etcd.io/etcd/client/v3 upgrade => v3.0.0-20201125202132-28d1af294e43
go get: go.etcd.io/etcd/client/[email protected] requires
    go.etcd.io/etcd/api/[email protected]: reading go.etcd.io/etcd/api/api/go.mod at revision api/v3.5.0-pre: unknown revision api/v3.5.0-pre

All 4 comments

I'm also puzzled about this. Can the documentation be changed in a way that is shows how to import the client that targets a specific etcd version? like, go get go.etcd.io/etcd/clientv3@vTODO?

Also, maybe this is related to #12412.

@thrawn01, my example at https://github.com/rgl/ubuntu-docker-compose-example/tree/master/hello still works with the versions that are in the go.mod/go.sum file, maybe that's enough for you to get started in the meantime.

I'm in a similar situation. After switching a project over to gomodules from the old gopath style, I stared having the same type of error:

go: finding module for package github.com/coreos/etcd/clientv3/concurrency
go: finding module for package github.com/coreos/etcd/clientv3
go: found github.com/coreos/etcd/clientv3 in github.com/coreos/etcd v3.3.25+incompatible
go: found github.com/coreos/etcd/clientv3/concurrency in github.com/coreos/etcd v3.3.25+incompatible
# github.com/coreos/etcd/clientv3/balancer/picker
../../../../../../go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/err.go:37:44: undefined: balancer.PickOptions
../../../../../../go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/roundrobin_balanced.go:55:54: undefined: balancer.PickOptions
# github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
../../../../../../go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:78: undefined: resolver.BuildOption
../../../../../../go/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:182:31: undefined: resolver.ResolveNowOption

So I removed the go.mod entries and changed my imports from:

"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/clientv3/concurrency"

to

clientv3 "github.com/etcd-io/etcd/client/v3"
"github.com/etcd-io/etcd/client/v3/concurrency"

However, that just lead to:

> go get go.etcd.io/etcd/client/v3
go: go.etcd.io/etcd/client/v3 upgrade => v3.0.0-20201125202132-28d1af294e43
go get: go.etcd.io/etcd/client/[email protected] requires
    go.etcd.io/etcd/api/[email protected]: reading go.etcd.io/etcd/api/api/go.mod at revision api/v3.5.0-pre: unknown revision api/v3.5.0-pre

I made a standalone client here https://github.com/swdee/etcdc for v3.4.13 a few months back due to the issues with Go Modules and GRPC versions.

managed to get it compile with the following replace section in go.mod:

replace (
    go.etcd.io/etcd => ./etcd-fix
    go.etcd.io/etcd/api/v3 => ./etcd-fix/api
    go.etcd.io/etcd/client/v2 => ./etcd-fix/client/v2
    go.etcd.io/etcd/client/v3 => ./etcd-fix/client/v3
    go.etcd.io/etcd/etcdctl/v3 => ./etcd-fix/etcdctl
    go.etcd.io/etcd/pkg/v3 => ./etcd-fix/pkg
    go.etcd.io/etcd/raft/v3 => ./etcd-fix/raft
    go.etcd.io/etcd/server/v3 => ./etcd-fix/server
    go.etcd.io/etcd/tests/v3 => ./etcd-fix/tests
)

The etcd-fix folder my fixed fork of etcd's master branch (at 0539bcb81f4 right now) => https://github.com/mcluseau/etcd .

Currently, works with a single endpoint and forcing it hard to avoid the balancer layer that does not work:

    etcd, err := etcdv3.New(etcdCfg)
    if err != nil {
        return
    }

    cc, err := etcd.Dial(*etcdEndpoints)
    if err != nil {
        return
    }

    etcd.KV = etcdv3.NewKVFromKVClient(etcdserverpb.NewKVClient(cc), etcd)
    etcd.Lease = etcdv3.NewLeaseFromLeaseClient(etcdserverpb.NewLeaseClient(cc), etcd, etcdCfg.DialTimeout+time.Second)
    etcd.Watcher = etcdv3.NewWatchFromWatchClient(etcdserverpb.NewWatchClient(cc), etcd)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

suresh-chaudhari picture suresh-chaudhari  路  3Comments

cheyang picture cheyang  路  3Comments

olalonde picture olalonde  路  4Comments

el10savio picture el10savio  路  4Comments

govine picture govine  路  3Comments