Bump etcd client to 3.4. Use go modules

This commit is contained in:
Ole Markus With 2020-12-14 21:57:55 +01:00
parent 52ea87d6ba
commit 73fcd24e5e
39 changed files with 92 additions and 81 deletions

View File

@ -17,8 +17,8 @@ go_library(
"//dnsprovider/pkg/dnsprovider:go_default_library",
"//dnsprovider/pkg/dnsprovider/providers/coredns/stubs:go_default_library",
"//dnsprovider/pkg/dnsprovider/rrstype:go_default_library",
"//vendor/github.com/coreos/etcd/client:go_default_library",
"//vendor/github.com/miekg/coredns/middleware/etcd/msg:go_default_library",
"//vendor/go.etcd.io/etcd/client:go_default_library",
"//vendor/gopkg.in/gcfg.v1:go_default_library",
"//vendor/k8s.io/klog/v2:go_default_library",
],

View File

@ -23,7 +23,7 @@ import (
"strconv"
"strings"
etcdc "github.com/coreos/etcd/client"
etcdc "go.etcd.io/etcd/client"
gcfg "gopkg.in/gcfg.v1"
"k8s.io/klog/v2"
"k8s.io/kops/dnsprovider/pkg/dnsprovider"

View File

@ -22,8 +22,8 @@ import (
"fmt"
"hash/fnv"
etcdc "github.com/coreos/etcd/client"
dnsmsg "github.com/miekg/coredns/middleware/etcd/msg"
etcdc "go.etcd.io/etcd/client"
"k8s.io/kops/dnsprovider/pkg/dnsprovider"
)

View File

@ -22,8 +22,8 @@ import (
"fmt"
"net"
etcdc "github.com/coreos/etcd/client"
dnsmsg "github.com/miekg/coredns/middleware/etcd/msg"
etcdc "go.etcd.io/etcd/client"
"k8s.io/klog/v2"
"k8s.io/kops/dnsprovider/pkg/dnsprovider"
"k8s.io/kops/dnsprovider/pkg/dnsprovider/rrstype"

View File

@ -5,5 +5,5 @@ go_library(
srcs = ["corednsapi.go"],
importpath = "k8s.io/kops/dnsprovider/pkg/dnsprovider/providers/coredns/stubs",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/coreos/etcd/client:go_default_library"],
deps = ["//vendor/go.etcd.io/etcd/client:go_default_library"],
)

View File

@ -21,7 +21,7 @@ import (
"context"
"strings"
etcd "github.com/coreos/etcd/client"
etcd "go.etcd.io/etcd/client"
)
// Compile time check for interface conformance

2
go.mod
View File

@ -60,7 +60,6 @@ require (
github.com/aws/aws-sdk-go v1.36.0
github.com/blang/semver/v4 v4.0.0
github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1 // indirect
github.com/coreos/etcd v3.3.17+incompatible
github.com/denverdino/aliyungo v0.0.0-20191128015008-acd8035bbb1d
github.com/digitalocean/godo v1.54.0
github.com/docker/docker v1.4.2-0.20200309214505-aa6a9891b09c
@ -93,6 +92,7 @@ require (
github.com/urfave/cli v1.22.2
github.com/weaveworks/mesh v0.0.0-20170419100114-1f158d31de55
github.com/zclconf/go-cty v1.3.1
go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489
go.uber.org/zap v1.10.0
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b

5
go.sum
View File

@ -164,6 +164,7 @@ github.com/cilium/ebpf v0.0.0-20200702112145-1c8d4c9ef775/go.mod h1:7cR51M8ViRLI
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/clusterhq/flocker-go v0.0.0-20160920122132-2b8b7259d313/go.mod h1:P1wt9Z3DP8O6W3rvwCt0REIlshg1InHImaLW0t3ObY0=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
github.com/container-storage-interface/spec v1.2.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
@ -186,8 +187,6 @@ github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.17+incompatible h1:f/Z3EoDSx1yjaIjLQGo1diYUlQYSBrrAQ5vP8NjwXwo=
github.com/coreos/etcd v3.3.17+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
@ -235,6 +234,7 @@ github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKG
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
@ -827,6 +827,7 @@ go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.etcd.io/etcd v0.5.0-alpha.5.0.20200819165624-17cef6e3e9d5/go.mod h1:skWido08r9w6Lq/w70DO5XYIKMu4QFu1+4VsqLQuJy8=
go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489 h1:1JFLBqwIgdyHN1ZtgjTBwO+blA6gVOmZurpiMEsETKo=
go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg=
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=

View File

@ -1,10 +0,0 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["srv.go"],
importmap = "k8s.io/kops/vendor/github.com/coreos/etcd/pkg/srv",
importpath = "github.com/coreos/etcd/pkg/srv",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/coreos/etcd/pkg/types:go_default_library"],
)

View File

@ -16,15 +16,15 @@ go_library(
"members.go",
"util.go",
],
importmap = "k8s.io/kops/vendor/github.com/coreos/etcd/client",
importpath = "github.com/coreos/etcd/client",
importmap = "k8s.io/kops/vendor/go.etcd.io/etcd/client",
importpath = "go.etcd.io/etcd/client",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/coreos/etcd/pkg/pathutil:go_default_library",
"//vendor/github.com/coreos/etcd/pkg/srv:go_default_library",
"//vendor/github.com/coreos/etcd/pkg/types:go_default_library",
"//vendor/github.com/coreos/etcd/version:go_default_library",
"//vendor/github.com/json-iterator/go:go_default_library",
"//vendor/github.com/modern-go/reflect2:go_default_library",
"//vendor/go.etcd.io/etcd/pkg/pathutil:go_default_library",
"//vendor/go.etcd.io/etcd/pkg/srv:go_default_library",
"//vendor/go.etcd.io/etcd/pkg/types:go_default_library",
"//vendor/go.etcd.io/etcd/version:go_default_library",
],
)

View File

@ -2,19 +2,14 @@
etcd/client is the Go client library for etcd.
[![GoDoc](https://godoc.org/github.com/coreos/etcd/client?status.png)](https://godoc.org/github.com/coreos/etcd/client)
[![GoDoc](https://godoc.org/go.etcd.io/etcd/client?status.png)](https://godoc.org/go.etcd.io/etcd/client)
etcd uses `cmd/vendor` directory to store external dependencies, which are
to be compiled into etcd release binaries. `client` can be imported without
vendoring. For full compatibility, it is recommended to vendor builds using
etcd's vendored packages, using tools like godep, as in
[vendor directories](https://golang.org/cmd/go/#hdr-Vendor_Directories).
For more detail, please read [Go vendor design](https://golang.org/s/go15vendor).
For full compatibility, it is recommended to vendor builds using etcd's vendored packages, using tools like `golang/dep`, as in [vendor directories](https://golang.org/cmd/go/#hdr-Vendor_Directories).
## Install
```bash
go get github.com/coreos/etcd/client
go get go.etcd.io/etcd/client
```
## Usage
@ -27,7 +22,7 @@ import (
"time"
"context"
"github.com/coreos/etcd/client"
"go.etcd.io/etcd/client"
)
func main() {

View File

@ -29,7 +29,7 @@ import (
"sync"
"time"
"github.com/coreos/etcd/version"
"go.etcd.io/etcd/version"
)
var (
@ -640,11 +640,11 @@ func (r *redirectFollowingHTTPClient) Do(ctx context.Context, act httpAction) (*
if resp.StatusCode/100 == 3 {
hdr := resp.Header.Get("Location")
if hdr == "" {
return nil, nil, fmt.Errorf("Location header not set")
return nil, nil, fmt.Errorf("location header not set")
}
loc, err := url.Parse(hdr)
if err != nil {
return nil, nil, fmt.Errorf("Location header not valid URL: %s", hdr)
return nil, nil, fmt.Errorf("location header not valid URL: %s", hdr)
}
next = &redirectedHTTPAction{
action: act,

View File

@ -15,13 +15,13 @@
package client
import (
"github.com/coreos/etcd/pkg/srv"
"go.etcd.io/etcd/pkg/srv"
)
// Discoverer is an interface that wraps the Discover method.
type Discoverer interface {
// Discover looks up the etcd servers for the domain.
Discover(domain string) ([]string, error)
Discover(domain string, serviceName string) ([]string, error)
}
type srvDiscover struct{}
@ -31,8 +31,8 @@ func NewSRVDiscover() Discoverer {
return &srvDiscover{}
}
func (d *srvDiscover) Discover(domain string) ([]string, error) {
srvs, err := srv.GetClient("etcd-client", domain)
func (d *srvDiscover) Discover(domain string, serviceName string) ([]string, error) {
srvs, err := srv.GetClient("etcd-client", domain, serviceName)
if err != nil {
return nil, err
}

View File

@ -21,7 +21,7 @@ Create a Config and exchange it for a Client:
"net/http"
"context"
"github.com/coreos/etcd/client"
"go.etcd.io/etcd/client"
)
cfg := client.Config{

View File

@ -19,13 +19,12 @@ import (
"encoding/json"
"errors"
"fmt"
"go.etcd.io/etcd/pkg/pathutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"
"github.com/coreos/etcd/pkg/pathutil"
)
const (
@ -63,7 +62,7 @@ func (e Error) Error() string {
}
var (
ErrInvalidJSON = errors.New("client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint.")
ErrInvalidJSON = errors.New("client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint")
ErrEmptyBody = errors.New("client: response body is empty")
)

View File

@ -23,7 +23,7 @@ import (
"net/url"
"path"
"github.com/coreos/etcd/pkg/types"
"go.etcd.io/etcd/pkg/types"
)
var (

View File

@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["path.go"],
importmap = "k8s.io/kops/vendor/github.com/coreos/etcd/pkg/pathutil",
importpath = "github.com/coreos/etcd/pkg/pathutil",
importmap = "k8s.io/kops/vendor/go.etcd.io/etcd/pkg/pathutil",
importpath = "go.etcd.io/etcd/pkg/pathutil",
visibility = ["//visibility:public"],
)

10
vendor/go.etcd.io/etcd/pkg/srv/BUILD.bazel generated vendored Normal file
View File

@ -0,0 +1,10 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["srv.go"],
importmap = "k8s.io/kops/vendor/go.etcd.io/etcd/pkg/srv",
importpath = "go.etcd.io/etcd/pkg/srv",
visibility = ["//visibility:public"],
deps = ["//vendor/go.etcd.io/etcd/pkg/types:go_default_library"],
)

View File

@ -21,7 +21,7 @@ import (
"net/url"
"strings"
"github.com/coreos/etcd/pkg/types"
"go.etcd.io/etcd/pkg/types"
)
var (
@ -32,7 +32,7 @@ var (
// GetCluster gets the cluster information via DNS discovery.
// Also sees each entry as a separate instance.
func GetCluster(service, name, dns string, apurls types.URLs) ([]string, error) {
func GetCluster(serviceScheme, service, name, dns string, apurls types.URLs) ([]string, error) {
tempName := int(0)
tcp2ap := make(map[string]url.URL)
@ -83,20 +83,9 @@ func GetCluster(service, name, dns string, apurls types.URLs) ([]string, error)
return nil
}
failCount := 0
err := updateNodeMap(service+"-ssl", "https")
srvErr := make([]string, 2)
err := updateNodeMap(service, serviceScheme)
if err != nil {
srvErr[0] = fmt.Sprintf("error querying DNS SRV records for _%s-ssl %s", service, err)
failCount++
}
err = updateNodeMap(service, "http")
if err != nil {
srvErr[1] = fmt.Sprintf("error querying DNS SRV records for _%s %s", service, err)
failCount++
}
if failCount == 2 {
return nil, fmt.Errorf("srv: too many errors querying DNS SRV records (%q, %q)", srvErr[0], srvErr[1])
return nil, fmt.Errorf("error querying DNS SRV records for _%s %s", service, err)
}
return stringParts, nil
}
@ -107,7 +96,7 @@ type SRVClients struct {
}
// GetClient looks up the client endpoints for a service and domain.
func GetClient(service, domain string) (*SRVClients, error) {
func GetClient(service, domain string, serviceName string) (*SRVClients, error) {
var urls []*url.URL
var srvs []*net.SRV
@ -126,8 +115,8 @@ func GetClient(service, domain string) (*SRVClients, error) {
return nil
}
errHTTPS := updateURLs(service+"-ssl", "https")
errHTTP := updateURLs(service, "http")
errHTTPS := updateURLs(GetSRVService(service, serviceName, "https"), "https")
errHTTP := updateURLs(GetSRVService(service, serviceName, "http"), "http")
if errHTTPS != nil && errHTTP != nil {
return nil, fmt.Errorf("dns lookup errors: %s and %s", errHTTPS, errHTTP)
@ -139,3 +128,15 @@ func GetClient(service, domain string) (*SRVClients, error) {
}
return &SRVClients{Endpoints: endpoints, SRVs: srvs}, nil
}
// GetSRVService generates a SRV service including an optional suffix.
func GetSRVService(service, serviceName string, scheme string) (SRVService string) {
if scheme == "https" {
service = fmt.Sprintf("%s-ssl", service)
}
if serviceName != "" {
return fmt.Sprintf("%s-%s", service, serviceName)
}
return service
}

View File

@ -10,7 +10,7 @@ go_library(
"urls.go",
"urlsmap.go",
],
importmap = "k8s.io/kops/vendor/github.com/coreos/etcd/pkg/types",
importpath = "github.com/coreos/etcd/pkg/types",
importmap = "k8s.io/kops/vendor/go.etcd.io/etcd/pkg/types",
importpath = "go.etcd.io/etcd/pkg/types",
visibility = ["//visibility:public"],
)

View File

@ -14,9 +14,7 @@
package types
import (
"strconv"
)
import "strconv"
// ID represents a generic identifier which is canonically
// stored as a uint64 but is typically represented as a

View File

@ -148,6 +148,14 @@ func (ts *tsafeSet) Contains(value string) (exists bool) {
func (ts *tsafeSet) Equals(other Set) bool {
ts.m.RLock()
defer ts.m.RUnlock()
// If ts and other represent the same variable, avoid calling
// ts.us.Equals(other), to avoid double RLock bug
if _other, ok := other.(*tsafeSet); ok {
if _other == ts {
return true
}
}
return ts.us.Equals(other)
}
@ -173,6 +181,15 @@ func (ts *tsafeSet) Copy() Set {
func (ts *tsafeSet) Sub(other Set) Set {
ts.m.RLock()
defer ts.m.RUnlock()
// If ts and other represent the same variable, avoid calling
// ts.us.Sub(other), to avoid double RLock bug
if _other, ok := other.(*tsafeSet); ok {
if _other == ts {
usResult := NewUnsafeSet()
return &tsafeSet{usResult, sync.RWMutex{}}
}
}
usResult := ts.us.Sub(other).(*unsafeSet)
return &tsafeSet{usResult, sync.RWMutex{}}
}

View File

@ -3,8 +3,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["version.go"],
importmap = "k8s.io/kops/vendor/github.com/coreos/etcd/version",
importpath = "github.com/coreos/etcd/version",
importmap = "k8s.io/kops/vendor/go.etcd.io/etcd/version",
importpath = "go.etcd.io/etcd/version",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/coreos/go-semver/semver:go_default_library"],
)

View File

@ -26,7 +26,7 @@ import (
var (
// MinClusterVersion is the min cluster version this etcd binary is compatible with.
MinClusterVersion = "3.0.0"
Version = "3.3.17"
Version = "3.4.13"
APIVersion = "unknown"
// Git SHA Value will be set during build

14
vendor/modules.txt vendored
View File

@ -151,13 +151,6 @@ github.com/chai2010/gettext-go/gettext/plural
github.com/chai2010/gettext-go/gettext/po
# github.com/containerd/containerd v1.3.3
github.com/containerd/containerd/errdefs
# github.com/coreos/etcd v3.3.17+incompatible
## explicit
github.com/coreos/etcd/client
github.com/coreos/etcd/pkg/pathutil
github.com/coreos/etcd/pkg/srv
github.com/coreos/etcd/pkg/types
github.com/coreos/etcd/version
# github.com/coreos/go-semver v0.3.0
github.com/coreos/go-semver/semver
# github.com/cpuguy83/go-md2man/v2 v2.0.0
@ -548,6 +541,13 @@ github.com/zclconf/go-cty/cty/function/stdlib
github.com/zclconf/go-cty/cty/gocty
github.com/zclconf/go-cty/cty/json
github.com/zclconf/go-cty/cty/set
# go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489
## explicit
go.etcd.io/etcd/client
go.etcd.io/etcd/pkg/pathutil
go.etcd.io/etcd/pkg/srv
go.etcd.io/etcd/pkg/types
go.etcd.io/etcd/version
# go.opencensus.io v0.22.3
go.opencensus.io
go.opencensus.io/internal