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

Implement systemd notification #7028

Closed
astorath opened this issue Jul 1, 2019 · 5 comments
Closed

Implement systemd notification #7028

astorath opened this issue Jul 1, 2019 · 5 comments
Labels
core Issues and Pull-Requests specific to Vault Core enhancement

Comments

@astorath
Copy link

astorath commented Jul 1, 2019

Is your feature request related to a problem? Please describe.
Using vault binary as a systemd unit have some control problem:

  • vault does not have daemon mode
  • vault does not support systemd notification system

So when service starts unsuccessfully (due to config error for instance), systemctl can't report the problem right away and systemd keeps restarting failing unit forever.

Describe the solution you'd like
I think the best solution is to implement systemd notification when vault (or vault agent) is ready to accept requests.

Example from consul: agent.go

Describe alternatives you've considered
I've implemented a simple bash wrapper to check for active port after vault startup. This is a dirty solution:

  • it makes startup take longer
  • checking port availability is not the same as checking service is ready
  • requires some unnecessary intermediate script

Explain any additional use-cases
You can implement WATCHDOG notification to make systemd monitor unit health.

Additional context
I see that github.com/coreos/go-systemd module is in

github.com/coreos/go-systemd/journal
and

vault/go.sum

Line 104 in 0a58f30

github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 h1:u9SHYsPQNyt5tgDm3YN7+9dYrpK96E5wFilTFWIDZOM=
, maybe there were some attempts to implement it already?

@michelvocks michelvocks added enhancement core Issues and Pull-Requests specific to Vault Core labels Nov 6, 2019
@aphorise
Copy link
Contributor

Should be implemented in above PR (make a note for my own reference).

@sgmiller
Copy link
Collaborator

sgmiller commented May 3, 2021

Implemented using a cleaner dep, and also notifying on shutdown/config reload: #11517

@aphorise
Copy link
Contributor

@astorath can you confirm if the merged changes already accommodate for what you were after within the latest 1.7.x or higher releases?

@qk4l
Copy link
Contributor

qk4l commented Oct 24, 2021

@sgmiller Thank you for implementation.
I've tried this functional (1.8.4) and found the problem with reload.
Currently there is not SdNotifyReady call after reload, so systemd wait, timeout and then call restart.
https://github.com/coreos/go-systemd/blob/main/daemon/sdnotify.go#L39

Some logs...

Oct 24 20:42:18 example.com systemd[1]: Reloading vault.service.
Oct 24 20:42:18 example.com vault[32106]: ==> Vault reload triggered
Oct 24 20:42:18 example.com vault[32106]: 2021-10-24T20:42:18.709+0300 [DEBUG] sent systemd notification: notification=RELOADING=1
...
Oct 24 20:45:19 example.com systemd[1]: vault.service reload operation timed out. Stopping.
Oct 24 20:47:13 example.com systemd[1]: Stopped vault.service.
Oct 24 20:47:13 example.com systemd[1]: Starting vault.service...
Oct 24 20:47:14 example.com systemd[1]: Started vault.service.

@ncabatoff
Copy link
Collaborator

This was fixed in #11517 and should've been closed then. Closing.

ncabatoff added a commit that referenced this issue May 3, 2022
…g config #7028 (#15041) (#15269)

Co-authored-by: Alexander Tischenko <tsm@archaron.ru>
ncabatoff added a commit that referenced this issue May 5, 2022
…g config #7028 (#15041) (#15267)

Co-authored-by: Alexander Tischenko <tsm@archaron.ru>
ncabatoff added a commit that referenced this issue May 9, 2022
…ted reloading config #7028 into release/1.10.x (#15265)

* backport of commit d230c83

* backport of commit 56fba39

Co-authored-by: Alexander Tischenko <tsm@fiberside.ru>
Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
ncabatoff pushed a commit that referenced this issue Aug 29, 2022
Agent systemd notify added similar to Consul. Resolves: #7028
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues and Pull-Requests specific to Vault Core enhancement
Projects
None yet
Development

No branches or pull requests

6 participants