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

[deb/rpm] try restart on upgrade #20473

Closed
wants to merge 6 commits into from
Closed

Conversation

jsoref
Copy link
Contributor

@jsoref jsoref commented Jul 4, 2018

#9863

  • If submitting code, have you included unit tests that cover the changes?
    no
  • If submitting code, have you tested and built your code locally prior to submission with yarn test && yarn build?
    no
  • If submitting code, is your pull request against master? Unless there is a good reason otherwise, we prefer pull requests against master and will backport as needed.
    yes

@elasticmachine
Copy link
Contributor

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?

@timroes
Copy link
Contributor

timroes commented Jul 5, 2018

Jenkins, test this

/cc @elastic/kibana-operations

@elasticmachine
Copy link
Contributor

💔 Build Failed

@jsoref
Copy link
Contributor Author

jsoref commented Jul 5, 2018

I don't see how the build failure corresponds to my changes...

@mistic
Copy link
Member

mistic commented Jul 5, 2018

Jenkins, test this

@mistic mistic added Team:Operations Team label for Operations Team review labels Jul 5, 2018
Copy link
Member

@mistic mistic left a 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
Copy link
Member

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 😃

Copy link
Contributor Author

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)
Copy link
Member

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?

Copy link
Contributor Author

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@jsoref I also found docs about this here. I'm fine with it!

set -e

if command -v systemctl >/dev/null ; then
systemctl reload kibana.service
Copy link
Contributor Author

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

Copy link
Member

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.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@jbudz
Copy link
Member

jbudz commented Jul 5, 2018

Thanks jsoref! No worries about the build for now, it's unrelated.

@jinmu03 jinmu03 added v6.3.2 and removed v6.3.1 labels Jul 5, 2018
jsoref added 2 commits July 6, 2018 01:13
rename file;
properly reload daemon
Copy link
Member

@mistic mistic left a comment

Choose a reason for hiding this comment

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

@jsoref It's good for me now! Thanks for the work!
What do you think @jbudz ?

@jbudz
Copy link
Member

jbudz commented Jul 9, 2018

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.

root@kbdeb64:/vagrant# sudo dpkg --purge kibana
(Reading database ... 56185 files and directories currently installed.)
Removing kibana (7.0.0-alpha1-SNAPSHOT) ...
post remove script called with unknown argument `'
dpkg: error processing package kibana (--purge):
 subprocess installed post-removal script returned error exit status 1
cat /var/lib/dpkg/info/kibana.postrm

@jbudz
Copy link
Member

jbudz commented Jul 9, 2018

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 :)

@jbudz jbudz removed the v6.3.2 label Jul 9, 2018
@jbudz
Copy link
Member

jbudz commented Jul 9, 2018

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.
In rpm we can detect upgrade by the argument 1 is initial installation, and the argument 2 is upgrade.

@mistic
Copy link
Member

mistic commented Jul 10, 2018

@jbudz it looks like fpm is already doing a thing close to what you suggest at least for deb (https://github.com/jordansissel/fpm/blob/master/templates/deb/postinst_upgrade.sh.erb#L49).

Also for rpm it looks like it is relying on post-install because it is under %post section (https://github.com/jordansissel/fpm/blob/master/templates/rpm.erb#L185) and the %post section maps to after_install (https://github.com/jordansissel/fpm/blob/master/templates/rpm.erb#L213).

Do you believe the problem you talk about in the previous comment related with "fpm does some magic with --after-upgrade by wrapping the postrm script with a few if statements to handle remove/upgrade" could still exists? Or do my findings solve the doubts?

@jbudz
Copy link
Member

jbudz commented Jul 11, 2018

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.

@jbudz
Copy link
Member

jbudz commented Jul 11, 2018

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.

@mistic
Copy link
Member

mistic commented Jul 11, 2018

@jbudz I'm not against what you have on jsoref#2

For me is good to go once it get merged into this PR!

Copy link
Member

@jbudz jbudz left a 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:

  1. install 6.3
  2. start kibana
  3. install 6.4
    • kibana should be stopped (edge case - old 6.3 post_remove script still exists)
  4. remove kibana
    • no errors

upgrade from this to future:

  1. install 6.4
  2. start kibana
  3. install 6.4+
    • kibana should be running
  4. remove kibana
    • no errors

init scripts:

  1. install 6.4
  2. /etc/init.d/kibana try-restart
    • kibana is not running
  3. /etc/init.d/kibana start
  4. /etc/init.d/kibana try-restart
    • kibana is running
  5. /etc/init.d/kibana stop
    • kibana is not running
  6. systemctl start kibana.service
  7. systemctl try-restart kibana.service
    • kibana is running

Release notes:
Future versions of kibana's deb/rpm packages will restart on upgrade

@jbudz
Copy link
Member

jbudz commented Jul 11, 2018

Thanks a bunch @jsoref we're going to get one more reviewer on this before merging.

@jbudz jbudz changed the title Try restart [deb/rpm] try restart on upgrade Jul 16, 2018
@jbudz jbudz requested a review from tylersmalley July 16, 2018 16:11
@tylersmalley
Copy link
Contributor

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.

Copy link
Contributor

@tylersmalley tylersmalley left a 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.

@jsoref
Copy link
Contributor Author

jsoref commented Jul 18, 2018

@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).

@rashmivkulkarni
Copy link
Contributor

There have been lots of changes in master . I would recommend pulling master into your branches and re run the tests.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@snide snide added v7.0.1 and removed v7.0.0 labels Apr 10, 2019
@jsoref jsoref closed this May 6, 2019
@jsoref jsoref deleted the try-restart branch May 6, 2019 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Operations Team label for Operations Team v6.7.0 v7.0.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.