-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[deb/rpm] try restart on upgrade #20473
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
Jenkins, test this /cc @elastic/kibana-operations |
💔 Build Failed |
I don't see how the build failure corresponds to my changes... |
Jenkins, test this |
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.
Overall it looks fine to me, I just point 2 small things @jsoref 😃
@@ -0,0 +1,15 @@ | |||
#!/bin/sh |
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 believe the name of this file could be changed to post_upgrade.sh
in order to follow the same logic of the others 😃
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.
Sure
@@ -151,9 +155,15 @@ case "$1" in | |||
fi | |||
exit $code | |||
;; | |||
condrestart|try-restart) |
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.
why the addition of two options condrestart
and try-restart
? Isn't try-restart
enough?
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.
This was copy-paste from someone else's script. There are essentially two different verbs in common use for this action. Since I'm adding the thing, it seemed reasonable to support both for humans as opposed to just for this thing itself.
I don't have a strong opinion about this. My systems going forward are Debian derivatives with systemd...
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.
https://www.cyberciti.biz/faq/linux-unix-sysvinit-services-restart-vs-reload-vs-condrestart/ for lack of a better reference
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.
set -e | ||
|
||
if command -v systemctl >/dev/null ; then | ||
systemctl reload kibana.service |
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.
This apparently doesn't do what I wanted sigh.
I'll change it to systemctl daemon-reload
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.
Good one here, it escaped to me! We want to reload the systemd manager configuration here and the correct is systemctl daemon-reload
.
💔 Build Failed |
Thanks jsoref! No worries about the build for now, it's unrelated. |
rename file; properly reload daemon
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 believe fpm does some magic with --after-upgrade by wrapping the postrm script with a few if statements to handle remove/upgrade. The post remove script already covers these cases, and so when it gets wrapped and called as a function it loses arguments($1) and doesn't know what to do.
|
Dropping the 6.3 label, normally it would go in as a bug fix but the amount the testing involved is significant for a patch release :) |
I'd have to think about it more but I'm wondering if we can add try-restart to https://github.com/elastic/kibana/blob/master/src/dev/build/tasks/os_packages/package_scripts/post_install.sh#L7. In deb we can detect upgrade by checking configure for $2 which will have the version we're upgrading from. |
@jbudz it looks like Also for rpm it looks like it is relying on Do you believe the problem you talk about in the previous comment related with |
fpm is doing it but we need it for other reasons, so it's kinda getting in the way. i'd prefer that we kept full control to be as flexible as possible but i could be convinced. I opened jsoref#2 to demo what I was going with above. @jsoref if you don't have time lmk and I can run with it in a separate PR - thanks for all your patience on this. |
one other note for anyone testing: this won't work for one release cycle. the post_remove script of the old package will stop kibana, and try-restart will check if kibana is running and it won't be. i'd recommend installing new builds twice or creating a fake newer version. |
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
Example test cases:
rpm/deb need to be tested separately, there are conditions for both and the script orders are different
upgrade from old to this:
- install 6.3
- start kibana
- install 6.4
- kibana should be stopped (edge case - old 6.3 post_remove script still exists)
- remove kibana
- no errors
upgrade from this to future:
- install 6.4
- start kibana
- install 6.4+
- kibana should be running
- remove kibana
- no errors
init scripts:
- install 6.4
- /etc/init.d/kibana try-restart
- kibana is not running
- /etc/init.d/kibana start
- /etc/init.d/kibana try-restart
- kibana is running
- /etc/init.d/kibana stop
- kibana is not running
- systemctl start kibana.service
- systemctl try-restart kibana.service
- kibana is running
Release notes:
Future versions of kibana's deb/rpm packages will restart on upgrade
Thanks a bunch @jsoref we're going to get one more reviewer on this before merging. |
The more I think about this, the more I am of the opinion that we should touch the service at all. There are possible issues with file locks if we let the service continue to run - and a restart is not likely to work if there are plugins which need to be upgraded. |
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.
@jsoref, I really appreciate this PR and the effort that went into it. I have discussed with some other folks within the company, and the consensus was for the install scripts to avoid interacting with the service. This allows the user to decide how they intend on handling the service. This is also the path which Logstash has taken.
@tylersmalley: I don't really have an opinion on this thing. All I can say is that the current behavior (as described in #9863) is really awful. Someone complained about it, I looked, found a vaguely reasonable approach and offered it. If you or someone else plan to fix this some other way, that's great. If you plan to leave it broken, that's not great. If you want me to do something else, I'm open to suggestions w/in reason (I'm not rewriting your entire codebase, but a <20 line delta against where you are today or any state my PR has been would be reasonable). As a user of these services, the fact that upgrades don't actually work w/ a simple command is IMHO a bug, and I wonder if there's any intention of fixing that (I wouldn't expect that to be done for this issue / PR, but, I'm asking about a roadmap). As a general rule, I'm in favor of consistency, so if logstash has decided to not touch the service but no one updated kibana to have the same behavior, then making kibana consistent would be a positive change in my book. -- That said, I can't figure out where the equivalent-ish code lives in logstash. I'm not sure how well logstash's approach works -- most modern things delay-load/dynamically load modules as needed, which means that if an installer replaces files on disk and they haven't yet been loaded by a program, then when the program decides to load them, if it gets a version that's newer (and probably incompatible w/ its running instance), they tend to explode -- I'm very used to java applications having exactly this problem when the java runtime is upgraded and the java process isn't. -- We have tried experimenting w/ addon modules in logstash and they seem to explode when things aren't perfect (and they certainly seem like they're loading dynamically). |
There have been lots of changes in master . I would recommend pulling master into your branches and re run the tests. |
💔 Build Failed |
💔 Build Failed |
#9863
no
yarn test && yarn build
?no
yes