From 2db9036c024f0184298808e8060c178774ec3af5 Mon Sep 17 00:00:00 2001 From: Iury Gregory Melo Ferreira Date: Tue, 1 Oct 2019 09:53:31 +0200 Subject: [PATCH] DevStack support and Redfish job - plugin for devstack - runs the exporter as a service with gunicorn - collect data from virtual baremetal (redfish) Change-Id: I5e6221a49c60a18309ca9b5d644d97acb56f7fef (cherry picked from commit 1765f44faaca43eb9274544c2e6aa33e44635920) --- .zuul.yaml | 89 ++++++++++++++++++++++++++++++++++ bindep.txt | 4 ++ devstack/plugin.sh | 116 +++++++++++++++++++++++++++++++++++++++++++++ devstack/settings | 3 ++ 4 files changed, 212 insertions(+) create mode 100644 bindep.txt create mode 100644 devstack/plugin.sh create mode 100644 devstack/settings diff --git a/.zuul.yaml b/.zuul.yaml index 29d6919..582d873 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,6 +1,95 @@ +- job: + name: ironic-prometheus-exporter-redfish + description: Job that installs the exporter with redfish driver. + parent: devstack + nodeset: openstack-single-node-bionic + timeout: 5400 + required-projects: + - openstack/ironic + - openstack/ironic-python-agent + - openstack/ironic-python-agent-builder + - openstack/ironic-tempest-plugin + - openstack/virtualbmc + irrelevant-files: + - ^.*\.rst$ + - ^api-ref/.*$ + - ^doc/.*$ + - ^driver-requirements.txt$ + - ^install-guide/.*$ + - ^ironic/locale/.*$ + - ^ironic/tests/.*$ + - ^releasenotes/.*$ + - ^setup.cfg$ + - ^tools/.*$ + - ^tox.ini$ + - ^ironic_prometheus_exporter/tests/*$ + vars: + devstack_localrc: + DEFAULT_INSTANCE_TYPE: baremetal + FORCE_CONFIG_DRIVE: True + INSTALL_TEMPEST: False # Don't install a tempest package globaly + TEMPEST_PLUGINS: "{{ ansible_user_dir }}/src/opendev.org/openstack/ironic-tempest-plugin" + VIRT_DRIVER: ironic + BUILD_TIMEOUT: 720 + IRONIC_BAREMETAL_BASIC_OPS: True + IRONIC_BUILD_DEPLOY_RAMDISK: False + IRONIC_CALLBACK_TIMEOUT: 600 + IRONIC_DEPLOY_DRIVER: redfish + IRONIC_ENABLED_HARDWARE_TYPES: redfish + IRONIC_DEFAULT_RESCUE_INTERFACE: "" + EBTABLES_RACE_FIX: True + IRONIC_INSPECTOR_BUILD_RAMDISK: False + IRONIC_RAMDISK_TYPE: tinyipa + IRONIC_VM_COUNT: 1 + IRONIC_VM_EPHEMERAL_DISK: 1 + IRONIC_VM_LOG_DIR: '{{ devstack_base_dir }}/ironic-bm-logs' + IRONIC_VM_SPECS_RAM: 384 + IRONIC_VM_SPECS_DISK: 4 + IRONIC_DEFAULT_DEPLOY_INTERFACE: iscsi + Q_AGENT: openvswitch + Q_ML2_TENANT_NETWORK_TYPE: vxlan + SERVICE_TIMEOUT: 90 + USE_PYTHON3: True + IRONIC_PROMETHEUS_EXPORTER_LOCATION: '{{ devstack_base_dir }}/ironic-bm-logs/ipe' + devstack_plugins: + ironic: https://opendev.org/openstack/ironic + ironic-prometheus-exporter: https://opendev.org/openstack/ironic-prometheus-exporter + zuul_copy_output: + '{{ devstack_base_dir }}/ironic-bm-logs': 'logs' + '{{ devstack_base_dir }}/ironic-bm-logs/ipe': 'logs' + devstack_services: + q-agt: false + q-dhcp: false + q-l3: false + q-meta: false + q-metering: false + q-svc: false + neutron-api: true + neutron-agent: true + neutron-dhcp: true + neutron-l3: true + neutron-metadata-agent: true + neutron-metering: true + c-api: False + c-bak: False + c-sch: False + c-vol: False + cinder: False + s-account: False + s-container: False + s-object: False + s-proxy: False + - project: templates: - check-requirements - openstack-python-jobs - openstack-python3-train-jobs - release-notes-jobs-python3 + check: + jobs: + - ironic-prometheus-exporter-redfish + gate: + queue: ironic + jobs: + - ironic-prometheus-exporter-redfish diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 0000000..d8b89cd --- /dev/null +++ b/bindep.txt @@ -0,0 +1,4 @@ +libvirt-dev [platform:dpkg] +libvirt-devel [platform:rpm] +pkg-config [platform:dpkg] +pkgconfig [platform:redhat] diff --git a/devstack/plugin.sh b/devstack/plugin.sh new file mode 100644 index 0000000..394eba0 --- /dev/null +++ b/devstack/plugin.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash +# plugin.sh - DevStack plugin.sh dispatch script template + +IRONIC_PROMETHEUS_EXPORTER_DIR=${IRONIC_PROMETHEUS_EXPORTER_DIR:-$DEST/ironic-prometheus-exporter} +IRONIC_PROMETHEUS_EXPORTER_PORT=${IRONIC_PROMETHEUS_EXPORTER_PORT:-9608} +IRONIC_PROMETHEUS_EXPORTER_DATA_DIR=""$DATA_DIR/ironic-prometheus-exporter"" +IRONIC_PROMETHEUS_EXPORTER_SYSTEMD_SERVICE="devstack@ironic-prometheus-exporter.service" +# Location where the metrics from the baremetal nodes will be stored +IRONIC_PROMETHEUS_EXPORTER_LOCATION=${IRONIC_PROMETHEUS_EXPORTER_LOCATION:-$IRONIC_VM_LOG_DIR} +COLLECT_DATA_UNDEPLOYED_NODES=$(trueorfalse True COLLECT_DATA_UNDEPLOYED_NODES) +IRONIC_CONFIG=${IRONIC_CONFIG:-$IRONIC_CONF_FILE} +IPE_ACCESS_LF="$IRONIC_VM_LOG_DIR/ipe_access.log" +IPE_ERROR_LF="$IRONIC_VM_LOG_DIR/ipe_errors.log" + +function install_ironic_prometheus_exporter { + git_clone_by_name "ironic-prometheus-exporter" + setup_dev_lib "ironic-prometheus-exporter" +} + +function configure_ironic_prometheus_exporter { + # Update ironic configuration file to use the exporter + iniset $IRONIC_CONF_FILE conductor send_sensor_data true + iniset $IRONIC_CONF_FILE conductor send_sensor_data_for_undeployed_nodes $COLLECT_DATA_UNDEPLOYED_NODES + iniset $IRONIC_CONF_FILE conductor send_sensor_data_interval 90 + iniset $IRONIC_CONF_FILE oslo_messaging_notifications driver prometheus_exporter + iniset $IRONIC_CONF_FILE oslo_messaging_notifications transport_url fake:// + iniset $IRONIC_CONF_FILE oslo_messaging_notifications location $IRONIC_PROMETHEUS_EXPORTER_LOCATION + + local gunicorn_ipe_cmd + + gunicorn_ipe_cmd=$(which gunicorn3) + gunicorn_ipe_cmd+=" -b ${HOST_IP}:${IRONIC_PROMETHEUS_EXPORTER_PORT}" + gunicorn_ipe_cmd+=" --env IRONIC_CONFIG=$IRONIC_CONFIG" + gunicorn_ipe_cmd+=" --env FLASK_DEBUG=1 -w 4" + gunicorn_ipe_cmd+=" --access-logfile=$IPE_ACCESS_LF --error-logfile=$IPE_ERROR_LF" + gunicorn_ipe_cmd+=" -D ironic_prometheus_exporter.app.wsgi:application" + + write_user_unit_file $IRONIC_PROMETHEUS_EXPORTER_SYSTEMD_SERVICE "$gunicorn_ipe_cmd" "" "$STACK_USER" + + enable_service $IRONIC_PROMETHEUS_EXPORTER_SYSTEMD_SERVICE +} + +function start_ironic_prometheus_exporter { + start_service $IRONIC_PROMETHEUS_EXPORTER_SYSTEMD_SERVICE +} + +function stop_ironic_prometheus_exporter { + stop_service $IRONIC_PROMETHEUS_EXPORTER_SYSTEMD_SERVICE +} + +function cleanup_ironic_prometheus_exporter { + stop_ironic_prometheus_exporter + + disable_service $IRONIC_PROMETHEUS_EXPORTER_SYSTEMD_SERVICE + + sudo rm -rf $IRONIC_PROMETHEUS_EXPORTER_DATA_DIR + + local unitfile="$SYSTEMD_DIR/$IRONIC_PROMETHEUS_EXPORTER_SYSTEMD_SERVICE" + sudo rm -f $unitfile + + $SYSTEMCTL daemon-reload +} + +function wait_for_data { + # Sleep for more than the [conductor]send_sensor_data_interval value + # to verify if we can get data from the baremetal + # FIXME(iurygregory): Add some logic to verify if the data already exists + sleep 240 +} + +function check_data { + local node_file="node-0-hardware.redfish.metrics" + if [ -f "$IRONIC_PROMETHEUS_EXPORTER_LOCATION/$node_file" ]; then + echo "Found $node_file in $IRONIC_PROMETHEUS_EXPORTER_LOCATION" + if curl -s --head --request GET "http://$HOST_IP:$IRONIC_PROMETHEUS_EXPORTER_PORT/metrics" | grep "200 OK" > /dev/null; then + echo "Data successfully retrived from ironic-prometheus-exporter application" + else + die $LINENO "Couldn't get data from ironic-prometheus-exporter application" + fi + else + die $LINENO "Couldn't find $node_file in $IRONIC_PROMETHEUS_EXPORTER_LOCATION" + fi +} + +echo_summary "ironic-prometheus-exporter devstack plugin.sh called: $1/$2" + +if is_service_enabled ironic-prometheus-exporter; then + + if [[ "$1" == "stack" ]]; then + case "$2" in + install) + echo_summary "Installing Ironic Prometheus Exporter" + install_ironic_prometheus_exporter + ;; + post-config) + echo_summary "Configuring Ironic Prometheus Exporter Application" + configure_ironic_prometheus_exporter + ;; + extra) + echo_summary "Starting Ironic Prometheus Exporter Application" + start_ironic_prometheus_exporter + echo_summary "Give time to baremetal to provide data" + wait_for_data + check_data + ;; + esac + fi + + if [[ "$1" == "unstack" ]]; then + echo_summary "Stopping Ironic Prometheus Exporter Application" + stop_ironic_prometheus_exporter + echo_summary "Cleaning Ironic Prometheus Exporter" + cleanup_ironic_prometheus_exporter + fi + +fi diff --git a/devstack/settings b/devstack/settings new file mode 100644 index 0000000..96fc989 --- /dev/null +++ b/devstack/settings @@ -0,0 +1,3 @@ +define_plugin ironic-prometheus-exporter +plugin_requires ironic-prometheus-exporter ironic +enable_service ironic-prometheus-exporter