Merge lp:~jacekn/charms/precise/rabbitmq-server/nrpe-fix into lp:charms/rabbitmq-server

Proposed by Jacek Nykis
Status: Merged
Merged at revision: 55
Proposed branch: lp:~jacekn/charms/precise/rabbitmq-server/nrpe-fix
Merge into: lp:charms/rabbitmq-server
Prerequisite: lp:~jacekn/charms/precise/rabbitmq-server/fixes
Diff against target: 12 lines (+1/-1)
1 file modified
hooks/rabbit_utils.py (+1/-1)
To merge this branch: bzr merge lp:~jacekn/charms/precise/rabbitmq-server/nrpe-fix
Reviewer Review Type Date Requested Status
Matt Bruzek (community) Approve
Jacek Nykis (community) Needs Resubmitting
Tim Van Steenburgh (community) Approve
Review via email: mp+218124@code.launchpad.net

Description of the change

Fixed bug where nrpe was configured with wrong password

To post a comment you must log in.
Revision history for this message
Tim Van Steenburgh (tvansteenburgh) wrote :

+1 LGTM, thanks Jacek!

review: Approve
Revision history for this message
Matt Bruzek (mbruzek) wrote :

Hello Jacek,

Thanks for your submission on the rabbitmq-server charm!

I have to reject this Merge Proposal because it does not look like you handle migration of the password file from existing charms to this change.

Consider the case where the existing rabbitmq-server charm already wrote out the password to /var/lib/charm/rabbitmq-server/rabbit-user.passwd if upgrade-charm was run with this new code the password file would not be migrated. The new code looks for the password file in /var/lib/charm/rabbitmq-server/user.passwd and it would not find the file.

The solution is to migrate any old password files in the upgrade-charm hook. This change would need to include something like that to not break the existing charm.

I am going to put this MP to "needs fixing" Once the problem has been addressed, click on the “Request another review” link on this merge proposal. That way it will be added to the review queue properly.

If you have any questions or concerns about the review contact mbruzek in IRC, or the team in #juju on irc.freenode.net or email the mailing list <email address hidden>

review: Needs Fixing
Revision history for this message
Jacek Nykis (jacekn) wrote :

Hi Matt,

Thank you for taking time to review the charm.

This bugfix is meant to fix password mismatch problem. What currently happens is that one part of the code generates and writes a password and 2nd part tries to retrieve it using wrong filename. This fails and new password is generated (and original file is orphaned). See lines 40 and 327-336

You should be able to verify this behaviour by deploying the rabbit charm, nrpe-external-master charm and adding relation and between them. nagios user password on disk will not work.

review: Needs Resubmitting
Revision history for this message
Matt Bruzek (mbruzek) wrote :

Jacek,

Thanks for working with me on this MP. For the record here is what we found.

The rabbitmq-server charm was broken before this fix. The get_rabbit_password_on_disk() method could not find the password file so a new password is generated, which causes a command to fail later in execution.

I verified this was the case by deploying the original rabbitmq-server and nrpe-external-master, related the two. The file /etc/nagios/nrpe.d/check_rabbitmq.cfg ends up with this password. I ssh to the rabbitmq-server/0 machine and ran the command in the file:
/usr/local/lib/nagios/plugins/check_rabbitmq.py --user nagios-rabbitmq-server-0 --password Lbd27tgrg4nHTyp98mmYXmwpLXRwfVk5TPYSLS3VRg45z3pZJfX4zRqttLsXLtK9 --vhost nagios-rabbitmq-server-0
ERROR: Unknown error connecting to RabbitMQ server localhost:5672

I applied this MP and redeployed the environment. This time the file got the proper password and running the command was successful:
/usr/local/lib/nagios/plugins/check_rabbitmq.py --user nagios-rabbitmq-server-0 --password Wr48JgNFcG8VZbhcn9kdTHz23hF8MtKfWVBKHHNYnyySCZMq5R9h5GHkLK5Wqs69 --vhost nagios-rabbitmq-server-0
Ok: sent and received 10 test messages

This file does not exist on the file system for a very long time, it is migrated by a glob immediately after being written so I no longer believe there is an upgrade issue.

Thanks for this fix Jacek!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/rabbit_utils.py'
2--- hooks/rabbit_utils.py 2014-03-18 12:16:06 +0000
3+++ hooks/rabbit_utils.py 2014-05-02 17:00:37 +0000
4@@ -37,7 +37,7 @@
5 RABBIT_USER = 'rabbitmq'
6 LIB_PATH = '/var/lib/rabbitmq/'
7
8-_named_passwd = '/var/lib/charm/{}/rabbit-{}.passwd'
9+_named_passwd = '/var/lib/charm/{}/{}.passwd'
10
11
12 def vhost_exists(vhost):

Subscribers

People subscribed via source and target branches