Add broker support for passing app_name

In Ceph >= Luminous, application name needs to be set
on a per-pool level to avoid health warnings. This
change adds support for sending the application name
over the broker channel from consuming charms.

When a name is not sent from the other side of the
relation, the application name will be set to "unknown"
in Luminous and greater

Change-Id: I99ae47b6802f50ea019751ffa328f11567cca567
Closes-Bug: #1753640
This commit is contained in:
Chris MacNaughton 2018-04-26 13:11:43 +02:00
parent efdd37baf7
commit 978e561782
2 changed files with 7 additions and 2 deletions

View File

@ -370,6 +370,8 @@ def handle_erasure_pool(request, service):
if erasure_profile is None:
erasure_profile = "default-canonical"
app_name = request.get('app-name')
# Check for missing params
if pool_name is None:
msg = "Missing parameter. name is required for the pool"
@ -393,7 +395,7 @@ def handle_erasure_pool(request, service):
pool = ErasurePool(service=service, name=pool_name,
erasure_code_profile=erasure_profile,
percent_data=weight)
percent_data=weight, app_name=app_name)
# Ok make the erasure pool
if not pool_exists(service=service, name=pool_name):
log("Creating pool '{}' (erasure_profile={})"
@ -426,6 +428,7 @@ def handle_replicated_pool(request, service):
if osds:
pg_num = min(pg_num, (len(osds) * 100 // replicas))
app_name = request.get('app-name')
# Check for missing params
if pool_name is None or replicas is None:
msg = "Missing parameter. name and replicas are required"
@ -446,6 +449,8 @@ def handle_replicated_pool(request, service):
kwargs['percent_data'] = weight
if replicas:
kwargs['replicas'] = replicas
if app_name:
kwargs['app_name'] = app_name
pool = ReplicatedPool(service=service,
name=pool_name, **kwargs)

View File

@ -134,9 +134,9 @@ class CephTestCase(unittest.TestCase):
"""Ensure that previously processed disks are skipped"""
db = MagicMock()
_kv.return_value = db
db.get.return_value = ['/dev/sdb']
utils.osdize('/dev/sdb', osd_format='xfs', osd_journal=None,
reformat_osd=True, bluestore=False)
db.get.return_value = ['/dev/sdb']
db.get.assert_called_with('osd-devices', [])
db.set.assert_not_called()