Skip to content

Commit

Permalink
Add binary_prefix=true argument to mysql uri
Browse files Browse the repository at this point in the history
This patch adds the argument binary_prefix=true to MySQL uri if
OpenStack version is equal or greater than Rocky due to Python
upper-constraints [1]. This argument is required because of PyMySQL's
change from version 0.8 and on [2], in order to fix Gnocchi API
warnings like this [3].

[1] https://github.com/openstack/requirements/blob/stable/rocky/upper-constraints.txt#L377
[2] https://github.com/PyMySQL/PyMySQL/blob/master/CHANGELOG#L61-L64
[3] gnocchixyz/gnocchi#847

Change-Id: Ie8b10209daa4de74427e175ef21ddf306a17a0ae
Signed-off-by: Stamatis Katsaounis <skatsaounis@admin.grnet.gr>
  • Loading branch information
skatsaounis committed Oct 24, 2019
1 parent 3c41001 commit bf7ac78
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/lib/charm/openstack/gnocchi.py
Expand Up @@ -76,6 +76,25 @@ def ceph_config(config):
return CEPH_CONF


class GnocchiCharmDatabaseRelationAdapter(adapters.DatabaseRelationAdapter):
"""
Overrides default class to add binary_prefix option to solve
'Invalid utf8 character' warnings
"""

def get_uri(self, prefix=None):
uri = super(GnocchiCharmDatabaseRelationAdapter, self).get_uri(prefix)
release = ch_utils.get_os_codename_install_source(
self.config['openstack-origin'])
if (ch_utils.OPENSTACK_RELEASES.index(release) >=
ch_utils.OPENSTACK_RELEASES.index('rocky')):
if '?' in uri:
uri += '&binary_prefix=true'
else:
uri += '?binary_prefix=true'
return uri


class GnocchiCharmRelationAdapaters(adapters.OpenStackAPIRelationAdapters):

"""
Expand All @@ -84,7 +103,7 @@ class GnocchiCharmRelationAdapaters(adapters.OpenStackAPIRelationAdapters):

relation_adapters = {
'storage_ceph': charms_openstack.plugins.CephRelationAdapter,
'shared_db': adapters.DatabaseRelationAdapter,
'shared_db': GnocchiCharmDatabaseRelationAdapter,
'cluster': adapters.PeerHARelationAdapter,
'coordinator_memcached': adapters.MemcacheRelationAdapter,
}
Expand Down

0 comments on commit bf7ac78

Please sign in to comment.