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

[build] Commit install/remove scripts #6674

Closed
wants to merge 9 commits into from

Conversation

jbudz
Copy link
Member

@jbudz jbudz commented Mar 28, 2016

After install - create a kibana user if one doesn't exist, chown /optimize
Upgrade - stop kibana, upgrade files
Remove (red hat), purge (debian) - delete the kibana user, remove files

Fixes #6262
Fixes #6729

@LeeDr
Copy link

LeeDr commented Apr 8, 2016

LGTM - I did not test rpm package but Jon says its the same scripts.

Testing installing 5.0-snapshot on a previously uninstalled (but not purged) 4.5 install I get a screen asking what to do with the previous kibana.yml. I think this is good.

root@U14K:~# dpkg -i kibana_5.0.0-snapshot_amd64.deb
Selecting previously unselected package kibana.
(Reading database ... 324885 files and directories currently installed.)
Preparing to unpack kibana_5.0.0-snapshot_amd64.deb ...
Unpacking kibana (5.0.0-snapshot) ...
Setting up kibana (5.0.0-snapshot) ...

Configuration file '/opt/kibana/config/kibana.yml'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** kibana.yml (Y/I/N/O/D/Z) [default=N] ? 

I entered Y and took the new kibana.yml. Then I edited it with a comment to mark it.
Next I installed this 5.1.0-snapshot build. I did not get a prompt about my kibana.yml file?!?
It did stop the kibana server (good).

root@U14K:~# dpkg -i kibana_5.1.0-snapshot_amd64.deb
(Reading database ... 341706 files and directories currently installed.)
Preparing to unpack kibana_5.1.0-snapshot_amd64.deb ...
Stopping kibana service... OK
Unpacking kibana (5.1.0-snapshot) over (5.0.0-snapshot) ...
Setting up kibana (5.1.0-snapshot) ...
Processing triggers for systemd (225-1ubuntu9.1) ...
Processing triggers for ureadahead (0.100.0-19) ...

I checked the user id before and after the upgrade and it did not change (good);

root@U14K:~# grep kibana /etc/passwd
kibana:x:998:998::/home/kibana:

Next test, I changed the kibana.yml before making a 5.2. When I installed it I was prompted with the choices again. So it is smart enough to know if nothing has changed in the packages yml file to leave the existing one.

If there are existing installedPlugins, Upgrade and Purge Leave them there.

  • For purge, they should probably be removed.
  • For upgrade, not sure what should really happen. I think we're expecting the user has to install the latest versions. And the old ones have to be removed first, so maybe we should clean them up?

I'll write an issue about these if there isn't one already.

root@U14K:~# dpkg --purge kibana
(Reading database ... 341705 files and directories currently installed.)
Removing kibana (5.2.0-snapshot) ...
Stopping kibana service... OK
Purging configuration files for kibana (5.2.0-snapshot) ...
dpkg: warning: while removing kibana, directory '/opt/kibana/installedPlugins' not empty so not removed
dpkg: warning: while removing kibana, directory '/opt/kibana/config' not empty so not removed
dpkg: warning: while removing kibana, directory '/opt/kibana/optimize/bundles' not empty so not removed

@LeeDr LeeDr assigned jbudz and unassigned LeeDr Apr 11, 2016
@gmoskovicz
Copy link
Contributor

@LeeDr @jbudz

Looks like when using the Kibana 4.5 .rpm downloaded via yum on RHEL 6.6 the install (using rpm -U ) removes the kibana user. So one needs to re-create/add the user.

Will this fix this issue as well?

@jbudz
Copy link
Member Author

jbudz commented Apr 13, 2016

@gmoskovicz yes, with these changes it should only be deleting the kibana user on remove on RHEL

@gmoskovicz
Copy link
Contributor

Thanks for confirming @jbudz .

@jbudz jbudz assigned ycombinator and unassigned jbudz Apr 29, 2016
if ! user_check "kibana" ; then
user_create "kibana"
fi
chown kibana /opt/kibana/optimize
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be recursive or is deliberately not recursive?

Copy link
Member Author

Choose a reason for hiding this comment

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

The only file in the optimize folder on install is .empty so it shouldn't be needed.

@jbudz
Copy link
Member Author

jbudz commented May 2, 2016

jenkins, test it

if ! user_check "<%= user %>" ; then
user_create "<%= user %>"
fi
chown <%= user %>:<%= group %> /opt/kibana/optimize
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this doesn't need to be recursive? After installing the kibana-5.0.0_snapshot-1.i686.rpm package, I found a bunch of folders and files under /opt/kibana/optimize that are owned by root:

$ tree -ug /opt/kibana/optimize | head -20
/opt/kibana/optimize
└── [root     root    ]  bundles
    ├── [root     root    ]  a573941f02f4331f81046356ebb667eb.swf
    ├── [root     root    ]  commons.bundle.js
    ├── [root     root    ]  commons.style.css
    ├── [root     root    ]  console.bundle.js
    ├── [root     root    ]  console.entry.js
    ├── [root     root    ]  console.style.css
    ├── [root     root    ]  fbe046f38bf68f1469110319dee9bbfd.js
    ├── [root     root    ]  kibana.bundle.js
    ├── [root     root    ]  kibana.entry.js
    ├── [root     root    ]  kibana.style.css
    ├── [root     root    ]  node_modules
    │   ├── [root     root    ]  bootstrap
    │   │   └── [root     root    ]  fonts
    │   │       ├── [root     root    ]  glyphicons-halflings-regular.eot
    │   │       ├── [root     root    ]  glyphicons-halflings-regular.svg
    │   │       ├── [root     root    ]  glyphicons-halflings-regular.ttf
    │   │       ├── [root     root    ]  glyphicons-halflings-regular.woff
    │   │       └── [root     root    ]  glyphicons-halflings-regular.woff2

@ycombinator
Copy link
Contributor

ycombinator commented May 3, 2016

I am unable to upgrade from Kibana 4.5.0 to Kibana 5.0.0_snapshot on CentOS 6:

[shaunak@localhost ~]$ cat /etc/*-release
CentOS release 6.7 (Final)
CentOS release 6.7 (Final)
CentOS release 6.7 (Final)
[shaunak@localhost ~]$ sudo rpm -Uvh kibana-4.5.0-1.i386.rpm
Preparing...                ########################################### [100%]
   1:kibana                 ########################################### [100%]
[shaunak@localhost ~]$ sudo /etc/init.d/kibana start
kibana started
[shaunak@localhost ~]$ sudo lsof -i:5601
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node    13066 kibana   10u  IPv4 362677      0t0  TCP *:esmagent (LISTEN)
[shaunak@localhost ~]$ sudo rpm -Uvh kibana-5.0.0_snapshot-1.i686.rpm
Preparing...                ########################################### [100%]
   1:kibana                 ########################################### [100%]
userdel: user kibana is currently used by process 13066
warning: %postun(kibana-4.5.0-1.i386) scriptlet failed, exit status 8
[shaunak@localhost ~]$ rpm -qa | grep kibana
kibana-5.0.0_snapshot-1.i686
[shaunak@localhost ~]$ curl -s 'http://localhost:5601/status' | grep version
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="viewport" content="width=device-width"><title>Kibana</title></head><body kbn-chrome id="kibana-body"><script>window.__KBN__ = {"app":{"id":"statusPage","title":"Server Status","main":"plugins/statusPage/statusPage","url":"/status"},"nav":[{"id":"kibana","title":"Kibana","description":"the kibana you know and love","main":"plugins/kibana/kibana","url":"/app/kibana"}],"version":"4.5.0","buildNum":9889,"buildSha":"ff5cfc5d05a58e53f7acaa762428fa803318d31e","basePath":""};</script><style>.ui-app-loading {

Note the last two steps in particular. Kibana 5.0.0 does get installed but the old Kibana is still running.

I realize this is exactly the issue this PR will fix for versions of Kibana 5.0.0 onwards. I'm just wondering if there should be a preinstall script as well that takes another shot at stopping the Kibana service. What do you think?

@ycombinator ycombinator assigned jbudz and unassigned ycombinator May 3, 2016
@jbudz
Copy link
Member Author

jbudz commented May 3, 2016

@epixa any thoughts on @ycombinator's comment above? It would look the same as https://github.com/jbudz/kibana/blob/50ab1b97a3a2af76ce518f345ffef38ef0c0d97d/tasks/build/package_scripts/pre_remove.sh. For 5.x upgrades it would try stopping kibana twice, and add some code debt, but would workaround the upgrade issue for 4.x->5 users.

@epixa
Copy link
Contributor

epixa commented May 3, 2016

What impact does it have on upgrades post 5.0? Also, what's the alternative? People would need to stop Kibana before attempting to upgrade?

@jbudz
Copy link
Member Author

jbudz commented May 4, 2016

No visible impact on upgrades post 5.0 - it will try and stop the service twice. And yes, the alternative is to stop the Kibana service or do a fresh install

@epixa
Copy link
Contributor

epixa commented May 4, 2016

What do you mean by "try to stop the service twice"? If it succeeds on the first try, does the second try error, or is it more like a noop?

@ycombinator
Copy link
Contributor

Butting in here: Ideally we wouldn't try to stop the service the second time if it is already stopped.

@jbudz
Copy link
Member Author

jbudz commented May 4, 2016

it would be more like a noop, no errors. @ycombinator - makes sense

@jbudz jbudz force-pushed the build-scripts branch 2 times, most recently from 50155ad to 0187dc5 Compare May 9, 2016 21:05
@jbudz jbudz assigned ycombinator and unassigned jbudz May 9, 2016
@ycombinator
Copy link
Contributor

ycombinator commented May 26, 2016

Getting back to testing this PR today:

  • 5.0.0 rpm
    • Clean install (no Kibana previously installed)
      • Ensure that install succeeds
      • Ensure that start/stop suceed
      • Ensure that uninstall succeeds
    • Upgrade from previously-installed Kibana
      • While previously-installed Kibana is running
        • Ensure that install (upgrade) succeeds
        • Ensure that start/stop suceed
        • Ensure that uninstall succeeds
      • While previously-installed Kibana is NOT running
        • Ensure that install (upgrade) succeeds
        • Ensure that start/stop suceed
        • Ensure that uninstall succeeds
  • 5.0.0 deb
    • Clean install (no Kibana previously installed)
      • Ensure that install succeeds
      • Ensure that start/stop suceed
      • Ensure that uninstall succeeds
    • Upgrade from previously-installed Kibana
      • While previously-installed Kibana is running
        • Ensure that install (upgrade) succeeds
        • Ensure that start/stop suceed
        • Ensure that uninstall succeeds
      • While previously-installed Kibana is NOT running
        • Ensure that install (upgrade) succeeds
        • Ensure that start/stop suceed
        • Ensure that uninstall succeeds

@ycombinator
Copy link
Contributor

@jbudz I'm still seeing the same error I reported in an earlier comment when upgrading from Kibana 4.5.* to 5.0.0:

  1. Install and start Kibana 4.5.1 + verify that its running:

    [shaunak@localhost ~]$ sudo rpm -Uvh kibana-4.5.1-1.i386.rpm
    Preparing...                ########################################### [100%]
    1:kibana                 ########################################### [100%]
    [shaunak@localhost ~]$ rpm -qa | grep kibana
    kibana-4.5.1-1.i386
    [shaunak@localhost ~]$ sudo service kibana status
    kibana is not running
    [shaunak@localhost ~]$ sudo service kibana start
    kibana started
    [shaunak@localhost ~]$ netstat -an | grep LISTEN | grep 5601
    tcp        0      0 0.0.0.0:5601                0.0.0.0:*                   LISTEN
    [shaunak@localhost ~]$ sudo lsof -i:5601
    COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    node    14306 kibana   10u  IPv4 164160      0t0  TCP *:esmagent (LISTEN)
    [shaunak@localhost ~]$ ps auxfw | grep kibana
    shaunak  14323  0.0  0.1   4420   756 pts/0    S+   08:39   0:00              \_ grep kibana
    kibana   14306 10.7 12.7 168680 64868 pts/0    Sl   08:39   0:01 /opt/kibana/bin/../node/bin/node /opt/kibana/bin/../src/cli
    
  2. Try to upgrade the Kibana 5.0.0:

    [shaunak@localhost ~]$ sudo rpm -Uvh kibana-5.0.0_snapshot-1.i386.rpm
    Preparing...                ########################################### [100%]
    1:kibana                 ########################################### [100%]
    userdel: user kibana is currently used by process 14306
    warning: %postun(kibana-4.5.1-1.i386) scriptlet failed, exit status 8
    [shaunak@localhost ~]$ rpm -qa | grep kibana
    kibana-5.0.0_snapshot-1.i386
    [shaunak@localhost ~]$ sudo service kibana status
    kibana is running
    [shaunak@localhost ~]$ netstat -an | grep LISTEN | grep 5601
    tcp        0      0 0.0.0.0:5601                0.0.0.0:*                   LISTEN
    [shaunak@localhost ~]$ sudo lsof -i:5601
    COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    node    14306 kibana   10u  IPv4 164160      0t0  TCP *:esmagent (LISTEN)
    

@jbudz
Copy link
Member Author

jbudz commented May 26, 2016

@ycombinator do you have any more info, can we double check the built rpm has updated scripts? I wasn't able to reproduce with both sysv and systemd.

[budz@localhost ~]$ sudo rpm -Uvh kibana-4.5.1_rc1-1.i386.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:kibana-4.5.1_rc1-1               ################################# [100%]
[budz@localhost ~]$ sudo /etc/init.d/kibana start
kibana started
[budz@localhost ~]$ rpm -qa | grep kibana
kibana-4.5.1_rc1-1.i386
s[budz@localhost ~]$ sudo service kibana status
kibana is running
[budz@localhost ~]$ netstat -an | grep LISTEN | grep 5601
tcp        0      0 0.0.0.0:5601            0.0.0.0:*               LISTEN     
[budz@localhost ~]$ sudo rpm -Uvh kibana-5.0.0_snapshot-1.i386.rpm 
Preparing...                          ################################# [100%]
kibana stopped.
Updating / installing...
   1:kibana-5.0.0_snapshot-1          ################################# [ 50%]
Cleaning up / removing...
   2:kibana-4.5.1_rc1-1               ################################# [100%]


[budz@localhost ~]$ sudo rpm -Uvh kibana-4.5.1_rc1-1.i386.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:kibana-4.5.1_rc1-1               ################################# [100%]
[budz@localhost ~]$ sudo systemctl start kibana.service
Warning: kibana.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[budz@localhost ~]$ sudo systemctl daemon-reload
[budz@localhost ~]$ netstat -an | grep LISTEN | grep 5601
tcp        0      0 0.0.0.0:5601            0.0.0.0:*               LISTEN     
[budz@localhost ~]$ sudo rpm -Uvh kibana-5.0.0_snapshot-1.i386.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:kibana-5.0.0_snapshot-1          ################################# [ 50%]
Cleaning up / removing...
   2:kibana-4.5.1_rc1-1               ################################# [100%]

@ycombinator
Copy link
Contributor

@jbudz That's so bizzare. I'm on CentOS 6.8. What OS are you on?

@jbudz
Copy link
Member Author

jbudz commented May 27, 2016

earlier was fedora, same story on centos(7) though
image

@jbudz
Copy link
Member Author

jbudz commented Jun 8, 2016

Merged as part of #7308

@jbudz jbudz closed this Jun 8, 2016
jbudz added a commit to jbudz/kibana that referenced this pull request Jun 9, 2016
jbudz added a commit to jbudz/kibana that referenced this pull request Jun 9, 2016
jbudz added a commit that referenced this pull request Jun 9, 2016
jbudz added a commit that referenced this pull request Jun 9, 2016
@epixa epixa added v4.5.4 and removed v4.5.2 labels Jul 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants