433 Commits

Author SHA1 Message Date
Marek Siarkowicz
6af760131e
Merge pull request #13687 from serathius/etcdctl
Add downgrade commands
2022-02-22 17:12:23 +01:00
Piotr Tabor
f80f477073
Merge pull request #13644 from Juneezee/refactor/t.TempDir
*: use `T.TempDir` to create temporary test directory
2022-02-21 19:52:37 +01:00
Marek Siarkowicz
d0c1c3a1fd client: Alias downgrade action enum 2022-02-21 17:58:20 +01:00
ahrtr
8681888012 fix typo, renamed ErrGPRCNotSupportedForLearner to ErrGRPCNotSupportedForLearner 2022-02-21 14:46:58 +08:00
ahrtr
5fc0092c87 trim the suffix dot from the srv.Target for etcd-client DNS lookup 2022-02-18 18:16:19 +08:00
Eng Zer Jun
e9edc5432c
*: use T.TempDir to create temporary test directory
The directory created by `T.TempDir()` and is automatically removed when
the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-01-25 00:00:46 +08:00
ahrtr
15568f4c00 add protection code for Range when the sortTarget is an invalid value 2022-01-18 07:46:37 +08:00
Piotr Tabor
fdd98477ef Update dep: require gopkg.in/yaml.v2 v2.2.8 -> v2.4.0 due to: CVE-2019-11254 2022-01-17 16:52:58 +01:00
Jille Timmermans
3710083dc3 retry_interceptor.go: Log the method that failed
When getting warnings from the retry_interceptors that RPCs failed, they
provide very little context as to what exactly failed.

I used this patch to try debugging
https://groups.google.com/g/etcd-dev/c/3hxxr9ktdpM.
2022-01-16 16:46:50 +01:00
Piotr Tabor
b2f6ffdd81
Merge pull request #13595 from serathius/enable-v2
server: --enable-v2 and --enable-v2v3 is decomissioned
2022-01-15 16:48:29 +01:00
Marek Siarkowicz
ee5ef42c5c server: --enable-v2 and --enable-v2v3 is decomissioned 2022-01-14 13:19:30 +01:00
Marek Siarkowicz
4032d4f66a Remove CodeQL errors 2022-01-13 14:29:09 +01:00
Sahdev Zala
96a9fd0a1e
Merge pull request #13574 from cunnie/defer_cancel
Golang Client docs: defer `cancel()`, avoid erroring
2022-01-03 20:03:22 -05:00
Yap Sok Ann
17fd2e7282 Disable auth gracefully without impacting existing watchers
This attempts to fix a special case of the problem described in #12385,
where trying to do `clientv3.Watch` with an expired token would result
in `ErrGRPCPermissionDenied`, due to the failing authorization check in
`isWatchPermitted`. Furthermore, the client can't auto recover, since
`shouldRefreshToken` rightly returns false for the permission denied
error.

In this case, we would like to have a runbook to dynamically disable
auth, without causing any disruption. Doing so would immediately expire
all existing tokens, which would then cause the behavior described
above. This means existing watchers would still work for a period of
time after disabling auth, until they have to reconnect, e.g. due to a
rolling restart of server nodes.

This commit adds a client-side fix and a server-side fix, either of
which is sufficient to get the added test case to pass. Note that it is
an e2e test case instead of an integration one, as the reconnect only
happens if the server node is stopped via SIGINT or SIGTERM.

A generic fix for the problem described in #12385 would be better, as
that shall also fix this special case. However, the fix would likely be
a lot more involved, as some untangling of authn/authz is required.
2021-12-31 14:39:46 +07:00
Brian Cunnie
5620a9c227
Golang Client docs: defer cancel(), avoid erroring
In the sample code demonstrating how to specify a client request
timeout, the `cancel()` is called immediately after the Put, but it
should be deferred instead, giving the Put enough time to complete.

In the canonical Golang context
[docs](https://pkg.go.dev/context#WithTimeout), the sample code sets a
`defer cancel()` immediately after context creation, and with this
commit we adhere to that convention.

fixes:
```json
{
  "level": "warn",
  "ts": "2021-12-29T09:56:42.439-0800",
  "logger": "etcd-client",
  "caller": "v3@v3.5.1/retry_interceptor.go:62",
  "msg": "retrying of unary invoker failed",
  "target": "etcd-endpoints://0xc000213340/localhost:2379",
  "attempt": 0,
  "error": "rpc error: code = Canceled desc = context canceled"
}
```
2021-12-29 14:10:36 -08:00
Piotr Tabor
69279532f4
Merge pull request #13540 from songlh-psu/fixing-3
fixing one panic and two goroutine leaks
2021-12-21 11:03:59 +01:00
Linhai Song
0098dbf350 fixing two goroutine leaks and one panic 2021-12-15 22:38:25 -05:00
Linhai
d1194977eb fix potential goroutine leaks in TestTxnPanics 2021-12-15 01:22:56 -05:00
Kushal Pisavadia
71493bde3e *: Upgrade to use go.opentelemetry.io/otel@v1.2.0
Upgrading from v1.0.1.

Upgrading related dependencies
------------------------------

The following dependencies also had to be upgraded:

- go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.26.1
  From v0.25.0. This gets rid of a transitive dependency on go.opentelemetry.io/otel@v1.0.1.
- google.golang.org/genproto@v0.0.0-20211118181313-81c1377c94b1
2021-11-24 16:03:33 +00:00
Chao Chen
b5e4c2d3c4 client/v2: remove unsafe json-iterator/reflect2 2021-11-09 11:16:40 -08:00
Piotr Tabor
9c28e07588
Merge pull request #13447 from Juneezee/deprecate-ioutil
*: move from io/ioutil to io and os packages
2021-10-29 23:18:36 +02:00
Sam Batschelet
316e62b4e1 *: fixup go 1.17 bump
Signed-off-by: Sam Batschelet <sbatsche@redhat.com>
2021-10-27 14:26:55 -04:00
Eng Zer Jun
2a151c8982
*: move from io/ioutil to io and os packages
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-10-28 00:05:28 +08:00
Lili Cosic
e6e279a14d *: Bump go to go v1.17.2 2021-10-27 13:44:54 +02:00
Piotr Tabor
8aa6ae9bbb
Merge pull request #13361 from vooon/otel-1.0.0
server: update OpenTelemetry to 1.0.1
2021-10-20 14:14:00 +02:00
Vladimir Ermakov
49a8aa7f49
run fix.sh
To fix dependencies.

Signed-off-by: Vladimir Ermakov <vooon341@gmail.com>
2021-10-13 14:08:27 +03:00
Arda Güçlü
d7fa8022e6
Merge branch 'main' into support-zap-console-encoding 2021-10-08 11:00:57 +03:00
Aleksandr Razumov
3644c9d67b
client/pkg/fileutil: add missing logger to {Create,Touch}DirAll
Also populate it to every invocation.
2021-10-07 17:53:59 +03:00
Marek Siarkowicz
c929a917b6 client: Use first endpoint as http2 authority header 2021-09-29 14:41:35 +02:00
Piotr Tabor
ca5bad0e83
Merge pull request #13261 from njhill/sorting
etcdserver,clientv3: server-side ignore sort-ascend-key for range reqs
2021-09-25 17:47:10 +02:00
Arda Güçlü
3c6e09f932 Handle empty log-format gracefully 2021-09-23 08:17:29 +03:00
Arda Güçlü
ec252d06c9 Return error when log-format is invalid 2021-09-22 19:45:08 +03:00
Arda Güçlü
e647995a38 Add zap encoding configurable
Json encoding is the default zap encoding value and can not be changeable.
This PR enables configuring zap encoding to console via new flag `log-format`.
2021-09-22 15:48:47 +03:00
Tero Saarni
78463237d4 Merge branch 'main' into etcd-client-solaris-build 2021-09-10 11:31:44 +03:00
leoyang.yl
ad69fe0f40 fix IsOptsWithFromKey
fix IsOptsWithFromKey

fix IsOptsWithFromKey

fix IsOptsWithFromKey

fix IsOptsWithFromKey

fix IsOptsWithFromKey
2021-09-10 00:44:52 +08:00
Hitoshi Mitake
2a750a8dba *: implement a retry logic for auth old revision in the client 2021-09-05 01:13:52 +09:00
Tero Saarni
af626ebfde client/pkg/v3: fixes Solaris build of transport
Add empty implementation for reuse port socket option since Solaris does not
support SO_REUSEPORT.
2021-08-30 11:44:02 +03:00
Ashish Ranjan
6d300fd38b client/v3: refresh the token when ErrUserEmpty is received while retrying
To fix a bug in the retry logic caused when the auth token is cleared after receiving `ErrInvalidAuthToken` from the server and the subsequent call to `getToken` also fails due to some reason (eg. context deadline exceeded).
This leaves the client without a token and the retry will continue to fail with `ErrUserEmpty` unless the token is refreshed.
2021-08-25 11:27:19 +08:00
nickhill
99182f5404 etcdserver,clientv3: server-side ignore sort-ascend-key for range requests
A client-side optimization was made in #6100 to filter ascending key sorts to avoid an unnecessary re-sort since this is the order already returned by the back-end logic.

It seems to me that this really belongs on the server side since it's tied to the server implementation and should apply for any caller of the kv api (for example non-go clients).

Related, the client/v3 syncer depends on this default sorting which isn't explicit in the kv api contract. So I'm proposing the required sort parameters be included explicitly; it will take the fast path either way.
2021-07-30 15:02:15 -07:00
Yi-Shu Tai
77a5072b69 client: call .Endpoints() in dial() in client/v3/client.go instead of accessing cfg.Endpoints directly
0cdd558361/client/v3/client.go (L299) accesses
endpoints without acquiring lock. Fix it to call Endpoints()

Fix #13201
2021-07-27 15:55:22 -07:00
Piotr Tabor
40da254d68
Merge pull request #13146 from tklauser/filelock-x-sys-windows
client/pkg/fileutil: use `golang.org/x/sys/windows` for `FileLockEx`
2021-07-01 10:44:08 +02:00
Piotr Tabor
7271adecc5
Merge pull request #12992 from awly/client-auth-bundle-overwrite
client/v3: do not overwrite authTokenBundle on dial
2021-07-01 10:40:18 +02:00
Marek Siarkowicz
86f68b9374 *: Add missing file licenses and Fix static analysis prevent skipping them in future 2021-06-29 12:52:02 +02:00
Tobias Klauser
c3fe63a658 client/pkg/fileutil: use golang.org/x/sys/windows for FileLockEx
Use the FileLockEx wrapper and the corresponding LOCKFILE_* and error
constants from the golang.org/x/sys/windows package rather than
implementing these in the fileutil package.
2021-06-25 14:44:30 +02:00
Andrew Lytvynov
ab8e5a4f8e client/v3: do not overwrite authTokenBundle on dial
`Client.dial` can be called multiple times. For example, from regular
`NewClient` and [from the `Maintenance`
wrapper](6d451ab61d/client/v3/maintenance.go (L81-L84)).

This ends up creating two (if `Client.dial` is called twice) independent
`credentials.Bundle` instances:
- the first one is wired into `PerRPCCredentials` callback in gRPC
  client.
- the second one is in `Client.authTokenBundle` and receives the latest
  auth token updates.

When using username/password authentication and the server is configured
to issue JWTs, token rotation logic breaks because of the above
`credentials.Bundle` confusion.
2021-06-23 09:44:27 -07:00
Lili Cosic
df696a7e76 go.mod: Bump etcd to 3.5.0 2021-06-22 12:25:39 +02:00
Piotr Tabor
5564476831
Merge pull request #13073 from serathius/snapshot-version
[Version in Snapshot] SnapshotResponse includes local etcd version
2021-06-21 16:56:00 +02:00
Brandon Philips
1a943350b0
client: README: update to new go.mod paths
The paths in the readme and go.dev docs are out of date after v3.5
2021-06-15 19:47:22 -07:00
Marek Siarkowicz
e1b1d93548 *: Snapshot returns local etcd version
Co-authored-by: Lili Cosic <cosiclili@gmail.com>
2021-06-14 16:36:50 +02:00
Lili Cosic
16477a8270 Update client_golang dependency to v1.11.0 2021-06-07 14:49:57 +02:00