Skip to content

go.mod:incorrect pacakge dependency in etcd 3.3 without go.mod #12068

Closed
@cfc4n

Description

@cfc4n

shell:

cfc4n@cnxct-mt:~/Project/golang $mkdir etcd_3.3_mod
cfc4n@cnxct-mt:~/Project/golang $cd etcd_3.3_mod
cfc4n@cnxct-mt:~/Project/golang $touch main.go

and type code with:

package main

import (
	"github.com/coreos/etcd/clientv3" //equal to go.etcd.io/etcd/clientv3
	"time"
)

func main() {
	cfg := clientv3.Config{
		Endpoints:        []string{"https://localhost:2379"},
		DialTimeout:      time.Second * 5,
	}

	_,e := clientv3.New(cfg)
	if e != nil {
		panic(e)
	}
}

condition 1

cfc4n@cnxct-mt:~/Project/golang/etcd_3.3_mod $go mod init etcd_3.3_mod
go: creating new go.mod: module etcd_3.3_mod
cfc4n@cnxct-mt:~/Project/golang/etcd_3.3_mod $go build -o test
go: finding github.com/coreos/pkg latest
go: finding github.com/coreos/go-systemd latest
# github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
../../../../gopath/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:78: undefined: resolver.BuildOption
../../../../gopath/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:182:31: undefined: resolver.ResolveNowOption
# github.com/coreos/etcd/clientv3/balancer/picker
../../../../gopath/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/err.go:37:44: undefined: balancer.PickOptions
../../../../gopath/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/roundrobin_balanced.go:55:54: undefined: balancer.PickOptions

condition 2

error logs:

cfc4n@cnxct-mt:~/Project/golang/etcd_3.3_mod $go mod init etcd_3.3_mod
go: creating new go.mod: module etcd_3.3_mod
cfc4n@cnxct-mt:~/Project/golang/etcd_3.3_mod $go get go.etcd.io/etcd
go: finding github.com/coreos/pkg latest
go: finding golang.org/x/time latest
go: finding golang.org/x/net latest
go: finding github.com/golang/groupcache latest
go: finding github.com/coreos/go-systemd latest
go: finding github.com/tmc/grpc-websocket-proxy latest
go: finding github.com/xiang90/probing latest
go: finding google.golang.org/genproto latest
go: finding golang.org/x/crypto latest
go: github.com/coreos/[email protected]: parsing go.mod: unexpected module path "go.etcd.io/bbolt"
go: error loading module requirements

rootcause

There is not go.mod in https://github.com/etcd-io/etcd/tree/v3.3.22 . via https://pkg.go.dev/go.etcd.io/etcd/?tab=doc .
go mod will get lastest version package default.

package ver in client used clientv3 lib ver in etcd
github.com/coreos/etcd v3.3.22+incompatible // indirect
github.com/coreos/go-semver v0.3.0 // indirect v0.2.0
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect v0.0.0-20190620071333-e64a0ec8b42a
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect v0.0.0-20180108230652-97fdf19511ea
github.com/gogo/protobuf v1.3.1 // indirect v1.2.1
github.com/google/uuid v1.1.1 // indirect v1.0.0
go.etcd.io/etcd v3.3.22+incompatible // indirect
go.uber.org/zap v1.15.0 // indirect v1.10.0
google.golang.org/grpc v1.30.0 // indirect v1.23.0

If we build project in etcd repo ,it works. because go mod will translate package version from glide.lock with correct version.
but if used clientv3 sdk ,it will failed ,go mod will not translate package for indirect package .and error logs with this issue.

other issue

#12028
#12009
#11931
#11829
#11808
#11772
#11749
#11721
#11707
and other complain : https://colobu.com/2020/04/09/accidents-of-etcd-and-go-module/ 🤣

solution

  • add go.mod and go.sum into etcd 3.3 repo for GO111MODULE=on ( build this project and go get go.etcd.io/etcd for other project )
  • keep use glide.lock and glide.yaml for GO111MODULE=off

/cc @gyuho @mitake @spzala

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions