From 407b726fc2ba76a7a149a8722b7cf9b09d8dc0d3 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Thu, 5 Jan 2017 07:32:28 +0100 Subject: [PATCH] upgrade: fix gnocchi resource update This fix the gnocchi upgrade code. Also it makes devstack fail if the upgrade don't work. Change-Id: I658adf71fb997b63daeb2a56d9a6303103ef446d --- ceilometer/gnocchi_client.py | 9 ++++++++- devstack/plugin.sh | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ceilometer/gnocchi_client.py b/ceilometer/gnocchi_client.py index e0a1942739..8f7cff8643 100644 --- a/ceilometer/gnocchi_client.py +++ b/ceilometer/gnocchi_client.py @@ -98,7 +98,8 @@ resources_update_operation = [ "type": "update_attribute_type", "resource_type": "volume", "data": { - "attribute": "/attributes/volume_type", + "op": "add", + "path": "/attributes/volume_type", "value": {"type": "string", "min_length": 0, "max_length": 255, "required": False}}}, ] @@ -119,6 +120,12 @@ def upgrade_resource_types(conf): for op in resources_update_operation: if op['type'] == 'update_attribute_type': + rt = gnocchi.resource_type.get(name=op['resource_type']) + attrib = op['data']['path'].replace('/attributes', '') + if op['data']['op'] == 'add' and attrib in rt['attributes']: + continue + if op['data']['op'] == 'remove' and attrib not in rt['attributes']: + continue try: gnocchi.resource_type.update(op['resource_type'], op['data']) except Exception: diff --git a/devstack/plugin.sh b/devstack/plugin.sh index bd0ceaede4..f8c2ab9cc5 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -363,12 +363,16 @@ function init_ceilometer { if is_service_enabled mysql postgresql ; then if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] || [ "$CEILOMETER_BACKEND" = 'es' ] ; then recreate_database ceilometer + set -e $CEILOMETER_BIN_DIR/ceilometer-upgrade --skip-gnocchi-resource-types + set +e fi fi if is_service_enabled gnocchi ; then if [ "$CEILOMETER_BACKEND" = 'gnocchi' ]; then + set -e $CEILOMETER_BIN_DIR/ceilometer-upgrade --skip-metering-database --skip-event-database + set +e fi fi fi