Compare commits
11 Commits
etcdutl/v3
...
pkg/v3.5.9
Author | SHA1 | Date | |
---|---|---|---|
bdbbde998b | |||
d5069486cc | |||
f53707edfa | |||
45d8cb254e | |||
e38eb678bb | |||
d1b1aa9dbe | |||
d6bc827955 | |||
fb8fba710b | |||
b91025abbb | |||
f4f5ac93ca | |||
c0f2954e9f |
5
.github/workflows/e2e.yaml
vendored
5
.github/workflows/e2e.yaml
vendored
@ -1,8 +1,11 @@
|
|||||||
name: E2E
|
name: E2E
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
|
goversion:
|
||||||
|
uses: ./.github/workflows/go-version.yaml
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: goversion
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
@ -13,7 +16,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: "1.19.8"
|
go-version: ${{ needs.goversion.outputs.goversion }}
|
||||||
- run: date
|
- run: date
|
||||||
- env:
|
- env:
|
||||||
TARGET: ${{ matrix.target }}
|
TARGET: ${{ matrix.target }}
|
||||||
|
5
.github/workflows/functional.yaml
vendored
5
.github/workflows/functional.yaml
vendored
@ -1,8 +1,11 @@
|
|||||||
name: functional-tests
|
name: functional-tests
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
|
goversion:
|
||||||
|
uses: ./.github/workflows/go-version.yaml
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: goversion
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
@ -12,7 +15,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: "1.19.8"
|
go-version: ${{ needs.goversion.outputs.goversion }}
|
||||||
- run: date
|
- run: date
|
||||||
- env:
|
- env:
|
||||||
TARGET: ${{ matrix.target }}
|
TARGET: ${{ matrix.target }}
|
||||||
|
21
.github/workflows/go-version.yaml
vendored
Normal file
21
.github/workflows/go-version.yaml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: Go version setup
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
outputs:
|
||||||
|
goversion:
|
||||||
|
value: ${{ jobs.version.outputs.goversion }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
version:
|
||||||
|
name: Set Go version variable for all the workflows
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
goversion: ${{ steps.goversion.outputs.goversion }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||||
|
- id: goversion
|
||||||
|
run: |
|
||||||
|
GO_VERSION=$(cat .go-version)
|
||||||
|
echo "Go Version: $GO_VERSION"
|
||||||
|
echo "goversion=$GO_VERSION" >> $GITHUB_OUTPUT
|
5
.github/workflows/grpcproxy.yaml
vendored
5
.github/workflows/grpcproxy.yaml
vendored
@ -1,8 +1,11 @@
|
|||||||
name: grpcProxy-tests
|
name: grpcProxy-tests
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
|
goversion:
|
||||||
|
uses: ./.github/workflows/go-version.yaml
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: goversion
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
@ -12,7 +15,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: "1.19.8"
|
go-version: ${{ needs.goversion.outputs.goversion }}
|
||||||
- run: date
|
- run: date
|
||||||
- env:
|
- env:
|
||||||
TARGET: ${{ matrix.target }}
|
TARGET: ${{ matrix.target }}
|
||||||
|
5
.github/workflows/release.yaml
vendored
5
.github/workflows/release.yaml
vendored
@ -1,13 +1,16 @@
|
|||||||
name: Release
|
name: Release
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
|
goversion:
|
||||||
|
uses: ./.github/workflows/go-version.yaml
|
||||||
main:
|
main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: goversion
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: "1.19.8"
|
go-version: ${{ needs.goversion.outputs.goversion }}
|
||||||
- name: release
|
- name: release
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
5
.github/workflows/tests.yaml
vendored
5
.github/workflows/tests.yaml
vendored
@ -1,8 +1,11 @@
|
|||||||
name: Tests
|
name: Tests
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
|
goversion:
|
||||||
|
uses: ./.github/workflows/go-version.yaml
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: goversion
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -18,7 +21,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: "1.19.8"
|
go-version: ${{ needs.goversion.outputs.goversion }}
|
||||||
- run: date
|
- run: date
|
||||||
- env:
|
- env:
|
||||||
TARGET: ${{ matrix.target }}
|
TARGET: ${{ matrix.target }}
|
||||||
|
1
.go-version
Normal file
1
.go-version
Normal file
@ -0,0 +1 @@
|
|||||||
|
1.19.9
|
2
Makefile
2
Makefile
@ -55,7 +55,7 @@ docker-remove:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
GO_VERSION ?= 1.19.8
|
GO_VERSION ?= 1.19.9
|
||||||
ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound")
|
ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound")
|
||||||
|
|
||||||
TEST_SUFFIX = $(shell date +%s | base64 | head -c 15)
|
TEST_SUFFIX = $(shell date +%s | base64 | head -c 15)
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
// MinClusterVersion is the min cluster version this etcd binary is compatible with.
|
// MinClusterVersion is the min cluster version this etcd binary is compatible with.
|
||||||
MinClusterVersion = "3.0.0"
|
MinClusterVersion = "3.0.0"
|
||||||
Version = "3.5.8"
|
Version = "3.5.9"
|
||||||
APIVersion = "unknown"
|
APIVersion = "unknown"
|
||||||
|
|
||||||
// Git SHA Value will be set during build
|
// Git SHA Value will be set during build
|
||||||
|
@ -5,8 +5,8 @@ go 1.19
|
|||||||
require (
|
require (
|
||||||
github.com/json-iterator/go v1.1.11
|
github.com/json-iterator/go v1.1.11
|
||||||
github.com/modern-go/reflect2 v1.0.1
|
github.com/modern-go/reflect2 v1.0.1
|
||||||
go.etcd.io/etcd/api/v3 v3.5.8
|
go.etcd.io/etcd/api/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.8
|
go.etcd.io/etcd/client/pkg/v3 v3.5.9
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
@ -6,8 +6,8 @@ require (
|
|||||||
github.com/dustin/go-humanize v1.0.0
|
github.com/dustin/go-humanize v1.0.0
|
||||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
||||||
github.com/prometheus/client_golang v1.11.1
|
github.com/prometheus/client_golang v1.11.1
|
||||||
go.etcd.io/etcd/api/v3 v3.5.8
|
go.etcd.io/etcd/api/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.8
|
go.etcd.io/etcd/client/pkg/v3 v3.5.9
|
||||||
go.uber.org/zap v1.17.0
|
go.uber.org/zap v1.17.0
|
||||||
google.golang.org/grpc v1.41.0
|
google.golang.org/grpc v1.41.0
|
||||||
sigs.k8s.io/yaml v1.2.0
|
sigs.k8s.io/yaml v1.2.0
|
||||||
|
@ -9,12 +9,12 @@ require (
|
|||||||
github.com/spf13/cobra v1.1.3
|
github.com/spf13/cobra v1.1.3
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/urfave/cli v1.22.4
|
github.com/urfave/cli v1.22.4
|
||||||
go.etcd.io/etcd/api/v3 v3.5.8
|
go.etcd.io/etcd/api/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.8
|
go.etcd.io/etcd/client/pkg/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/v2 v2.305.8
|
go.etcd.io/etcd/client/v2 v2.305.9
|
||||||
go.etcd.io/etcd/client/v3 v3.5.8
|
go.etcd.io/etcd/client/v3 v3.5.9
|
||||||
go.etcd.io/etcd/etcdutl/v3 v3.5.8
|
go.etcd.io/etcd/etcdutl/v3 v3.5.9
|
||||||
go.etcd.io/etcd/pkg/v3 v3.5.8
|
go.etcd.io/etcd/pkg/v3 v3.5.9
|
||||||
go.uber.org/zap v1.17.0
|
go.uber.org/zap v1.17.0
|
||||||
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
|
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
|
||||||
google.golang.org/grpc v1.41.0
|
google.golang.org/grpc v1.41.0
|
||||||
@ -46,8 +46,8 @@ require (
|
|||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
|
||||||
go.etcd.io/bbolt v1.3.7 // indirect
|
go.etcd.io/bbolt v1.3.7 // indirect
|
||||||
go.etcd.io/etcd/raft/v3 v3.5.8 // indirect
|
go.etcd.io/etcd/raft/v3 v3.5.9 // indirect
|
||||||
go.etcd.io/etcd/server/v3 v3.5.8 // indirect
|
go.etcd.io/etcd/server/v3 v3.5.9 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0 // indirect
|
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0 // indirect
|
||||||
go.opentelemetry.io/otel v1.0.1 // indirect
|
go.opentelemetry.io/otel v1.0.1 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.0.1 // indirect
|
go.opentelemetry.io/otel/trace v1.0.1 // indirect
|
||||||
|
@ -25,12 +25,12 @@ require (
|
|||||||
github.com/olekukonko/tablewriter v0.0.5
|
github.com/olekukonko/tablewriter v0.0.5
|
||||||
github.com/spf13/cobra v1.1.3
|
github.com/spf13/cobra v1.1.3
|
||||||
go.etcd.io/bbolt v1.3.7
|
go.etcd.io/bbolt v1.3.7
|
||||||
go.etcd.io/etcd/api/v3 v3.5.8
|
go.etcd.io/etcd/api/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.8
|
go.etcd.io/etcd/client/pkg/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/v3 v3.5.8
|
go.etcd.io/etcd/client/v3 v3.5.9
|
||||||
go.etcd.io/etcd/pkg/v3 v3.5.8
|
go.etcd.io/etcd/pkg/v3 v3.5.9
|
||||||
go.etcd.io/etcd/raft/v3 v3.5.8
|
go.etcd.io/etcd/raft/v3 v3.5.9
|
||||||
go.etcd.io/etcd/server/v3 v3.5.8
|
go.etcd.io/etcd/server/v3 v3.5.9
|
||||||
go.uber.org/zap v1.17.0
|
go.uber.org/zap v1.17.0
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ require (
|
|||||||
github.com/prometheus/procfs v0.6.0 // indirect
|
github.com/prometheus/procfs v0.6.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
|
||||||
go.etcd.io/etcd/client/v2 v2.305.8 // indirect
|
go.etcd.io/etcd/client/v2 v2.305.9 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0 // indirect
|
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0 // indirect
|
||||||
go.opentelemetry.io/otel v1.0.1 // indirect
|
go.opentelemetry.io/otel v1.0.1 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.0.1 // indirect
|
go.opentelemetry.io/otel/trace v1.0.1 // indirect
|
||||||
|
20
go.mod
20
go.mod
@ -20,16 +20,16 @@ require (
|
|||||||
github.com/dustin/go-humanize v1.0.0
|
github.com/dustin/go-humanize v1.0.0
|
||||||
github.com/spf13/cobra v1.1.3
|
github.com/spf13/cobra v1.1.3
|
||||||
go.etcd.io/bbolt v1.3.7
|
go.etcd.io/bbolt v1.3.7
|
||||||
go.etcd.io/etcd/api/v3 v3.5.8
|
go.etcd.io/etcd/api/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.8
|
go.etcd.io/etcd/client/pkg/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/v2 v2.305.8
|
go.etcd.io/etcd/client/v2 v2.305.9
|
||||||
go.etcd.io/etcd/client/v3 v3.5.8
|
go.etcd.io/etcd/client/v3 v3.5.9
|
||||||
go.etcd.io/etcd/etcdctl/v3 v3.5.8
|
go.etcd.io/etcd/etcdctl/v3 v3.5.9
|
||||||
go.etcd.io/etcd/etcdutl/v3 v3.5.8
|
go.etcd.io/etcd/etcdutl/v3 v3.5.9
|
||||||
go.etcd.io/etcd/pkg/v3 v3.5.8
|
go.etcd.io/etcd/pkg/v3 v3.5.9
|
||||||
go.etcd.io/etcd/raft/v3 v3.5.8
|
go.etcd.io/etcd/raft/v3 v3.5.9
|
||||||
go.etcd.io/etcd/server/v3 v3.5.8
|
go.etcd.io/etcd/server/v3 v3.5.9
|
||||||
go.etcd.io/etcd/tests/v3 v3.5.8
|
go.etcd.io/etcd/tests/v3 v3.5.9
|
||||||
go.uber.org/zap v1.17.0
|
go.uber.org/zap v1.17.0
|
||||||
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
|
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
|
||||||
google.golang.org/grpc v1.41.0
|
google.golang.org/grpc v1.41.0
|
||||||
|
@ -8,7 +8,7 @@ require (
|
|||||||
github.com/spf13/cobra v1.1.3
|
github.com/spf13/cobra v1.1.3
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/stretchr/testify v1.8.1
|
github.com/stretchr/testify v1.8.1
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.8
|
go.etcd.io/etcd/client/pkg/v3 v3.5.9
|
||||||
go.uber.org/zap v1.17.0
|
go.uber.org/zap v1.17.0
|
||||||
google.golang.org/grpc v1.41.0
|
google.golang.org/grpc v1.41.0
|
||||||
)
|
)
|
||||||
|
@ -6,7 +6,7 @@ require (
|
|||||||
github.com/cockroachdb/datadriven v1.0.2
|
github.com/cockroachdb/datadriven v1.0.2
|
||||||
github.com/gogo/protobuf v1.3.2
|
github.com/gogo/protobuf v1.3.2
|
||||||
github.com/golang/protobuf v1.5.2
|
github.com/golang/protobuf v1.5.2
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.8
|
go.etcd.io/etcd/client/pkg/v3 v3.5.9
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
@ -112,10 +112,10 @@ main() {
|
|||||||
# Check go version.
|
# Check go version.
|
||||||
log_callout "Check go version"
|
log_callout "Check go version"
|
||||||
local go_version current_go_version
|
local go_version current_go_version
|
||||||
go_version="go$(grep go-version .github/workflows/tests.yaml | awk '{print $2}' | tr -d '"')"
|
go_version="go$(cat .go-version)"
|
||||||
current_go_version=$(go version | awk '{ print $3 }')
|
current_go_version=$(go version | awk '{ print $3 }')
|
||||||
if [[ "${current_go_version}" != "${go_version}" ]]; then
|
if [[ "${current_go_version}" != "${go_version}" ]]; then
|
||||||
log_error "Current go version is ${current_go_version}, but etcd ${RELEASE_VERSION} requires ${go_version} (see .travis.yml)."
|
log_error "Current go version is ${current_go_version}, but etcd ${RELEASE_VERSION} requires ${go_version} (see .go-version)."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ func newConfig() *config {
|
|||||||
fs.StringVar(&cfg.ec.DNSClusterServiceName, "discovery-srv-name", cfg.ec.DNSClusterServiceName, "Service name to query when using DNS discovery.")
|
fs.StringVar(&cfg.ec.DNSClusterServiceName, "discovery-srv-name", cfg.ec.DNSClusterServiceName, "Service name to query when using DNS discovery.")
|
||||||
fs.StringVar(&cfg.ec.InitialCluster, "initial-cluster", cfg.ec.InitialCluster, "Initial cluster configuration for bootstrapping.")
|
fs.StringVar(&cfg.ec.InitialCluster, "initial-cluster", cfg.ec.InitialCluster, "Initial cluster configuration for bootstrapping.")
|
||||||
fs.StringVar(&cfg.ec.InitialClusterToken, "initial-cluster-token", cfg.ec.InitialClusterToken, "Initial cluster token for the etcd cluster during bootstrap.")
|
fs.StringVar(&cfg.ec.InitialClusterToken, "initial-cluster-token", cfg.ec.InitialClusterToken, "Initial cluster token for the etcd cluster during bootstrap.")
|
||||||
fs.Var(cfg.cf.clusterState, "initial-cluster-state", "Initial cluster state ('new' or 'existing').")
|
fs.Var(cfg.cf.clusterState, "initial-cluster-state", "Initial cluster state ('new' when bootstrapping a new cluster or 'existing' when adding new members to an existing cluster). After successful initialization (bootstrapping or adding), flag is ignored on restarts.")
|
||||||
|
|
||||||
fs.BoolVar(&cfg.ec.StrictReconfigCheck, "strict-reconfig-check", cfg.ec.StrictReconfigCheck, "Reject reconfiguration requests that would cause quorum loss.")
|
fs.BoolVar(&cfg.ec.StrictReconfigCheck, "strict-reconfig-check", cfg.ec.StrictReconfigCheck, "Reject reconfiguration requests that would cause quorum loss.")
|
||||||
|
|
||||||
|
@ -101,7 +101,8 @@ Clustering:
|
|||||||
--initial-cluster 'default=http://localhost:2380'
|
--initial-cluster 'default=http://localhost:2380'
|
||||||
Initial cluster configuration for bootstrapping.
|
Initial cluster configuration for bootstrapping.
|
||||||
--initial-cluster-state 'new'
|
--initial-cluster-state 'new'
|
||||||
Initial cluster state ('new' or 'existing').
|
Initial cluster state ('new' when bootstrapping a new cluster or 'existing' when adding new members to an existing cluster).
|
||||||
|
After successful initialization (bootstrapping or adding), flag is ignored on restarts.
|
||||||
--initial-cluster-token 'etcd-cluster'
|
--initial-cluster-token 'etcd-cluster'
|
||||||
Initial cluster token for the etcd cluster during bootstrap.
|
Initial cluster token for the etcd cluster during bootstrap.
|
||||||
Specifying this can protect you from unintended cross-cluster interaction when running multiple clusters.
|
Specifying this can protect you from unintended cross-cluster interaction when running multiple clusters.
|
||||||
|
@ -336,7 +336,32 @@ func (s *EtcdServer) LeaseRenew(ctx context.Context, id lease.LeaseID) (int64, e
|
|||||||
return -1, ErrCanceled
|
return -1, ErrCanceled
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EtcdServer) LeaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error) {
|
func (s *EtcdServer) checkLeaseTimeToLive(ctx context.Context, leaseID lease.LeaseID) (uint64, error) {
|
||||||
|
rev := s.AuthStore().Revision()
|
||||||
|
if !s.AuthStore().IsAuthEnabled() {
|
||||||
|
return rev, nil
|
||||||
|
}
|
||||||
|
authInfo, err := s.AuthInfoFromCtx(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return rev, err
|
||||||
|
}
|
||||||
|
if authInfo == nil {
|
||||||
|
return rev, auth.ErrUserEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
l := s.lessor.Lookup(leaseID)
|
||||||
|
if l != nil {
|
||||||
|
for _, key := range l.Keys() {
|
||||||
|
if err := s.AuthStore().IsRangePermitted(authInfo, []byte(key), []byte{}); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rev, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *EtcdServer) leaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error) {
|
||||||
if s.isLeader() {
|
if s.isLeader() {
|
||||||
if err := s.waitAppliedIndex(); err != nil {
|
if err := s.waitAppliedIndex(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -386,6 +411,31 @@ func (s *EtcdServer) LeaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveR
|
|||||||
return nil, ErrCanceled
|
return nil, ErrCanceled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *EtcdServer) LeaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error) {
|
||||||
|
var rev uint64
|
||||||
|
var err error
|
||||||
|
if r.Keys {
|
||||||
|
// check RBAC permission only if Keys is true
|
||||||
|
rev, err = s.checkLeaseTimeToLive(ctx, lease.LeaseID(r.ID))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.leaseTimeToLive(ctx, r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Keys {
|
||||||
|
if s.AuthStore().IsAuthEnabled() && rev != s.AuthStore().Revision() {
|
||||||
|
return nil, auth.ErrAuthOldRevision
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LeaseLeases is really ListLeases !???
|
||||||
func (s *EtcdServer) LeaseLeases(ctx context.Context, r *pb.LeaseLeasesRequest) (*pb.LeaseLeasesResponse, error) {
|
func (s *EtcdServer) LeaseLeases(ctx context.Context, r *pb.LeaseLeasesRequest) (*pb.LeaseLeasesResponse, error) {
|
||||||
ls := s.lessor.Leases()
|
ls := s.lessor.Leases()
|
||||||
lss := make([]*pb.LeaseStatus, len(ls))
|
lss := make([]*pb.LeaseStatus, len(ls))
|
||||||
|
@ -23,12 +23,12 @@ require (
|
|||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2
|
||||||
go.etcd.io/bbolt v1.3.7
|
go.etcd.io/bbolt v1.3.7
|
||||||
go.etcd.io/etcd/api/v3 v3.5.8
|
go.etcd.io/etcd/api/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.8
|
go.etcd.io/etcd/client/pkg/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/v2 v2.305.8
|
go.etcd.io/etcd/client/v2 v2.305.9
|
||||||
go.etcd.io/etcd/client/v3 v3.5.8
|
go.etcd.io/etcd/client/v3 v3.5.9
|
||||||
go.etcd.io/etcd/pkg/v3 v3.5.8
|
go.etcd.io/etcd/pkg/v3 v3.5.9
|
||||||
go.etcd.io/etcd/raft/v3 v3.5.8
|
go.etcd.io/etcd/raft/v3 v3.5.9
|
||||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0
|
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0
|
||||||
go.opentelemetry.io/otel v1.0.1
|
go.opentelemetry.io/otel v1.0.1
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1
|
||||||
|
@ -76,6 +76,7 @@ func TestCtlV3AuthSnapshotJWT(t *testing.T) { testCtl(t, authTestSnapsho
|
|||||||
func TestCtlV3AuthJWTExpire(t *testing.T) { testCtl(t, authTestJWTExpire, withCfg(*newConfigJWT())) }
|
func TestCtlV3AuthJWTExpire(t *testing.T) { testCtl(t, authTestJWTExpire, withCfg(*newConfigJWT())) }
|
||||||
func TestCtlV3AuthRevisionConsistency(t *testing.T) { testCtl(t, authTestRevisionConsistency) }
|
func TestCtlV3AuthRevisionConsistency(t *testing.T) { testCtl(t, authTestRevisionConsistency) }
|
||||||
func TestCtlV3AuthTestCacheReload(t *testing.T) { testCtl(t, authTestCacheReload) }
|
func TestCtlV3AuthTestCacheReload(t *testing.T) { testCtl(t, authTestCacheReload) }
|
||||||
|
func TestCtlV3AuthLeaseTimeToLive(t *testing.T) { testCtl(t, authTestLeaseTimeToLive) }
|
||||||
|
|
||||||
func TestCtlV3AuthRecoverFromSnapshot(t *testing.T) {
|
func TestCtlV3AuthRecoverFromSnapshot(t *testing.T) {
|
||||||
testCtl(t, authTestRecoverSnapshot, withCfg(*newConfigNoTLS()), withQuorum(), withSnapshotCount(5))
|
testCtl(t, authTestRecoverSnapshot, withCfg(*newConfigNoTLS()), withQuorum(), withSnapshotCount(5))
|
||||||
@ -1509,3 +1510,51 @@ func hashKVs(endpoints []string, cli *clientv3.Client) ([]*clientv3.HashKVRespon
|
|||||||
}
|
}
|
||||||
return retHashKVs, nil
|
return retHashKVs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func authTestLeaseTimeToLive(cx ctlCtx) {
|
||||||
|
if err := authEnable(cx); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
cx.user, cx.pass = "root", "root"
|
||||||
|
|
||||||
|
authSetupTestUser(cx)
|
||||||
|
|
||||||
|
cx.user = "test-user"
|
||||||
|
cx.pass = "pass"
|
||||||
|
|
||||||
|
leaseID, err := ctlV3LeaseGrant(cx, 10)
|
||||||
|
if err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ctlV3Put(cx, "foo", "val", leaseID)
|
||||||
|
if err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ctlV3LeaseTimeToLive(cx, leaseID, true)
|
||||||
|
if err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cx.user = "root"
|
||||||
|
cx.pass = "root"
|
||||||
|
err = ctlV3Put(cx, "bar", "val", leaseID)
|
||||||
|
if err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cx.user = "test-user"
|
||||||
|
cx.pass = "pass"
|
||||||
|
// the lease is attached to bar, which test-user cannot access
|
||||||
|
err = ctlV3LeaseTimeToLive(cx, leaseID, true)
|
||||||
|
if err == nil {
|
||||||
|
cx.t.Fatal("test-user must not be able to access to the lease, because it's attached to the key bar")
|
||||||
|
}
|
||||||
|
|
||||||
|
// without --keys, access should be allowed
|
||||||
|
err = ctlV3LeaseTimeToLive(cx, leaseID, false)
|
||||||
|
if err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -300,3 +300,11 @@ func ctlV3LeaseRevoke(cx ctlCtx, leaseID string) error {
|
|||||||
cmdArgs := append(cx.PrefixArgs(), "lease", "revoke", leaseID)
|
cmdArgs := append(cx.PrefixArgs(), "lease", "revoke", leaseID)
|
||||||
return spawnWithExpectWithEnv(cmdArgs, cx.envMap, fmt.Sprintf("lease %s revoked", leaseID))
|
return spawnWithExpectWithEnv(cmdArgs, cx.envMap, fmt.Sprintf("lease %s revoked", leaseID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ctlV3LeaseTimeToLive(cx ctlCtx, leaseID string, withKeys bool) error {
|
||||||
|
cmdArgs := append(cx.PrefixArgs(), "lease", "timetolive", leaseID)
|
||||||
|
if withKeys {
|
||||||
|
cmdArgs = append(cmdArgs, "--keys")
|
||||||
|
}
|
||||||
|
return spawnWithExpectWithEnv(cmdArgs, cx.envMap, fmt.Sprintf("lease %s granted with", leaseID))
|
||||||
|
}
|
||||||
|
16
tests/go.mod
16
tests/go.mod
@ -28,14 +28,14 @@ require (
|
|||||||
github.com/spf13/cobra v1.1.3
|
github.com/spf13/cobra v1.1.3
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/stretchr/testify v1.8.1
|
github.com/stretchr/testify v1.8.1
|
||||||
go.etcd.io/etcd/api/v3 v3.5.8
|
go.etcd.io/etcd/api/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.8
|
go.etcd.io/etcd/client/pkg/v3 v3.5.9
|
||||||
go.etcd.io/etcd/client/v2 v2.305.8
|
go.etcd.io/etcd/client/v2 v2.305.9
|
||||||
go.etcd.io/etcd/client/v3 v3.5.8
|
go.etcd.io/etcd/client/v3 v3.5.9
|
||||||
go.etcd.io/etcd/etcdutl/v3 v3.5.8
|
go.etcd.io/etcd/etcdutl/v3 v3.5.9
|
||||||
go.etcd.io/etcd/pkg/v3 v3.5.8
|
go.etcd.io/etcd/pkg/v3 v3.5.9
|
||||||
go.etcd.io/etcd/raft/v3 v3.5.8
|
go.etcd.io/etcd/raft/v3 v3.5.9
|
||||||
go.etcd.io/etcd/server/v3 v3.5.8
|
go.etcd.io/etcd/server/v3 v3.5.9
|
||||||
go.uber.org/zap v1.17.0
|
go.uber.org/zap v1.17.0
|
||||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
|
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
|
||||||
|
@ -177,12 +177,10 @@ func testV3AuthWithLeaseRevokeWithRoot(t *testing.T, ccfg ClusterConfig) {
|
|||||||
// wait for lease expire
|
// wait for lease expire
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
|
|
||||||
tresp, terr := api.Lease.LeaseTimeToLive(
|
tresp, terr := rootc.TimeToLive(
|
||||||
context.TODO(),
|
context.TODO(),
|
||||||
&pb.LeaseTimeToLiveRequest{
|
leaseID,
|
||||||
ID: int64(leaseID),
|
clientv3.WithAttachedKeys(),
|
||||||
Keys: true,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
if terr != nil {
|
if terr != nil {
|
||||||
t.Error(terr)
|
t.Error(terr)
|
||||||
@ -553,3 +551,86 @@ func TestV3AuthWatchErrorAndWatchId0(t *testing.T) {
|
|||||||
|
|
||||||
<-watchEndCh
|
<-watchEndCh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestV3AuthWithLeaseTimeToLive(t *testing.T) {
|
||||||
|
BeforeTest(t)
|
||||||
|
clus := NewClusterV3(t, &ClusterConfig{Size: 1})
|
||||||
|
defer clus.Terminate(t)
|
||||||
|
|
||||||
|
users := []user{
|
||||||
|
{
|
||||||
|
name: "user1",
|
||||||
|
password: "user1-123",
|
||||||
|
role: "role1",
|
||||||
|
key: "k1",
|
||||||
|
end: "k3",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "user2",
|
||||||
|
password: "user2-123",
|
||||||
|
role: "role2",
|
||||||
|
key: "k2",
|
||||||
|
end: "k4",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
authSetupUsers(t, toGRPC(clus.Client(0)).Auth, users)
|
||||||
|
|
||||||
|
authSetupRoot(t, toGRPC(clus.Client(0)).Auth)
|
||||||
|
|
||||||
|
user1c, cerr := NewClient(t, clientv3.Config{Endpoints: clus.Client(0).Endpoints(), Username: "user1", Password: "user1-123"})
|
||||||
|
if cerr != nil {
|
||||||
|
t.Fatal(cerr)
|
||||||
|
}
|
||||||
|
defer user1c.Close()
|
||||||
|
|
||||||
|
user2c, cerr := NewClient(t, clientv3.Config{Endpoints: clus.Client(0).Endpoints(), Username: "user2", Password: "user2-123"})
|
||||||
|
if cerr != nil {
|
||||||
|
t.Fatal(cerr)
|
||||||
|
}
|
||||||
|
defer user2c.Close()
|
||||||
|
|
||||||
|
leaseResp, err := user1c.Grant(context.TODO(), 90)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
leaseID := leaseResp.ID
|
||||||
|
_, err = user1c.Put(context.TODO(), "k1", "val", clientv3.WithLease(leaseID))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// k2 can be accessed from both user1 and user2
|
||||||
|
_, err = user1c.Put(context.TODO(), "k2", "val", clientv3.WithLease(leaseID))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = user1c.TimeToLive(context.TODO(), leaseID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = user2c.TimeToLive(context.TODO(), leaseID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = user2c.TimeToLive(context.TODO(), leaseID, clientv3.WithAttachedKeys())
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("timetolive from user2 should be failed with permission denied")
|
||||||
|
}
|
||||||
|
|
||||||
|
rootc, cerr := NewClient(t, clientv3.Config{Endpoints: clus.Client(0).Endpoints(), Username: "root", Password: "123"})
|
||||||
|
if cerr != nil {
|
||||||
|
t.Fatal(cerr)
|
||||||
|
}
|
||||||
|
defer rootc.Close()
|
||||||
|
|
||||||
|
if _, err := rootc.RoleRevokePermission(context.TODO(), "role1", "k1", "k3"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = user1c.TimeToLive(context.TODO(), leaseID, clientv3.WithAttachedKeys())
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("timetolive from user2 should be failed with permission denied")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user