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

[1.6] Various etcd fixes backports #12748

Merged
merged 5 commits into from Aug 3, 2020
Merged

[1.6] Various etcd fixes backports #12748

merged 5 commits into from Aug 3, 2020

Conversation

tgraf
Copy link
Member

@tgraf tgraf commented Aug 3, 2020

Various etcd bug fixes

[ upstream commit bfac77f ]

Due to creating a context with a timeout prior to blocking on the
session channel to wait for it to end, the timeout of the context will
likely already hvae expired by the time the kvstore operation is
performed. It is thus cancelled immediately, requiring a subsequent
controller call. This prolongs the time the session is renewed and
causes unnecessary controller failures which can be mistaken for etcd
issues.

Also pass the etcd client context to the controller to bind the
lifecycle of a controller run to it.

This fixes errors like these:
```
  kvstore-etcd-lock-session-renew   20s ago        10s ago      1       unable to renew etcd lock session: context deadline exceeded
```

MERGE CONFLICT: The controller layer does not support providing a context so
the client context is passed in later. It means that we can't merge the
controller and etcd client context.

Signed-off-by: Thomas Graf <thomas@cilium.io>
[ upstream commit ba9031b ]

The controller functions could potentially block forever while waiting
on channels to close. Bind waiting on the channel and check of the etcd
version to the controller and etcd client context so these operations
get cancelled.

MERGE CONFLICT:
Due to not passing the etcd client context to the controller, the etcd client
context is an exit case as well.

Signed-off-by: Thomas Graf <thomas@cilium.io>
[ upstream commit f6a751f ]

Same as ba9031b ("etcd: Ensure that session renewal controller exit") but
for the lock session.

MERGE CONFLICT: Due to not providing the etcd client context to the controller,
the etcd client controller must be checked as well in the select conditionals.

Signed-off-by: Thomas Graf <thomas@cilium.io>
[ upstream commit 02a1810 ]

Signed-off-by: Thomas Graf <thomas@cilium.io>
[ upstream commit 0262854 ]

The context passed into NewSession() was supposed to enforce a timeout on the
NewSession() operation which is triggering a Grant() and KeepAlive()
instruction. However, the context passed into NewSession() will also be
associated with the resulting lease. As per etcd documentation, this will
result in:

> If the context is canceled before Close() completes, the session's lease will
> be abandoned and left to expire instead of being revoked.

Because of this, any session renewal triggering a new session would create a
session that is immediately closed again due to the context passed into
NewSession being cancelled when the controller run ends successfully. This
resulted in any renewed session to have an effective lifetime of 10
milliseconds before requiring renewal again.

Fixes: #12619
Fixes: 8524fca ("kvstore: Add session renew backoff")

Signed-off-by: Thomas Graf <thomas@cilium.io>
@tgraf tgraf requested a review from a team as a code owner August 3, 2020 12:01
@maintainer-s-little-helper maintainer-s-little-helper bot added the kind/backports This PR provides functionality previously merged into master. label Aug 3, 2020
@tgraf
Copy link
Member Author

tgraf commented Aug 3, 2020

test-backport-1.6

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Aug 3, 2020
@tklauser tklauser merged commit 0bbe6a6 into v1.6 Aug 3, 2020
@tklauser tklauser deleted the pr/backports/1.6-etcd branch August 3, 2020 15:20
@aanm aanm changed the title [1.6] Various etcd fixe backports [1.6] Various etcd fix backports Aug 3, 2020
@aanm aanm changed the title [1.6] Various etcd fix backports [1.6] Various etcd fixes backports Aug 3, 2020
pkg/kvstore/etcd.go Show resolved Hide resolved
pkg/kvstore/etcd.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/backports This PR provides functionality previously merged into master. ready-to-merge This PR has passed all tests and received consensus from code owners to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants