From 27f4876eed21d7e1e615646d3c3da1e9025ced4a Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 11 Sep 2019 18:15:02 +0100 Subject: [PATCH] Switch default cloudkitty storage backend to influxdb Backport: stein In the Stein release, cloudkitty switched the default storage backend from sqlalchemy to influxdb. In kolla-ansible stein configuration, we did not explicitly set the storage backend, and so we automatically picked up this change. However, prior to https://review.opendev.org/#/c/615928/ we did not have full support for InfluxDB as a storage backend, and so this has broken the Rocky-Stein upgrade (https://bugs.launchpad.net/kolla-ansible/+bug/1838641), which fails with this during the DB sync: ERROR cloudkitty InfluxDBClientError: get_list_retention_policies() requires a database as a parameter or the client to be using a database This change synchronises our default with cloudkitty's (influxdb), and also provides an upgrade transition to create the influxdb database. We also move the cloudkitty_storage_backend variable to group_vars/all.yml, since it is used to determine whether to enable influxdb. Finally, the section name in cloudkitty.conf was incorrect - it was storage_influx, but should be storage_influxdb. Change-Id: I71f2ed11bd06f58e141d222e2709835b7ddb2c71 Closes-Bug: #1838641 --- ansible/group_vars/all.yml | 8 +++++++- ansible/roles/cloudkitty/defaults/main.yml | 9 ++++----- ansible/roles/cloudkitty/tasks/upgrade.yml | 13 +++++++++++++ .../roles/cloudkitty/templates/cloudkitty.conf.j2 | 2 +- etc/kolla/globals.yml | 13 ++++++++++++- ...loudkitty-default-influxdb-397d7441ad2576c5.yaml | 8 ++++++++ 6 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 releasenotes/notes/cloudkitty-default-influxdb-397d7441ad2576c5.yaml diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 06add8995d..802079a649 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -597,7 +597,7 @@ enable_horizon_vitrage: "{{ enable_vitrage | bool }}" enable_horizon_watcher: "{{ enable_watcher | bool }}" enable_horizon_zun: "{{ enable_zun | bool }}" enable_hyperv: "no" -enable_influxdb: "{{ enable_monasca | bool or (cloudkitty_storage_backend is defined and cloudkitty_storage_backend == 'influxdb') }}" +enable_influxdb: "{{ enable_monasca | bool or (enable_cloudkitty | bool and cloudkitty_storage_backend == 'influxdb') }}" enable_ironic: "no" enable_ironic_ipxe: "no" enable_ironic_neutron_agent: "{{ enable_neutron | bool and enable_ironic | bool }}" @@ -861,6 +861,12 @@ cinder_backup_mount_options_nfs: "" ####################### # Valid option is gnocchi cloudkitty_collector_backend: "gnocchi" +# Valid options are 'sqlalchemy' or 'influxdb'. The default value is +# 'influxdb', which matches the default in Cloudkitty since the Stein release. +# When the backend is "influxdb", we also enable Influxdb. +# Also, when using 'influxdb' as the backend, we trigger the configuration/use +# of Cloudkitty storage backend version 2. +cloudkitty_storage_backend: "influxdb" ####################### # Designate options diff --git a/ansible/roles/cloudkitty/defaults/main.yml b/ansible/roles/cloudkitty/defaults/main.yml index 440a40a48c..0dc9830fd3 100644 --- a/ansible/roles/cloudkitty/defaults/main.yml +++ b/ansible/roles/cloudkitty/defaults/main.yml @@ -100,13 +100,12 @@ cloudkitty_custom_metrics_yaml_file: "metrics.yml" #################### # Storage backend #################### -# Valid options are 'sqlalchemy' or 'influxdb'. The default value in -# Kolla-ansible is 'sqlalchemy' (for backwards compatibility). -# When cloudkitty_storage_backend is define with "influxdb" as its value, -# we also trigger the deployment of Influxdb via Kolla-ansible. +# Valid options are 'sqlalchemy' or 'influxdb'. The default value is +# 'influxdb', which matches the default in Cloudkitty since the Stein release. +# When the backend is "influxdb", we also enable Influxdb. # Also, when using 'influxdb' as the backend, we trigger the configuration/use # of Cloudkitty storage backend version 2. -cloudkitty_storage_backend: "sqlalchemy" +cloudkitty_storage_backend: "influxdb" # InfluxDB retention policy to use (defaults to autogen). # cloudkitty_influxdb_retention_policy: "autogen" diff --git a/ansible/roles/cloudkitty/tasks/upgrade.yml b/ansible/roles/cloudkitty/tasks/upgrade.yml index 20ccddc8f1..9f3ca46e57 100644 --- a/ansible/roles/cloudkitty/tasks/upgrade.yml +++ b/ansible/roles/cloudkitty/tasks/upgrade.yml @@ -1,6 +1,19 @@ --- - include_tasks: config.yml +# NOTE(mgoddard): Transition support for upgrades from Rocky or Stein which may +# be using the SQLAlchemy storage backend. +# TODO(mgoddard): Remove in U cycle. +- name: Creating Cloudkitty influxdb database + become: true + kolla_toolbox: + module_name: influxdb_database + module_args: + hostname: "{{ influxdb_address }}" + port: "{{ influxdb_http_port }}" + database_name: "{{ cloudkitty_influxdb_name }}" + when: cloudkitty_storage_backend == 'influxdb' + - include_tasks: bootstrap_service.yml - name: Flush handlers diff --git a/ansible/roles/cloudkitty/templates/cloudkitty.conf.j2 b/ansible/roles/cloudkitty/templates/cloudkitty.conf.j2 index b397a4a33e..c3dcf0aa6a 100644 --- a/ansible/roles/cloudkitty/templates/cloudkitty.conf.j2 +++ b/ansible/roles/cloudkitty/templates/cloudkitty.conf.j2 @@ -72,7 +72,7 @@ version = 1 {% endif %} {% if cloudkitty_storage_backend == 'influxdb' %} -[storage_influx] +[storage_influxdb] database = {{ cloudkitty_influxdb_name }} host = {{ influxdb_address }} port = {{ influxdb_http_port }} diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index 07c68061b6..1e36710178 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -268,7 +268,7 @@ #enable_horizon_watcher: "{{ enable_watcher | bool }}" #enable_horizon_zun: "{{ enable_zun | bool }}" #enable_hyperv: "no" -#enable_influxdb: "{{ enable_monasca | bool or (cloudkitty_storage_backend is defined and cloudkitty_storage_backend == 'influxdb') }}" +#enable_influxdb: "{{ enable_monasca | bool or (enable_cloudkitty | bool and cloudkitty_storage_backend == 'influxdb') }}" #enable_ironic: "no" #enable_ironic_ipxe: "no" #enable_ironic_neutron_agent: "{{ enable_neutron | bool and enable_ironic | bool }}" @@ -446,6 +446,17 @@ #cinder_backup_share: "" #cinder_backup_mount_options_nfs: "" +####################### +# Cloudkitty options +####################### +# Valid option is gnocchi +#cloudkitty_collector_backend: "gnocchi" +# Valid options are 'sqlalchemy' or 'influxdb'. The default value is +# 'influxdb', which matches the default in Cloudkitty since the Stein release. +# When the backend is "influxdb", we also enable Influxdb. +# Also, when using 'influxdb' as the backend, we trigger the configuration/use +# of Cloudkitty storage backend version 2. +#cloudkitty_storage_backend: "influxdb" ################### # Designate options diff --git a/releasenotes/notes/cloudkitty-default-influxdb-397d7441ad2576c5.yaml b/releasenotes/notes/cloudkitty-default-influxdb-397d7441ad2576c5.yaml new file mode 100644 index 0000000000..992aa6d127 --- /dev/null +++ b/releasenotes/notes/cloudkitty-default-influxdb-397d7441ad2576c5.yaml @@ -0,0 +1,8 @@ +--- +upgrade: + - | + Modifies the default storage backend for Cloudkitty to InfluxDB, to match + the default in Cloudkitty from Stein onwards. This is controlled via + ``cloudkitty_storage_backend``. To use the previous default, set + ``cloudkitty_storage_backend`` to ``sqlalchemy``. See `bug 1838641 + `__ for details.