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

fix(kuma-cp): graceful components #4277

Merged
merged 2 commits into from
May 16, 2022
Merged

Conversation

jakubdyszkiewicz
Copy link
Contributor

Summary

To implement a graceful shutdown, I had to disable signal propagation from Kuma DP to Envoy. That means that we need to take care of sending the signal ourselves. This has a disadvantage that if we won't do this, Envoy (and other subprocesses) will still be running. This is not a problem on Kubernetes since the whole Pod will go down, but it is a problem on VMs.

There was a race that we were not waiting until all components are stopped. This could result in stopping Kuma DP process without closing context that is passed to Envoy command which results in not sending SIGTERM.

I implemented GracefulComponent that adds additional optional logic of waiting until the component is finished. The logic is specific to every component. In the case of Envoy and CoreDNS, the main process waits until the command finish.

I considered adding WaitForDone to Component, but this would result in empty implementations for tens of components, which is also not that relevant if they are not manage external resources. I expect that moving this to Component will be done in #1001

Issues resolved

Not reported, I noticed it while testing.

Documentation

No extra docs.

Testing

  • Unit tests
  • E2E tests (really hard to write E2E for this)
  • Manual testing on Universal
  • Manual testing on Kubernetes

Backwards compatibility

- [ ] Update UPGRADE.md with any steps users will need to take when upgrading.

  • No backporting since it was not released yet

@jakubdyszkiewicz jakubdyszkiewicz requested a review from a team as a code owner May 12, 2022 16:29
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
@jakubdyszkiewicz jakubdyszkiewicz force-pushed the feat/graceful-components branch from 6c36e0f to 161fdc1 Compare May 12, 2022 16:30
@codecov-commenter
Copy link

codecov-commenter commented May 12, 2022

Codecov Report

Merging #4277 (f806edd) into master (4baa7d6) will increase coverage by 0.00%.
The diff coverage is 68.42%.

@@           Coverage Diff           @@
##           master    #4277   +/-   ##
=======================================
  Coverage   55.68%   55.69%           
=======================================
  Files         935      935           
  Lines       56402    56421   +19     
=======================================
+ Hits        31410    31424   +14     
- Misses      22513    22518    +5     
  Partials     2479     2479           
Impacted Files Coverage Δ
pkg/plugins/bootstrap/k8s/plugin.go 3.12% <0.00%> (-0.11%) ⬇️
app/kuma-dp/pkg/dataplane/dnsserver/dnsserver.go 72.97% <100.00%> (+1.54%) ⬆️
app/kuma-dp/pkg/dataplane/envoy/envoy.go 79.34% <100.00%> (+0.93%) ⬆️
pkg/core/runtime/component/component.go 93.54% <100.00%> (+0.56%) ⬆️
pkg/plugins/leader/postgres/leader_elector.go 93.61% <0.00%> (-6.39%) ⬇️
pkg/plugins/runtime/gateway/route/sorter.go 66.66% <0.00%> (-5.13%) ⬇️
pkg/plugins/resources/postgres/store.go 76.79% <0.00%> (+0.42%) ⬆️
pkg/core/secrets/manager/global_manager.go 45.45% <0.00%> (+3.03%) ⬆️
pkg/core/tokens/default_signing_key.go 86.11% <0.00%> (+8.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4baa7d6...f806edd. Read the comment docs.

Copy link
Contributor

@michaelbeaumont michaelbeaumont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just 2 small things that you can ignore either way

app/kuma-dp/pkg/dataplane/dnsserver/dnsserver.go Outdated Show resolved Hide resolved
pkg/core/runtime/component/finalizer.go Outdated Show resolved Hide resolved
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
@jakubdyszkiewicz jakubdyszkiewicz merged commit 24d2dae into master May 16, 2022
@jakubdyszkiewicz jakubdyszkiewicz deleted the feat/graceful-components branch May 16, 2022 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants