- openstack-cinder-volume/openstack-floating-ip/openstack-info/

openstack-virtual-ip: fixes and improved debugging

  Resolves: rhbz#2083081, rhbz#2083086, rhbz#2083090, rhbz#2083092
This commit is contained in:
Oyvind Albrigtsen 2022-07-12 09:52:05 +02:00
parent d9da3695e5
commit 6479f341ec
4 changed files with 393 additions and 7 deletions

View File

@ -0,0 +1,282 @@
From ebea4c3620261c529cad908c0e52064df84b0c61 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Mon, 11 Jul 2022 10:28:11 +0200
Subject: [PATCH] openstack-agents: warn when openstackcli is slow
---
heartbeat/openstack-cinder-volume | 19 +++++++++++--------
heartbeat/openstack-common.sh | 22 ++++++++++++++++++++++
heartbeat/openstack-floating-ip | 17 ++++++++++-------
heartbeat/openstack-info.in | 20 ++++++++++----------
heartbeat/openstack-virtual-ip | 20 ++++++++++----------
5 files changed, 63 insertions(+), 35 deletions(-)
diff --git a/heartbeat/openstack-cinder-volume b/heartbeat/openstack-cinder-volume
index 19bf04faf..116442c41 100755
--- a/heartbeat/openstack-cinder-volume
+++ b/heartbeat/openstack-cinder-volume
@@ -113,11 +113,14 @@ _get_node_id() {
}
osvol_validate() {
+ local result
+
check_binary "$OCF_RESKEY_openstackcli"
get_config
- if ! $OCF_RESKEY_openstackcli volume list|grep -q $OCF_RESKEY_volume_id ; then
+ result=$(run_openstackcli "volume list")
+ if ! echo "$result" | grep -q $OCF_RESKEY_volume_id; then
ocf_exit_reason "volume-id $OCF_RESKEY_volume_id not found"
return $OCF_ERR_CONFIGURED
fi
@@ -156,17 +159,17 @@ osvol_monitor() {
# Is the volue attached?
# We use the API
#
- result=$($OCF_RESKEY_openstackcli volume show \
+ result=$(run_openstackcli "volume show \
--column status \
--column attachments \
--format value \
- $OCF_RESKEY_volume_id)
+ $OCF_RESKEY_volume_id")
- if echo "$result" | grep -q available ; then
+ if echo "$result" | grep -q available; then
ocf_log warn "$OCF_RESKEY_volume_id is not attached to any instance"
return $OCF_NOT_RUNNING
else
- export attached_server_id=$(echo $result|head -n1|
+ export attached_server_id=$(echo "$result"|head -n1|
grep -P -o "'server_id': '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}'"|
grep -P -o "[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}")
ocf_log info "$OCF_RESKEY_volume_id is attached to instance $attached_server_id"
@@ -199,7 +202,7 @@ osvol_stop() {
#
# Detach the volume
#
- if ! $OCF_RESKEY_openstackcli server remove volume $node_id $OCF_RESKEY_volume_id ; then
+ if ! run_openstackcli "server remove volume $node_id $OCF_RESKEY_volume_id"; then
ocf_log error "Couldn't remove volume $OCF_RESKEY_volume_id from instance $node_id"
return $OCF_ERR_GENERIC
fi
@@ -225,7 +228,7 @@ osvol_start() {
# TODO: make it optional in case multi-attachment is allowed by Cinder
#
if [ ! -z $attached_server_id ] ; then
- if ! $OCF_RESKEY_openstackcli server remove volume $attached_server_id $OCF_RESKEY_volume_id ; then
+ if ! run_openstackcli "server remove volume $attached_server_id $OCF_RESKEY_volume_id"; then
ocf_log error "Couldn't remove volume $OCF_RESKEY_volume_id from instance $attached_server_id"
return $OCF_ERR_GENERIC
fi
@@ -238,7 +241,7 @@ osvol_start() {
#
# Attach the volume
#
- $OCF_RESKEY_openstackcli server add volume $node_id $OCF_RESKEY_volume_id
+ run_openstackcli "server add volume $node_id $OCF_RESKEY_volume_id"
if [ $? != $OCF_SUCCESS ]; then
ocf_log error "Couldn't add volume $OCF_RESKEY_volume_id to instance $node_id"
return $OCF_ERR_GENERIC
diff --git a/heartbeat/openstack-common.sh b/heartbeat/openstack-common.sh
index 4763c90db..b6eec09c2 100644
--- a/heartbeat/openstack-common.sh
+++ b/heartbeat/openstack-common.sh
@@ -145,3 +145,25 @@ get_config() {
OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-project-domain-name $OCF_RESKEY_project_domain_name"
fi
}
+
+run_openstackcli() {
+ local cmd="${OCF_RESKEY_openstackcli} $1"
+ local result
+ local rc
+ local start_time=$(date +%s)
+ local end_time
+ local elapsed_time
+
+ result=$($cmd)
+ rc=$?
+ end_time=$(date +%s)
+ elapsed_time=$(expr $end_time - $start_time)
+
+ if [ $elapsed_time -gt 20 ]; then
+ ocf_log warn "$cmd took ${elapsed_time}s to complete"
+ fi
+
+ echo "$result"
+
+ return $rc
+}
diff --git a/heartbeat/openstack-floating-ip b/heartbeat/openstack-floating-ip
index 6e2895654..7317f19a8 100755
--- a/heartbeat/openstack-floating-ip
+++ b/heartbeat/openstack-floating-ip
@@ -101,11 +101,14 @@ END
}
osflip_validate() {
+ local result
+
check_binary "$OCF_RESKEY_openstackcli"
get_config
- if ! $OCF_RESKEY_openstackcli floating ip list|grep -q $OCF_RESKEY_ip_id ; then
+ result=$(run_openstackcli "floating ip list")
+ if ! echo "$result" | grep -q $OCF_RESKEY_ip_id; then
ocf_exit_reason "ip-id $OCF_RESKEY_ip_id not found"
return $OCF_ERR_CONFIGURED
fi
@@ -132,14 +135,14 @@ osflip_monitor() {
| awk '{gsub("[^ ]*:", "");print}')
# Is the IP active and attached?
- result=$($OCF_RESKEY_openstackcli floating ip show \
+ result=$(run_openstackcli "floating ip show \
--column port_id --column floating_ip_address \
--format yaml \
- $OCF_RESKEY_ip_id)
+ $OCF_RESKEY_ip_id")
for port in $node_port_ids ; do
- if echo $result | grep -q $port ; then
- floating_ip=$(echo $result | awk '/floating_ip_address/ {print $2}')
+ if echo "$result" | grep -q $port ; then
+ floating_ip=$(echo "$result" | awk '/floating_ip_address/ {print $2}')
${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -S status -n openstack_floating_ip -v $floating_ip
return $OCF_SUCCESS
@@ -160,7 +163,7 @@ osflip_stop() {
return $OCF_SUCCESS
fi
- if ! $OCF_RESKEY_openstackcli floating ip unset --port $OCF_RESKEY_ip_id ; then
+ if ! run_openstackcli "floating ip unset --port $OCF_RESKEY_ip_id"; then
return $OCF_ERR_GENERIC
fi
@@ -194,7 +197,7 @@ osflip_start() {
ocf_log info "Moving IP address $OCF_RESKEY_ip_id to port ID $node_port_id"
- $OCF_RESKEY_openstackcli floating ip set --port $node_port_id $OCF_RESKEY_ip_id
+ run_openstackcli "floating ip set --port $node_port_id $OCF_RESKEY_ip_id"
if [ $? != $OCF_SUCCESS ]; then
ocf_log error "$OCF_RESKEY_ip_id Cannot be set to port $node_port_id"
return $OCF_ERR_GENERIC
diff --git a/heartbeat/openstack-info.in b/heartbeat/openstack-info.in
index f3a59fc7a..6502f1df1 100755
--- a/heartbeat/openstack-info.in
+++ b/heartbeat/openstack-info.in
@@ -119,9 +119,7 @@ END
#######################################################################
OSInfoStats() {
- local result
local value
- local node
local node_id
get_config
@@ -141,31 +139,33 @@ OSInfoStats() {
${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_id -v "$node_id"
# Nova data: flavor
- value=$($OCF_RESKEY_openstackcli server show \
+ value=$(run_openstackcli "server show \
--format value \
--column flavor \
- $node_id)
+ $node_id")
${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_flavor -v "$value"
# Nova data: availability zone
- value=$($OCF_RESKEY_openstackcli server show \
+ value=$(run_openstackcli "server show \
--format value \
--column OS-EXT-AZ:availability_zone \
- $node_id)
+ $node_id")
${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_az -v "$value"
# Network data: ports
value=""
- for port_id in $($OCF_RESKEY_openstackcli port list \
+ for port_id in $(run_openstackcli "port list \
--format value \
--column id \
- --server $node_id); do
- subnet_id=$($OCF_RESKEY_openstackcli port show \
+ --server $node_id"); do
+ subnet_result=$(run_openstackcli "port show \
--format json \
--column fixed_ips \
- ${port_id} | grep -P '\"subnet_id\": \".*\",$' |
+ ${port_id}")
+ subnet_id=$(echo "$subnet_result" |
+ grep -P '\"subnet_id\": \".*\",$' |
grep -P -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}')
value="${value}${subnet_id}:${port_id},"
done
diff --git a/heartbeat/openstack-virtual-ip b/heartbeat/openstack-virtual-ip
index c654d980a..361357d55 100755
--- a/heartbeat/openstack-virtual-ip
+++ b/heartbeat/openstack-virtual-ip
@@ -132,11 +132,11 @@ osvip_monitor() {
node_port_id=$(osvip_port_id)
- result=$($OCF_RESKEY_openstackcli port show \
+ result=$(run_openstackcli "port show \
--format value \
--column allowed_address_pairs \
- ${node_port_id})
- if echo $result | grep -q "$OCF_RESKEY_ip"; then
+ ${node_port_id}")
+ if echo "$result" | grep -q "$OCF_RESKEY_ip"; then
${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -S status -n openstack_virtual_ip -v $OCF_RESKEY_ip
return $OCF_SUCCESS
@@ -158,20 +158,20 @@ osvip_stop() {
return $OCF_SUCCESS
fi
- mac_address=$($OCF_RESKEY_openstackcli port show \
+ mac_address=$(run_openstackcli "port show \
--format value \
--column mac_address \
- $node_port_id)
- echo ${mac_address} | grep -q -P "^([0-9a-f]{2}:){5}[0-9a-f]{2}$"
+ $node_port_id")
+ echo "${mac_address}" | grep -q -P "^([0-9a-f]{2}:){5}[0-9a-f]{2}$"
if [ $? -ne 0 ]; then
ocf_log error "MAC address '${mac_address}' is not valid."
return $OCF_ERR_GENERIC
fi
- if ! $OCF_RESKEY_openstackcli port unset \
+ if ! run_openstackcli "port unset \
--allowed-address \
ip-address=$OCF_RESKEY_ip,mac-address=${mac_address} \
- $node_port_id; then
+ $node_port_id"; then
return $OCF_ERR_GENERIC
fi
@@ -196,9 +196,9 @@ osvip_start() {
ocf_log info "Moving IP address $OCF_RESKEY_ip to port ID $node_port_id"
- $OCF_RESKEY_openstackcli port set \
+ run_openstackcli "port set \
--allowed-address ip-address=$OCF_RESKEY_ip \
- $node_port_id
+ $node_port_id"
if [ $? != $OCF_SUCCESS ]; then
ocf_log error "$OCF_RESKEY_ip Cannot be set to port $node_port_id"
return $OCF_ERR_GENERIC

View File

@ -0,0 +1,72 @@
From 64f434014bc198055478a139532c7cc133967c5d Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Fri, 8 Jul 2022 15:41:34 +0200
Subject: [PATCH] openstack-agents: fixes
- openstack-cinder-volume: dont do volume_local_check during start/stop-action
- openstack-floating-ip/openstack-virtual-ip: dont fail in validate()
during probe-calls
- openstack-floating-ip: fix awk only catching last id for node_port_ids
---
heartbeat/openstack-cinder-volume | 2 +-
heartbeat/openstack-floating-ip | 4 ++--
heartbeat/openstack-virtual-ip | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/heartbeat/openstack-cinder-volume b/heartbeat/openstack-cinder-volume
index cc12e58ae..19bf04faf 100755
--- a/heartbeat/openstack-cinder-volume
+++ b/heartbeat/openstack-cinder-volume
@@ -138,7 +138,7 @@ osvol_monitor() {
node_id=$(_get_node_id)
- if ocf_is_true $OCF_RESKEY_volume_local_check ; then
+ if [ "$__OCF_ACTION" = "monitor" ] && ocf_is_true $OCF_RESKEY_volume_local_check ; then
#
# Is the volue attached?
# We check the local devices
diff --git a/heartbeat/openstack-floating-ip b/heartbeat/openstack-floating-ip
index 8c135cc24..6e2895654 100755
--- a/heartbeat/openstack-floating-ip
+++ b/heartbeat/openstack-floating-ip
@@ -111,7 +111,7 @@ osflip_validate() {
fi
${HA_SBIN_DIR}/attrd_updater --query -n openstack_ports -N $(crm_node -n) > /dev/null 2>&1
- if [ $? -ne 0 ] ; then
+ if [ $? -ne 0 ] && ! ocf_is_probe; then
ocf_log warn "attr_updater failed to get openstack_ports attribute of node $OCF_RESOURCE_INSTANCE"
return $OCF_ERR_GENERIC
fi
@@ -129,7 +129,7 @@ osflip_monitor() {
node_port_ids=$(${HA_SBIN_DIR}/attrd_updater --query -n openstack_ports -N $(crm_node -n) \
| awk -F= '{gsub("\"","");print $NF}' \
| tr ',' ' ' \
- | awk -F: '{print $NF}')
+ | awk '{gsub("[^ ]*:", "");print}')
# Is the IP active and attached?
result=$($OCF_RESKEY_openstackcli floating ip show \
diff --git a/heartbeat/openstack-virtual-ip b/heartbeat/openstack-virtual-ip
index a1084c420..c654d980a 100755
--- a/heartbeat/openstack-virtual-ip
+++ b/heartbeat/openstack-virtual-ip
@@ -119,7 +119,7 @@ osvip_validate() {
get_config
${HA_SBIN_DIR}/attrd_updater --query -n openstack_ports -N $(crm_node -n) > /dev/null 2>&1
- if [ $? -ne 0 ] ; then
+ if [ $? -ne 0 ] && ! ocf_is_probe; then
ocf_log warn "attr_updater failed to get openstack_ports attribute of node $OCF_RESOURCE_INSTANCE"
return $OCF_ERR_GENERIC
fi
@@ -136,7 +136,7 @@ osvip_monitor() {
--format value \
--column allowed_address_pairs \
${node_port_id})
- if echo $result | grep -q $OCF_RESKEY_ip ; then
+ if echo $result | grep -q "$OCF_RESKEY_ip"; then
${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -S status -n openstack_virtual_ip -v $OCF_RESKEY_ip
return $OCF_SUCCESS

View File

@ -0,0 +1,26 @@
From 8b1d3257e5176a2f50a843a21888c4b4f51f370b Mon Sep 17 00:00:00 2001
From: Valentin Vidic <vvidic@valentin-vidic.from.hr>
Date: Sun, 3 Apr 2022 20:31:50 +0200
Subject: [PATCH] openstack-info: fix bashism
Also simplify striping of trailing comma.
---
heartbeat/openstack-info.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/heartbeat/openstack-info.in b/heartbeat/openstack-info.in
index f6dc1ee4d..f3a59fc7a 100755
--- a/heartbeat/openstack-info.in
+++ b/heartbeat/openstack-info.in
@@ -167,9 +167,9 @@ OSInfoStats() {
--column fixed_ips \
${port_id} | grep -P '\"subnet_id\": \".*\",$' |
grep -P -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}')
- value+="${subnet_id}:${port_id},"
+ value="${value}${subnet_id}:${port_id},"
done
- value=$(echo ${value} | sed -e 's/,$//g')
+ value=${value%,}
${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_ports -v "$value"

View File

@ -45,7 +45,7 @@
Name: resource-agents
Summary: Open Source HA Reusable Cluster Resource Scripts
Version: 4.10.0
Release: 18%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist}
Release: 19%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist}
License: GPLv2+ and LGPLv2+
URL: https://github.com/ClusterLabs/resource-agents
Source0: %{upstream_prefix}-%{upstream_version}.tar.gz
@ -71,6 +71,9 @@ Patch18: bz2081585-NovaEvacuate-add-user_domain-project_domain.patch
Patch19: bz2094828-lvmlockd-fail-when-use_lvmlockd-not-set.patch
Patch20: bz2093213-aws-vpc-move-ip-add-interface-label-support.patch
Patch21: bz2063877-all-agents-use-promotable-terms.patch
Patch22: bz2083090-openstack-info-fix-bashism.patch
Patch23: bz2083081-bz2083086-bz2083092-openstack-agents-fixes.patch
Patch24: bz2083081-bz2083086-bz2083090-bz2083092-openstack-agents-warn-when-openstackcli-slow.patch
# bundled ha-cloud-support libs
Patch500: ha-cloud-support-aws.patch
@ -216,6 +219,9 @@ exit 1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
# bundled ha-cloud-support libs
%patch500 -p1
@ -538,6 +544,12 @@ rm -rf %{buildroot}/usr/share/doc/resource-agents
%{_usr}/lib/ocf/lib/heartbeat/OCF_*.pm
%changelog
* Tue Jul 12 2022 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-19
- openstack-cinder-volume/openstack-floating-ip/openstack-info/
openstack-virtual-ip: new resource agents
Resolves: rhbz#2083081, rhbz#2083086, rhbz#2083090, rhbz#2083092
* Mon Jun 20 2022 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-18
- all agents: use promotable terms
@ -555,12 +567,6 @@ rm -rf %{buildroot}/usr/share/doc/resource-agents
Resolves: rhbz#2081585
* Mon May 9 2022 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-14
- openstack-cinder-volume/openstack-floating-ip/openstack-info/
openstack-virtual-ip: new resource agents
Resolves: rhbz#2083081, rhbz#2083086, rhbz#2083090, rhbz#2083092
* Thu Apr 21 2022 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-12
- Filesystem: fix UUID/label device support when there's whitespace
between parameter and UUID/label