During openstack-charmers-next, charm errors during the nrpe-external-master-relation-joined hook, failing to connect to local host as nagios.
2021-04-18 03:07:36 ERROR juju-log nrpe-external-master:282: Failed to connect to database due to '(1045, "Access denied for user 'nagios'@'localhost' (using password: YES)")'
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined Traceback (most recent call last):
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/var/lib/juju/agents/unit-mysql-0/charm/charmhelpers/contrib/database/mysql.py", line 358, in set_mysql_password
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined self.connect(user=username, password=current_password)
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/var/lib/juju/agents/unit-mysql-0/charm/charmhelpers/contrib/database/mysql.py", line 111, in connect
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined self.connection = MySQLdb.connect(**_connection_info)
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/usr/lib/python3/dist-packages/MySQLdb/__init__.py", line 86, in Connect
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined return Connection(*args, **kwargs)
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 204, in __init__
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined super(Connection, self).__init__(*args, **kwargs2)
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined _mysql_exceptions.OperationalError: (1045, "Access denied for user 'nagios'@'localhost' (using password: YES)")
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined During handling of the above exception, another exception occurred:
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined Traceback (most recent call last):
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/var/lib/juju/agents/unit-mysql-0/charm/hooks/nrpe-external-master-relation-joined", line 1235, in <module>
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined main()
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/var/lib/juju/agents/unit-mysql-0/charm/hooks/nrpe-external-master-relation-joined", line 1225, in main
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined hooks.execute(sys.argv)
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/var/lib/juju/agents/unit-mysql-0/charm/charmhelpers/core/hookenv.py", line 956, in execute
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined self._hooks[hook_name]()
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/var/lib/juju/agents/unit-mysql-0/charm/hooks/nrpe-external-master-relation-joined", line 1098, in update_nrpe_config
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined set_nagios_user()
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/var/lib/juju/agents/unit-mysql-0/charm/hooks/percona_utils.py", line 1837, in set_nagios_user
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined create_nagios_user()
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/var/lib/juju/agents/unit-mysql-0/charm/hooks/percona_utils.py", line 1831, in create_nagios_user
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined m_helper.set_mysql_password('nagios', nagios_password())
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined File "/var/lib/juju/agents/unit-mysql-0/charm/charmhelpers/contrib/database/mysql.py", line 362, in set_mysql_password
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined 'leader settings (%s)') % ex, ex)
2021-04-18 03:07:36 WARNING nrpe-external-master-relation-joined charmhelpers.contrib.database.mysql.MySQLSetPasswordError: ('Cannot connect using password in leader settings ((1045, "Access denied for user \'nagios\'@\'localhost\' (using password: YES)"))', OperationalError(1045, "Access denied for user 'nagios'@'localhost' (using password: YES)"))
It looks like its only failing on unit 0, which happens to be the leader as well.
The test doesnt have retry-errors running when integrating lma with openstack, we'll update the count to try 5 times.
testrun artifcats at:
https://oil-jenkins.canonical.com/artifacts/f341cd8b-21bd-4cdc-8a06-3ee705f70cc6/index.html
crashdump at:
https://oil-jenkins.canonical.com/artifacts/f341cd8b-21bd-4cdc-8a06-3ee705f70cc6/generated/generated/openstack/juju-crashdump-openstack-2021-04-18-03.07.20.tar.gz
Yes, it's definitely broken. I'm pretty sure that this change breaks it (ironically, I added it): https:/ /github. com/openstack/ charm-percona- cluster/ commit/ d55dcdebc9049c5 09e2f5ab40c8d49 7dc0a3236d
This issue is that the codepath now creates a new password in leader-settings, and then tries to connect to the database using that password that it hasn't yet set for that user.
i.e. the call to nagios_password() here in create_ nagios_ user(): (line 1830 in hooks/percona_ utils.py) :
# NOTE (rgildein): Update the user's password if it has changed. set_mysql_ password( 'nagios' , nagios_password())
m_helper.
where nagios_password() is (line 1057):
nagios_password = partial( _get_password, 'nagios-password')
and _get_password (line 1033):
def _get_password(key):
leader_ set({key: _password})
_password = leader_get(key)
if not _password and is_leader():
_password = config(key) or pwgen()
return _password
means that set_mysql_ password( ) (charmhelpers/ contrib/ database/ mysql.py at 328) has this bit of code:
if not current_password:
current_ password = self.get_ mysql_password( rel_username)
# password that needs to be set
new_passwd = password
# update password for all users (e.g. root@localhost, root@::1, etc)
self. connect( user=username, password= current_ password) .cursor( ) OperationalErro r as ex: dError( ('Cannot connect using password in '
' leader settings (%s)') % ex, ex)
try:
cursor = self.connection
except MySQLdb.
raise MySQLSetPasswor
where get_mysql_ password( ) looks up the password from leader_settings! And thus it fails, as there is no password set against the user.
I'll unpick what is happening, and workout where to set the actual password.