Skip to content

Commit

Permalink
Don't overwrite last relation key when username not found
Browse files Browse the repository at this point in the history
When rotating a password, the code updates the password on the relation
bag for the associated relation. However, if the username wasn't found
in the relation data (e.g. if it was in app-data instead) then the code
unfortunately overwrote the last key it looked at (and this was,
randomly, private-address). This was due to a bug in the code. This
patch fixes that problem.

However, the charm (or at least certainly the rotating passwords code)
doesn't support app data bags as it doesn't find the matching username
to update the relation data. This means that it doesn't support rotating
passwords with charms that use app-data. This is the note added to the
README.

Change-Id: I05dac3ae89318ceb28724f4a75d1377a62d32d1c
Closes-Bug: #2051365
  • Loading branch information
ajkavanagh committed Feb 1, 2024
1 parent f9e1f45 commit 26cb835
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ charms can be obtained from the [Charm Store][charms-requires-rabbitmq] (the
charms officially supported by the OpenStack Charms project are published by
'openstack-charmers').

NOTE: the charm doesn't officially support application data bags, and thus may
not work correctly with them. See [this bug][app-data-bag-bug] for more
details.

# Usage

## Configuration
Expand Down Expand Up @@ -107,6 +111,8 @@ Actions allow specific operations to be performed on a per-unit basis.
* `list-unconsumed-queues`
* `pause`
* `resume`
* `list-service-usernames`
* `rotate-service-user-password`

To display action descriptions run `juju actions --schema rabbitmq-server`. If
the charm is not deployed then see file ``actions.yaml``.
Expand Down Expand Up @@ -135,3 +141,4 @@ For general charm questions refer to the [OpenStack Charm Guide][cg].
[uca]: https://wiki.ubuntu.com/OpenStack/CloudArchive
[cdg-ha-rabbitmq]: https://docs.openstack.org/project-deploy-guide/charm-deployment-guide/latest/app-ha.html#rabbitmq
[juju-docs-config-apps]: https://juju.is/docs/configuring-applications
[app-data-bag-bug]: https://bugs.launchpad.net/charm-rabbitmq-server/+bug/2051930
4 changes: 2 additions & 2 deletions hooks/rabbitmq_server_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ def rotate_service_user_password(service_username):
if 'username' in current:
key = 'password'
break
for key in current.keys():
match = pattern.match(key)
for inner_key in current.keys():
match = pattern.match(inner_key)
if match:
key = '_'.join((match[1], 'password'))
break
Expand Down

0 comments on commit 26cb835

Please sign in to comment.