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

Bug 1815637: bump etcd v3.3.22 #47

Merged
merged 62 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
95095f8
etcdserver: Remove infinite loop in doSerialize
horkhe Oct 26, 2018
5a48217
etcdserver: remove auth validation loop
jingyih Feb 12, 2019
e1508f9
integration: disable TestV3AuthOldRevConcurrent
jingyih Oct 26, 2019
70853d6
Merge pull request #11378 from jingyih/automated-cherry-pick-of-#1021…
mitake Jan 25, 2020
b3d9e29
mvcc/backend: Delete orphaned db.tmp files before defrag
jpbetz Feb 12, 2020
b0a4038
Merge pull request #11623 from jpbetz/automated-cherry-pick-of-#11613…
wenjiaswe Feb 13, 2020
7b1a92c
mvcc/backend: check for nil boltOpenOptions
jingyih Feb 15, 2020
e21e355
Merge pull request #11632 from jingyih/automated-cherry-pick-of-#1163…
jingyih Feb 16, 2020
c58133b
etcdctl: fix member add command
jingyih Feb 19, 2020
eb1df6d
Merge pull request #11665 from jingyih/automated-cherry-pick-of-#1163…
spzala Mar 11, 2020
1228d6c
proxy/grpcproxy: add return on error for metrics handler
hexfusion Mar 13, 2020
30aaceb
etcdserver/api/etcdhttp: log server-side /health checks
gyuho Mar 18, 2020
6f7ee07
clientv3: embed api version in metadata
gyuho Mar 18, 2020
d9027ce
etcdserver/api/v3rpc: handle api version metadata, add metrics
gyuho Mar 18, 2020
f9c8920
version: 3.3.19
gyuho Mar 18, 2020
10d50e0
words: whitelist "hasleader"
gyuho Mar 18, 2020
07562e2
Revert "version: 3.3.19"
gyuho Mar 19, 2020
acb9746
version: 3.3.19
gyuho Mar 19, 2020
5088080
travis.yaml: use Go 1.12.12
gyuho Mar 19, 2020
cd200b4
Revert "version: 3.3.19"
gyuho Mar 19, 2020
a463bd5
words: whitelist "racey"
gyuho Mar 19, 2020
67da93f
version: 3.3.19
gyuho Mar 19, 2020
89ecd19
pkg/ioutil: add "FlushN"
gyuho Apr 1, 2020
1aa5da9
wal: add "etcd_wal_writes_bytes_total"
gyuho Apr 1, 2020
9fd7e2b
version: 3.3.20
gyuho Apr 1, 2020
140bf53
*: fix auth revision corruption bug
tangcong Feb 24, 2020
06a2f81
auth: add new metric 'etcd_debugging_auth_revision'
wswcfan Feb 24, 2020
e7291a1
auth: print warning log when error is ErrAuthOldRevision
tangcong Mar 3, 2020
acd9422
auth: cleanup saveConsistentIndex in NewAuthStore
tangcong Mar 3, 2020
27dffc6
etcdserver: print warn log when failed to apply request
tangcong Mar 10, 2020
64fc4cc
auth: ensure RoleGrantPermission is compatible with older versions
tangcong Mar 22, 2020
294e714
*: fix cherry-pick conflict
tangcong Apr 6, 2020
7e20b9f
Merge pull request #11753 from tangcong/automated-cherry-pick-of-#116…
jingyih Apr 10, 2020
1b5e2f4
Update grpc-gateway to 1.3.1 (#11843)
polyrabbit May 6, 2020
5f79992
mvcc: fix deadlock bug
tangcong Apr 26, 2020
2333747
Merge pull request #11856 from tangcong/automated-cherry-pick-of-#118…
gyuho May 8, 2020
9caec0d
etcdserver,wal: fix inconsistencies in WAL and snapshot
gyuho May 18, 2020
924b812
*: make sure snapshot save downloads SHA256 checksum
gyuho May 18, 2020
6723145
rafthttp: improve snapshot logging
gyuho May 18, 2020
1205851
version: 3.3.21
gyuho May 18, 2020
669285f
rafthttp: log snapshot downloads
gyuho May 20, 2020
8ce10ea
wal: fix crc mismatch crash bug
tangcong May 20, 2020
a9d14cb
wal: add TestValidSnapshotEntriesAfterPurgeWal testcase
tangcong May 20, 2020
282cce7
version: 3.3.22
gyuho May 20, 2020
611a1f7
version: openshift-v4.0
hexfusion Nov 29, 2018
46f8e34
Dockerfile: add etcdctl
hexfusion Feb 20, 2019
8f67a24
Dockerfile.*: Fix "etcd is distributed" -> "etcd is a distributed"
wking Feb 7, 2019
516a080
Dockerfile: resolve issue where binary was not properly copied from b…
hexfusion Feb 20, 2019
a30c9dc
OWNERS: add
hexfusion May 5, 2019
7e7fa0e
Dockerfile: set coreos org as canonical for release-3.3
hexfusion May 4, 2019
7342605
Dockerfile: bump golang to 1.11
hexfusion Jul 9, 2019
f8f402b
Dockerfile: use build instead of make build
hexfusion Aug 29, 2019
c9ebfee
Dockerfile: bump golang 1.12
hexfusion Sep 23, 2019
e4fd890
add stub discovery-etcd-initial-cluster command
deads2k Feb 20, 2020
317ecea
build openshift tools with etcd
deads2k Feb 20, 2020
e839175
codify the initial cluster check as golang code
deads2k Feb 20, 2020
c7df133
Archive data-dir if target member is unstarted
Feb 23, 2020
0815076
fix removed member name, unmask error
alaypatel07 Feb 27, 2020
1810482
If we weren't able to get client or get target member but memberDir e…
Feb 28, 2020
d883e05
list all peers in initial-cluster
deads2k Mar 5, 2020
56f86d1
make evaluation of targetMember strict
deads2k May 14, 2020
9860350
vendor: bump gRPC-go to v1.23.1
hexfusion Jul 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sudo: required
services: docker

go:
- 1.12.9
- 1.12.12

env:
- GO111MODULE=on
Expand All @@ -28,7 +28,7 @@ env:
matrix:
fast_finish: true
allow_failures:
- go: 1.12.9
- go: 1.12.12
env: TARGET=linux-386-unit

install:
Expand Down
2 changes: 2 additions & 0 deletions .words
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ healthcheck
iff
inflight
keepalive
hasleader
racey
keepalives
keyspace
linearization
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile.openshift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM registry.svc.ci.openshift.org/openshift/release:golang-1.12 AS builder

WORKDIR /go/src/github.com/coreos/etcd

COPY . .

RUN ./build

# stage 2
FROM registry.svc.ci.openshift.org/openshift/origin-v4.0:base

ENTRYPOINT ["/usr/bin/etcd"]

COPY --from=builder /go/src/github.com/coreos/etcd/bin/etcd /usr/bin/
COPY --from=builder /go/src/github.com/coreos/etcd/bin/etcdctl /usr/bin/
COPY --from=builder /go/src/github.com/coreos/etcd/bin/discover-etcd-initial-cluster /usr/bin/

LABEL io.k8s.display-name="etcd server" \
io.k8s.description="etcd is a distributed key-value store which stores the persistent master state for Kubernetes and OpenShift." \
maintainer="Sam Batschelet <sbatsche@redhat.com>"
20 changes: 20 additions & 0 deletions Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM openshift/golang-builder:1.12 AS builder

WORKDIR /go/src/github.com/coreos/etcd

COPY . .

RUN ./build

# stage 2
FROM openshift/origin-base

ENTRYPOINT ["/usr/bin/etcd"]

COPY --from=builder /go/src/github.com/coreos/etcd/bin/etcd /usr/bin/
COPY --from=builder /go/src/github.com/coreos/etcd/bin/etcdctl /usr/bin/
COPY --from=builder /go/src/github.com/coreos/etcd/bin/discover-etcd-initial-cluster /usr/bin/

LABEL io.k8s.display-name="etcd server" \
io.k8s.description="etcd is a distributed key-value store which stores the persistent master state for Kubernetes and OpenShift." \
maintainer="Sam Batschelet <sbatsche@redhat.com>"
8 changes: 8 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
approvers:
- hexfusion
reviewers:
- deads2k
- crawford
- hexfusion
- smarterclayton
- wking
42 changes: 42 additions & 0 deletions auth/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2015 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package auth

import (
"github.com/prometheus/client_golang/prometheus"
"sync"
)

var (
currentAuthRevision = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: "etcd_debugging",
Subsystem: "auth",
Name: "revision",
Help: "The current revision of auth store.",
},
func() float64 {
reportCurrentAuthRevMu.RLock()
defer reportCurrentAuthRevMu.RUnlock()
return reportCurrentAuthRev()
},
)
// overridden by auth store initialization
reportCurrentAuthRevMu sync.RWMutex
reportCurrentAuthRev = func() float64 { return 0 }
)

func init() {
prometheus.MustRegister(currentAuthRevision)
}
50 changes: 47 additions & 3 deletions auth/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ type AuthenticateParamIndex struct{}
// AuthenticateParamSimpleTokenPrefix is used for a key of context in the parameters of Authenticate()
type AuthenticateParamSimpleTokenPrefix struct{}

// saveConsistentIndexFunc is used to sync consistentIndex to backend, now reusing store.saveIndex
type saveConsistentIndexFunc func(tx backend.BatchTx)

// AuthStore defines auth storage interface.
type AuthStore interface {
// AuthEnable turns on the authentication feature
AuthEnable() error
Expand Down Expand Up @@ -178,6 +182,9 @@ type AuthStore interface {

// HasRole checks that user has role
HasRole(user, role string) bool

// SetConsistentIndexSyncer sets consistentIndex syncer
SetConsistentIndexSyncer(syncer saveConsistentIndexFunc)
}

type TokenProvider interface {
Expand All @@ -200,9 +207,13 @@ type authStore struct {

rangePermCache map[string]*unifiedRangePermissions // username -> unifiedRangePermissions

tokenProvider TokenProvider
tokenProvider TokenProvider
syncConsistentIndex saveConsistentIndexFunc
}

func (as *authStore) SetConsistentIndexSyncer(syncer saveConsistentIndexFunc) {
as.syncConsistentIndex = syncer
}
func (as *authStore) AuthEnable() error {
as.enabledMu.Lock()
defer as.enabledMu.Unlock()
Expand Down Expand Up @@ -252,6 +263,7 @@ func (as *authStore) AuthDisable() {
tx.Lock()
tx.UnsafePut(authBucketName, enableFlagKey, authDisabled)
as.commitRevision(tx)
as.saveConsistentIndex(tx)
tx.Unlock()
b.ForceCommit()

Expand Down Expand Up @@ -368,6 +380,7 @@ func (as *authStore) UserAdd(r *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse,
putUser(tx, newUser)

as.commitRevision(tx)
as.saveConsistentIndex(tx)

plog.Noticef("added a new user: %s", r.Name)

Expand All @@ -392,6 +405,7 @@ func (as *authStore) UserDelete(r *pb.AuthUserDeleteRequest) (*pb.AuthUserDelete
delUser(tx, r.Name)

as.commitRevision(tx)
as.saveConsistentIndex(tx)

as.invalidateCachedPerm(r.Name)
as.tokenProvider.invalidateUser(r.Name)
Expand Down Expand Up @@ -428,6 +442,7 @@ func (as *authStore) UserChangePassword(r *pb.AuthUserChangePasswordRequest) (*p
putUser(tx, updatedUser)

as.commitRevision(tx)
as.saveConsistentIndex(tx)

as.invalidateCachedPerm(r.Name)
as.tokenProvider.invalidateUser(r.Name)
Expand Down Expand Up @@ -468,6 +483,7 @@ func (as *authStore) UserGrantRole(r *pb.AuthUserGrantRoleRequest) (*pb.AuthUser
as.invalidateCachedPerm(r.User)

as.commitRevision(tx)
as.saveConsistentIndex(tx)

plog.Noticef("granted role %s to user %s", r.Role, r.User)
return &pb.AuthUserGrantRoleResponse{}, nil
Expand Down Expand Up @@ -536,6 +552,7 @@ func (as *authStore) UserRevokeRole(r *pb.AuthUserRevokeRoleRequest) (*pb.AuthUs
as.invalidateCachedPerm(r.Name)

as.commitRevision(tx)
as.saveConsistentIndex(tx)

plog.Noticef("revoked role %s from user %s", r.Role, r.Name)
return &pb.AuthUserRevokeRoleResponse{}, nil
Expand Down Expand Up @@ -600,6 +617,7 @@ func (as *authStore) RoleRevokePermission(r *pb.AuthRoleRevokePermissionRequest)
as.clearCachedPerm()

as.commitRevision(tx)
as.saveConsistentIndex(tx)

plog.Noticef("revoked key %s from role %s", r.Key, r.Role)
return &pb.AuthRoleRevokePermissionResponse{}, nil
Expand Down Expand Up @@ -645,6 +663,7 @@ func (as *authStore) RoleDelete(r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDelete
}

as.commitRevision(tx)
as.saveConsistentIndex(tx)

plog.Noticef("deleted role %s", r.Role)
return &pb.AuthRoleDeleteResponse{}, nil
Expand All @@ -667,6 +686,7 @@ func (as *authStore) RoleAdd(r *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse,
putRole(tx, newRole)

as.commitRevision(tx)
as.saveConsistentIndex(tx)

plog.Noticef("Role %s is created", r.Name)

Expand Down Expand Up @@ -727,6 +747,7 @@ func (as *authStore) RoleGrantPermission(r *pb.AuthRoleGrantPermissionRequest) (
as.clearCachedPerm()

as.commitRevision(tx)
as.saveConsistentIndex(tx)

plog.Noticef("role %s's permission of key %s is updated as %s", r.Name, r.Perm.Key, authpb.Permission_Type_name[int32(r.Perm.PermType)])

Expand All @@ -743,8 +764,13 @@ func (as *authStore) isOpPermitted(userName string, revision uint64, key, rangeE
if revision == 0 {
return ErrUserEmpty
}

if revision < as.Revision() {
rev := as.Revision()
if revision < rev {
plog.Warningf("request auth revision is less than current node auth revision,"+
"current node auth revision is %d,"+
"request auth revision is %d,"+
"request key is %s, "+
"err is %v", rev, revision, key, ErrAuthOldRevision)
return ErrAuthOldRevision
}

Expand Down Expand Up @@ -933,6 +959,8 @@ func NewAuthStore(be backend.Backend, tp TokenProvider) *authStore {
as.commitRevision(tx)
}

as.setupMetricsReporter()

tx.Unlock()
be.ForceCommit()

Expand Down Expand Up @@ -1134,3 +1162,19 @@ func (as *authStore) HasRole(user, role string) bool {

return false
}

func (as *authStore) saveConsistentIndex(tx backend.BatchTx) {
if as.syncConsistentIndex != nil {
as.syncConsistentIndex(tx)
} else {
plog.Errorf("failed to save consistentIndex,syncConsistentIndex is nil")
}
}

func (as *authStore) setupMetricsReporter() {
reportCurrentAuthRevMu.Lock()
reportCurrentAuthRev = func() float64 {
return float64(as.Revision())
}
reportCurrentAuthRevMu.Unlock()
}
15 changes: 15 additions & 0 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ etcd_build() {
-o "${out}/etcdctl" ${REPO_PATH}/etcdctl || return
}


openshift_tools_build() {
out="bin"
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
toggle_failpoints_default

# Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK
# shellcheck disable=SC2086
CGO_ENABLED=0 go build $GO_BUILD_FLAGS \
-installsuffix cgo \
-ldflags "$GO_LDFLAGS" \
-o "${out}/discover-etcd-initial-cluster" "github.com/coreos/etcd/openshift-tools/discover-etcd-initial-cluster" || return
}

tools_build() {
out="bin"
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
Expand Down Expand Up @@ -91,4 +105,5 @@ fi
# only build when called directly, not sourced
if echo "$0" | grep "build$" >/dev/null; then
etcd_build
openshift_tools_build
fi
13 changes: 5 additions & 8 deletions clientv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ import (
"github.com/coreos/etcd/clientv3/credentials"
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
"github.com/coreos/etcd/pkg/logutil"
"github.com/coreos/pkg/capnslog"
"github.com/google/uuid"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
grpccredentials "google.golang.org/grpc/credentials"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)

Expand All @@ -48,6 +48,10 @@ var (
roundRobinBalancerName = fmt.Sprintf("etcd-%s", picker.RoundrobinBalanced.String())
)

var (
plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "clientv3")
)

func init() {
lg := zap.NewNop()
if os.Getenv("ETCD_CLIENT_DEBUG") != "" {
Expand Down Expand Up @@ -393,13 +397,6 @@ func (c *Client) dialWithBalancerCreds(ep string) grpccredentials.TransportCrede
return creds
}

// WithRequireLeader requires client requests to only succeed
// when the cluster has a leader.
func WithRequireLeader(ctx context.Context) context.Context {
md := metadata.Pairs(rpctypes.MetadataRequireLeaderKey, rpctypes.MetadataHasLeader)
return metadata.NewOutgoingContext(ctx, md)
}

func newClient(cfg *Config) (*Client, error) {
if cfg == nil {
cfg = &Config{}
Expand Down
Loading