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

SIGTERM handling in kube-runtime #275

Closed
clux opened this issue Jul 19, 2020 · 3 comments
Closed

SIGTERM handling in kube-runtime #275

clux opened this issue Jul 19, 2020 · 3 comments
Labels
question Direction unclear; possibly a bug, possibly could be improved. runtime controller runtime related

Comments

@clux
Copy link
Member

clux commented Jul 19, 2020

Looking at how to safely run reflectors/watchers now and the signal handler one I don't have a good answer to anymore. I think that if we get SIGTERM, it's unclear where we put the signal handlers:

  • in client during watch calls? -> PRO: will propagate errors up very quickly, CON: unexpected
  • injected sentinel into watcher stream -> PRO: expected, CON: might have to wait 300s for watch call (too late on k8s)
  • between watch events in runtime objects -> PRO: what we did before, CON: might have to wait on slow streams
  • in main: PRO: less dependency bloat, CON: can kill a reconciler mid execution

We did use to do 3 in old Reflector, but it's not really a good solution.
Considering whether this is just something we need to do at the deepest level (even if it only affects the runtime). Maybe feature-flag it?

@clux clux added question Direction unclear; possibly a bug, possibly could be improved. runtime controller runtime related labels Jul 19, 2020
@clux
Copy link
Member Author

clux commented Jul 19, 2020

StreamExt::take_until does look like it might work. There's also this stream_cancel crate that builds on top of it.

@clux
Copy link
Member Author

clux commented Jul 27, 2020

Another possible solution is to wrap the drainer future in an abortable and trigger aborthandle.abort() on SIGTERM with tokio::signal. Though, not sure how deep it goes before it stops. Does it finish a reconcile, or could it stop in the middle of one (since it can spawn its own futures).

The docs on AbortHandle::abort are a bit unclear:

Notifies the Abortable future associated with this handle that it should abort. Note that if the future is currently being polled on another thread, it will not immediately stop running. Instead, it will continue to run until its poll method returns.

@clux clux added the help wanted Not immediately prioritised, please help! label Aug 5, 2020
@clux clux removed the help wanted Not immediately prioritised, please help! label Oct 22, 2021
@clux
Copy link
Member Author

clux commented Oct 22, 2021

This was done in #573

@clux clux closed this as completed Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Direction unclear; possibly a bug, possibly could be improved. runtime controller runtime related
Projects
None yet
Development

No branches or pull requests

1 participant