-
Notifications
You must be signed in to change notification settings - Fork 352
feat: Add support for systemd notify #719
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
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
|
||
| logging.Infof("Ready for new connections") | ||
|
|
||
| go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I debated this a bit, but ended up running the notifies in separate goroutines to guard against any potential weirdness. Would gladly have a discussion on if this is a good idea or not.
The call dials a unix socket (but only if NOTIFY_SOCKET is set), and I'm wary that under the right set of unfortunate circumstances that could hang. But I don't know exactly what those circumstances would be (maybe if systemd itself is hanging)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any idea what the impact on systems without systemd might be?
Is this actually ready at this point in time? Or does it need to wait for proxyCleint.Run() to be called below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the docs, looks like this only kicks in if $NOTIFY_SOCKET is set (which you referred to above). So this shouldn't have any effect on systems without systemd present? Have you done any testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly, the code bails early if the environment variable isn't set. So non-systemd users will not get any change in behaviour unless they set that themselves.
Is this actually ready at this point in time?
Probably no, you are very correct that it should be holding until after proxyClient.Run, at least. In my testing the connection set up fast enough that I didn't see that the log statement above my addition was a bit premature.
But yes, I've done testing, and apart from that embarrassing part, the happy cases work well. I'm not sure what the less happy ones would be, though. From digging a bit, it looks like even proxyClient.Run might not be entirely correct, since it just kicks off the connections starting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're actually okay, because we start receiving connections with the connSrc is initialized, even if they aren't handled until Run() is called. However it's probably logically better to move this down closer to .Run() and add a comment, to help minimize the chance of a potentially long running bit sneaking in-between the two sections.
|
I'm not sure why the CLA doesn't work. I'm fairly sure I've signed it previously, but now it appears to try to match it up against my corporate identity when I open the link? (Not US-based, and my employer does not have rights over my spare time contributions) |
kurtisvg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to consider putting it behind a flag as well - user's without systemd might be
|
|
||
| logging.Infof("Ready for new connections") | ||
|
|
||
| go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any idea what the impact on systems without systemd might be?
Is this actually ready at this point in time? Or does it need to wait for proxyCleint.Run() to be called below.
|
|
||
| logging.Infof("Ready for new connections") | ||
|
|
||
| go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the docs, looks like this only kicks in if $NOTIFY_SOCKET is set (which you referred to above). So this shouldn't have any effect on systems without systemd present? Have you done any testing?
|
@carlpett also RE: CLA bot, it uses the commit email. Is that address correct for the CLA? |
|
Yes, should be. But signing in with my private account if doesn't seem to find the old CLA, so 🤷 Re-signed it now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. We are planning a release tomorrow, but we're gonna wait until it's complete before merging this in.
Also @enocom is gonna run a couple of smoke tests on:
- linux w/ systemd
- windows (w/o systemd)
|
Sorry for the slow response. I'll be double-checking this today. |
|
I ran the following test to confirm that this PR works with systemd where First I used the following unit file: And then I built the proxy from this PR and confirmed the service started: Next, I rebuilt the binary, omitted the call to |
|
I tried this change out on a Window machine as well. Here's what I did:
All works as expected. |
|
As for #234, I think this PR won't entirely fix the issue and so we should keep the issue open after merging this. |
|
Thanks @carlpett for this PR. Looks great. |
|
Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, one of your required reviews was not approved, or there is a do not merge label. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot. |
Change Description
This PR adds support for running with
Type=notifyunder systemd. The benefit of this is that service startup is not marked as successful until the signal has been sent, meaning other services with appropriateRequiresandAfterdirectives won't try to start until the proxy is ready to handle connectionsChecklist
Relevant issues: