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
This commit is contained in:
Mehdi Abaakouk 2017-01-05 07:32:28 +01:00
parent 75539b2725
commit 407b726fc2
2 changed files with 12 additions and 1 deletions

View File

@ -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:

View File

@ -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