Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package resource-agents for openSUSE:Factory checked in at 2021-05-12 19:31:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/resource-agents (Old) and /work/SRC/openSUSE:Factory/.resource-agents.new.2988 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "resource-agents" Wed May 12 19:31:40 2021 rev:107 rq:892020 version:4.8.0+git28.5c54175d Changes: -------- --- /work/SRC/openSUSE:Factory/resource-agents/resource-agents.changes 2021-04-18 21:44:58.428707978 +0200 +++ /work/SRC/openSUSE:Factory/.resource-agents.new.2988/resource-agents.changes 2021-05-12 19:32:04.403075667 +0200 @@ -1,0 +2,15 @@ +Mon May 10 10:48:36 UTC 2021 - vark...@suse.com + +- Update to version 4.8.0+git28.5c54175d: + * LVM-activate: Disable VG autoactivation in system_id access_mode + * gcp-vpc-move-vip.in: Adds retries + * gcp-ilb: resource wrapping nc or socat to respond to health checks (#1541) + * azure-events: update api_version + * openstack-cinder-volume: CLI output parsing fixes, fetch of node ID consistency, monitor action simplification, and proper use of osvol_validate. + * openstack-virtual-ip: New resource agent for virtual IP support in OpenStack. + * openstack-floating-ip: Proper use of osflip_validate and small log message fixes. + * configure: add /usr/local/share to fallback path to be scanned for docbook path + * openstack-info: Use OSInfo_validate in start action. (#1639) + (bsc#1178680) HA-LVM systemid race condition introduces an error "active on 2 nodes" + +------------------------------------------------------------------- @@ -113,0 +129,9 @@ + (bsc#1183971) L3: azure-events puts both nodes in standby + (bsc#1177796) ethmonitor bloats journal with warnings for VLAN + (bsc#1180590) azure-events URLError fixed upstream + (bsc#1184607) gcp-vpc-move-route resource agent file_cache is unavailable when using oauth2client + (bsc#1179977) L3: anything RA stop operation fails if /root/.profile has unexpected content + (bsc#1178977) ocf.py does not handle probe actions + (bsc#1175435) Last commit of a galera cluster member is not saved into grastate.dat + (bsc#1175101) GCP Resource Agents - Support for Multi Alias IP + (bsc#1170354) OCF version check for pacemaker is incompatible with the SUSE version strings Old: ---- resource-agents-4.8.0+git12.3068bf8b.tar.xz New: ---- resource-agents-4.8.0+git28.5c54175d.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ resource-agents.spec ++++++ --- /var/tmp/diff_new_pack.od3X7V/_old 2021-05-12 19:32:04.959073447 +0200 +++ /var/tmp/diff_new_pack.od3X7V/_new 2021-05-12 19:32:04.963073431 +0200 @@ -17,7 +17,7 @@ Name: resource-agents -Version: 4.8.0+git12.3068bf8b +Version: 4.8.0+git28.5c54175d Release: 0 Summary: HA Reusable Cluster Resource Scripts License: GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.od3X7V/_old 2021-05-12 19:32:05.011073239 +0200 +++ /var/tmp/diff_new_pack.od3X7V/_new 2021-05-12 19:32:05.015073223 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/ClusterLabs/resource-agents.git</param> -<param name="changesrevision">3068bf8b1dc47f69a22ab7785b0ffd6c28c97342</param> +<param name="changesrevision">5c54175d39a81344535977a475b015f6ec6b123a</param> </service> </servicedata> \ No newline at end of file ++++++ resource-agents-4.8.0+git12.3068bf8b.tar.xz -> resource-agents-4.8.0+git28.5c54175d.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/configure.ac new/resource-agents-4.8.0+git28.5c54175d/configure.ac --- old/resource-agents-4.8.0+git12.3068bf8b/configure.ac 2021-04-14 13:16:57.000000000 +0200 +++ new/resource-agents-4.8.0+git28.5c54175d/configure.ac 2021-04-30 16:27:24.000000000 +0200 @@ -580,7 +580,7 @@ if test x"${DIRS}" = x""; then # when datadir is not standard OS path, we cannot find docbook.xsl # use standard OS path as backup - DIRS=$(find "/usr/share" -name $(basename $(dirname ${DOCBOOK_XSL_PATH})) \ + DIRS=$(find "/usr/share" "/usr/local/share" -name $(basename $(dirname ${DOCBOOK_XSL_PATH})) \ -type d | LC_ALL=C sort) fi XSLT=$(basename ${DOCBOOK_XSL_PATH}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/doc/man/Makefile.am new/resource-agents-4.8.0+git28.5c54175d/doc/man/Makefile.am --- old/resource-agents-4.8.0+git12.3068bf8b/doc/man/Makefile.am 2021-04-14 13:16:57.000000000 +0200 +++ new/resource-agents-4.8.0+git28.5c54175d/doc/man/Makefile.am 2021-04-30 16:27:24.000000000 +0200 @@ -147,6 +147,7 @@ ocf_heartbeat_openstack-info.7 \ ocf_heartbeat_openstack-cinder-volume.7 \ ocf_heartbeat_openstack-floating-ip.7 \ + ocf_heartbeat_openstack-virtual-ip.7 \ ocf_heartbeat_oraasm.7 \ ocf_heartbeat_oracle.7 \ ocf_heartbeat_oralsnr.7 \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/LVM-activate new/resource-agents-4.8.0+git28.5c54175d/heartbeat/LVM-activate --- old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/LVM-activate 2021-04-14 13:16:57.000000000 +0200 +++ new/resource-agents-4.8.0+git28.5c54175d/heartbeat/LVM-activate 2021-04-30 16:27:24.000000000 +0200 @@ -115,6 +115,9 @@ the stop action of the lvmlockd agent may fail and the node may get fenced, because some DLM lockspaces might be in use and cannot be closed automatically. +3. The autoactivation property of volume group will be disabled when vg_access_mode +is set to system_id. + Option: OCF_CHECK_LEVEL The standard monitor operation of depth 0 checks if the VG or LV is valid. @@ -658,11 +661,20 @@ } systemid_activate() { + set_autoactivation=0 cur_systemid=$(vgs --foreign --noheadings -o systemid ${VG} | tr -d '[:blank:]') # Put our system ID on the VG vgchange -y --config "local/extra_system_ids=[\"${cur_systemid}\"]" \ --systemid ${SYSTEM_ID} ${VG} + vgchange --help | grep '\--setautoactivation' >/dev/null 2>&1 && set_autoactivation=1 + + if [ $set_autoactivation -ne 0 ]; then + if vgs -o autoactivation ${VG} | grep enabled >/dev/null 2>&1 ; then + ocf_log info "disable the autoactivation property of ${VG}" + ocf_run vgchange --setautoactivation n ${VG} + fi + fi do_activate "-ay" if [ $? -ne $OCF_SUCCESS ]; then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/Makefile.am new/resource-agents-4.8.0+git28.5c54175d/heartbeat/Makefile.am --- old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/Makefile.am 2021-04-14 13:16:57.000000000 +0200 +++ new/resource-agents-4.8.0+git28.5c54175d/heartbeat/Makefile.am 2021-04-30 16:27:24.000000000 +0200 @@ -142,6 +142,7 @@ openstack-cinder-volume \ openstack-floating-ip \ openstack-info \ + openstack-virtual-ip \ oraasm \ oracle \ oralsnr \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/azure-events.in new/resource-agents-4.8.0+git28.5c54175d/heartbeat/azure-events.in --- old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/azure-events.in 2021-04-14 13:16:57.000000000 +0200 +++ new/resource-agents-4.8.0+git28.5c54175d/heartbeat/azure-events.in 2021-04-30 16:27:24.000000000 +0200 @@ -70,7 +70,7 @@ metadata_host = "http://169.254.169.254/metadata" instance_api = "instance" events_api = "scheduledevents" - api_version = "2017-08-01" + api_version = "2019-08-01" @staticmethod def _sendMetadataRequest(endpoint, postData=None): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/gcp-ilb new/resource-agents-4.8.0+git28.5c54175d/heartbeat/gcp-ilb --- old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/gcp-ilb 1970-01-01 01:00:00.000000000 +0100 +++ new/resource-agents-4.8.0+git28.5c54175d/heartbeat/gcp-ilb 2021-04-30 16:27:24.000000000 +0200 @@ -0,0 +1,343 @@ +#!/bin/sh +# --------------------------------------------------------------------- +# # Copyright 2021 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Authors: Fatima Silveira, Lucia Subatin +# --------------------------------------------------------------------- +# Description: Wrapper to respond to probe requests from health +# check agents in Google Cloud Platform. Nothing is specific to Google +# Cloud. +# --------------------------------------------------------------------- + + +# Initialization: +: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} +. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs + +# Defaults +OCF_RESKEY_cat_default="socat" +OCF_RESKEY_port_default="60000" +OCF_RESKEY_log_enable_default="false" +OCF_RESKEY_log_cmd_default="gcloud" +OCF_RESKEY_log_params_default="logging write GCPILB" +OCF_RESKEY_log_end_params_default="" + + +if type "socat" > /dev/null 2>&1; then + OCF_RESKEY_cat_default="socat" +else + OCF_RESKEY_cat_default="nc" +fi; + + +: ${OCF_RESKEY_cat=${OCF_RESKEY_cat_default}} +: ${OCF_RESKEY_port=${OCF_RESKEY_port_default}} +: ${OCF_RESKEY_log_enable=${OCF_RESKEY_log_enable_default}} +: ${OCF_RESKEY_log_cmd=${OCF_RESKEY_log_cmd_default}} +: ${OCF_RESKEY_log_params=${OCF_RESKEY_log_params_default}} +: ${OCF_RESKEY_log_end_params=${OCF_RESKEY_log_end_params_default}} + + +process="$OCF_RESOURCE_INSTANCE" +pidfile="/var/run/$OCF_RESOURCE_INSTANCE.pid" + + +#Validate command for logging +if $OCF_RESKEY_log_enable = "true"; then + if type $OCF_RESKEY_log_cmd > /dev/null 2>&1; then + logging_cmd="$OCF_RESKEY_log_cmd $OCF_RESKEY_log_params" + ocf_log debug "Logging command is: \'$logging_cmd\' " + else + $OCF_RESKEY_log_enable = "false" + ocf_log err "\'$logging_cmd\' is invalid. External logging disabled." + + fi; +fi + + +####################################################################### +ilb_metadata() { +cat <<END +<?xml version="1.0"?> +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> +<resource-agent name="gcp-lb"> +<version>1.0</version> +<longdesc lang="en"> + Resource Agent that wraps /usr/bin/nc or /usr/bin/socat to reply to health checks in Google Cloud. + See https://cloud.google.com/load-balancing/docs/health-checks for more information. +</longdesc> + +<shortdesc lang="en">Replies to health checks from Google Cloud</shortdesc> + +<parameters> + <parameter name="port"> + <longdesc lang="en"> + Listening port for health-check probes. Default: ${OCF_RESKEY_port_default} + </longdesc> + <shortdesc lang="en">Listening port (def ${OCF_RESKEY_port_default}) </shortdesc> + <content type="string" default="${OCF_RESKEY_port_default}" /> + </parameter> + + <parameter name="cat"> + <longdesc lang="en"> + Location of netcat (default: /usr/bin/nc ) or socat (default: /usr/bin/socat ). If present, is used /usr/bin/socat. + The recommended binary is socat, present in the following minimum versions if the package resource-agents: + - SLES 12 SP4/SP5: resource-agents-4.3.018.a7fb5035-3.30.1. + - SLES 15/15 SP1: resource-agents-4.3.0184.6ee15eb2-4.13.1. + </longdesc> + <shortdesc lang="en">Path to nc / socat </shortdesc> + <content type="string" default="${OCF_RESKEY_cat_default}" /> + </parameter> + <parameter name="log_enable"> + <longdesc lang="en"> + Logging with an external application is enabled (accepts "true" or "false"). The defaults are configured to call "gcloud logging" (see: https://cloud.google.com/sdk/gcloud/reference/logging). + </longdesc> + <shortdesc lang="en">Log enabled </shortdesc> + <content type="string" default="${OCF_RESKEY_log_enable_default}" /> + </parameter> + <parameter name="log_cmd"> + <longdesc lang="en"> + External logging command. The defaults are configured to call "gcloud logging" (see: https://cloud.google.com/sdk/gcloud/reference/logging). + This parameter should only have the binary that can be validated (e.g., gcloud). The rest of the command is formed with the additional parameters + and the message being logged as follows: + - log_cmd + log_params + "The message being logged" + log_end_params + + Using the gcloud command for Stackdriver logging, the parameters would be: + - log_cmd = gcloud + - log_params = logging write GCPILB + - "This is a message being sent by the app" + - log_end_params = (nothing in this case, this is reserved for use with other tools) + Which would result in this valid command (where GCPILB is the name of the log): + gcloud logging write GCPILB "This is a message being sent by the app" + + NOTE: Only the binary is validated for existence and no further checks are performed. The assumption is that only administrators with root access can configure this tool. + </longdesc> + <shortdesc lang="en">External log command </shortdesc> + <content type="string" default="${OCF_RESKEY_log_cmd_default}" /> + </parameter> + <parameter name="log_params"> + <longdesc lang="en"> + Additional input for the logging application. See explanation for log_cmd + </longdesc> + <shortdesc lang="en">Additional input 1 </shortdesc> + <content type="string" default="${OCF_RESKEY_log_params_default}" /> + </parameter> + <parameter name="log_end_params"> + <longdesc lang="en"> + Additional input for the logging application. Placed after the message being logged. + </longdesc> + <shortdesc lang="en">Additional input 1 </shortdesc> + <content type="string" default="${OCF_RESKEY_log_end_params_default}" /> + </parameter> + +</parameters> + +<actions> + <action name="start" timeout="10s" /> + <action name="stop" timeout="30s" /> + <action name="monitor" depth="0" timeout="30s" interval="30s" /> + <action name="validate-all" timeout="5s" /> + <action name="meta-data" timeout="5s" /> +</actions> +</resource-agent> +END +exit 0 +} + +####################################################################### + +log() { + lvl=$1 + msg=$2 + ocf_log $lvl "$0 - $process - $pid: $msg" + if ocf_is_true "${OCF_RESKEY_log_enable}" ; then + ( ${OCF_RESKEY_log_cmd} ${OCF_RESKEY_log_params} "L $lvl: $msg" ${OCF_RESKEY_log_end_params} ) + fi +} + +getpid() { + if ! [ -f "$pidfile" ] ; then + return + fi + + cat $pidfile +} + +ilb_usage() { + cat <<END +usage: $0 {start|stop|monitor|status|meta-data|validate-all} + +Agent wrapping socat or nc to reply to health probes. +END +} + + + + +ilb_monitor() { + + pid=`getpid` + log debug "pid is $pid" + + if [ -z "$pid" ] ; then + return $OCF_NOT_RUNNING + fi + + if [ -n "$pid" ] && kill -s 0 $pid ; then + log debug "Process is currently running" + return $OCF_SUCCESS + else + log warn "The process is not running but has a pidfile. Removing file" + rm -f $pidfile + return $OCF_NOT_RUNNING + fi + +} + +ilb_start() { + + if ilb_monitor; then + log debug "Process is already running" + return $OCF_SUCCESS + fi + + cmd="$OCF_RESKEY_cat -U TCP-LISTEN:$OCF_RESKEY_port,backlog=10,fork,reuseaddr /dev/null" + + if [ $( basename $OCF_RESKEY_cat ) = 'nc' ]; then + cmd="$OCF_RESKEY_cat -l -k $OCF_RESKEY_port" + fi + + log debug "Starting with \'$cmd\'" + ( ${cmd} ) & pid="$!" + disown + + if [ -n "$pid" ] ; then + log debug "$pid is started" + echo "$pid" > $pidfile + return $OCF_SUCCESS + else + log err "\'$cmd\' could not be started" + return $OCF_ERR_GENERIC + fi + +} + +ilb_stop() { + + if ! ilb_monitor; then + rm -f $pidfile + return $OCF_SUCCESS + fi + + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + # Allow 2/3 of the action timeout for the orderly shutdown + # (The origin unit is ms, hence the conversion) + stop_timeout=$((OCF_RESKEY_CRM_meta_timeout/1500)) + else + stop_timeout=10 + fi + + + pid=`getpid` + kill $pid + + i=0 + while [ $i -lt $stop_timeout ]; do + if ! ilb_monitor; then + rm -f $pidfile + return $OCF_SUCCESS + fi + sleep 1 + i=$((i+1)) + done + + log warn "Stop with SIGTERM failed/timed out, now sending SIGKILL." + + i=0 + while [ $i -lt $stop_timeout ]; do + + kill -s 9 $pid + + if ! ilb_monitor; then + log warn "SIGKILL did the job." + rm -f $pidfile + return $OCF_SUCCESS + fi + log info "The job still hasn't stopped yet. Re-trying SIGKILL..." + sleep 2 + i=$((i+2)) + done + + log err "The cat has more than 9 lives and could not be terminated." + return $OCF_ERR_GENERIC + +} + +ilb_validate() { + check_binary "$OCF_RESKEY_cat" + check_binary "$OCF_RESKEY_log_cmd" + + if ! ocf_is_decimal "$OCF_RESKEY_port"; then + ocf_exit_reason "$OCF_RESKEY_port is not a valid port" + exit $OCF_ERR_CONFIGURED + fi + + return $OCF_SUCCESS +} + +############################################################################### +# +# MAIN +# +############################################################################### + +case $__OCF_ACTION in + meta-data) + ilb_metadata + exit $OCF_SUCCESS + ;; + usage|help) + ilb_usage + exit $OCF_SUCCESS + ;; +esac + +if ! ocf_is_root; then + log err "You must be root for $__OCF_ACTION operation." + exit $OCF_ERR_PERM +fi + +case $__OCF_ACTION in + start) + ilb_validate + ilb_start + ;; + stop) + ilb_stop + ;; + monitor) + ilb_monitor + ;; + validate-all) + ilb_validate + ;; + *) + ilb_usage + exit $OCF_ERR_UNIMPLEMENTED + ;; +esac + +rc=$? +log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION returned $rc" + +exit $rc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/gcp-vpc-move-vip.in new/resource-agents-4.8.0+git28.5c54175d/heartbeat/gcp-vpc-move-vip.in --- old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/gcp-vpc-move-vip.in 2021-04-14 13:16:57.000000000 +0200 +++ new/resource-agents-4.8.0+git28.5c54175d/heartbeat/gcp-vpc-move-vip.in 2021-04-30 16:27:24.000000000 +0200 @@ -50,6 +50,8 @@ CONN = None THIS_VM = None ALIAS = None +MAX_RETRIES = 3 +RETRY_BACKOFF_SECS = 1 METADATA_SERVER = 'http://metadata.google.internal/computeMetadata/v1/' METADATA_HEADERS = {'Metadata-Flavor': 'Google'} METADATA = \ @@ -111,18 +113,37 @@ Returns: HTTP response from the GET request. - - Raises: - urlerror.HTTPError: raises when the GET request fails. """ - timeout = timeout or 60 - metadata_url = os.path.join(METADATA_SERVER, metadata_key) - params = urlparse.urlencode(params or {}) - url = '%s?%s' % (metadata_url, params) - request = urlrequest.Request(url, headers=METADATA_HEADERS) - request_opener = urlrequest.build_opener(urlrequest.ProxyHandler({})) - return request_opener.open( - request, timeout=timeout * 1.1).read().decode("utf-8") + for i in range(MAX_RETRIES): + try: + timeout = timeout or 60 + metadata_url = os.path.join(METADATA_SERVER, metadata_key) + params = urlparse.urlencode(params or {}) + url = '%s?%s' % (metadata_url, params) + request = urlrequest.Request(url, headers=METADATA_HEADERS) + request_opener = urlrequest.build_opener(urlrequest.ProxyHandler({})) + return request_opener.open( + request, timeout=timeout * 1.1).read().decode("utf-8") + except Exception as e: + logger.error('Couldn\'t get instance name, is this running inside GCE?: ' + + str(e)) + time.sleep(RETRY_BACKOFF_SECS * (i + 1)) + + # If the retries are exhausted we exit with a generic error. + sys.exit(OCF_ERR_GENERIC) + + +def create_api_connection(): + for i in range(MAX_RETRIES): + try: + return googleapiclient.discovery.build('compute', 'v1', + cache_discovery=False) + except Exception as e: + logger.error('Couldn\'t connect with google api: ' + str(e)) + time.sleep(RETRY_BACKOFF_SECS * (i + 1)) + + # If the retries are exhausted we exit with a generic error. + sys.exit(OCF_ERR_GENERIC) def get_instance(project, zone, instance): @@ -358,24 +379,11 @@ def validate(): global ALIAS - global CONN global THIS_VM + global CONN - # Populate global vars - try: - CONN = googleapiclient.discovery.build('compute', 'v1', - cache_discovery=False) - except Exception as e: - logger.error('Couldn\'t connect with google api: ' + str(e)) - sys.exit(OCF_ERR_CONFIGURED) - - try: - THIS_VM = get_metadata('instance/name') - except Exception as e: - logger.error('Couldn\'t get instance name, is this running inside GCE?: ' - + str(e)) - sys.exit(OCF_ERR_CONFIGURED) - + CONN = create_api_connection() + THIS_VM = get_metadata('instance/name') ALIAS = os.environ.get('OCF_RESKEY_alias_ip') if not ALIAS: logger.error('Missing alias_ip parameter') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/openstack-cinder-volume new/resource-agents-4.8.0+git28.5c54175d/heartbeat/openstack-cinder-volume --- old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/openstack-cinder-volume 2021-04-14 13:16:57.000000000 +0200 +++ new/resource-agents-4.8.0+git28.5c54175d/heartbeat/openstack-cinder-volume 2021-04-30 16:27:24.000000000 +0200 @@ -27,6 +27,7 @@ # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. # + ####################################################################### # Initialization: @@ -35,13 +36,9 @@ # Defaults OCF_RESKEY_openstackcli_default="/usr/bin/openstack" -OCF_RESKEY_node_id_cache_file_default="${HA_RSCTMP}/node_id" OCF_RESKEY_volume_local_check_default="true" -export attached_server_id="" - : ${OCF_RESKEY_openstackcli=${OCF_RESKEY_openstackcli_default}} -: ${OCF_RESKEY_node_id_cache_file=${OCF_RESKEY_node_id_cache_file_default}} : ${OCF_RESKEY_volume_local_check=${OCF_RESKEY_volume_local_check_default}} ####################################################################### @@ -79,17 +76,6 @@ <content type="string" default="${OCF_RESKEY_openstackcli_default}" /> </parameter> -<parameter name="node_id_cache_file"> -<longdesc lang="en"> -Path to Node ID cache file, used to avoid Openstack API calls: -1. Is the local file written? -2. Is openstack_id available as a node attribute? -3. Can we get it from the API? -</longdesc> -<shortdesc lang="en">Path to Node ID cache file</shortdesc> -<content type="string" default="${OCF_RESKEY_node_id_cache_file_default}" /> -</parameter> - <parameter name="volume_local_check"> <longdesc lang="en"> This option allows the cluster to monitor the cinder volume presence without @@ -128,83 +114,19 @@ END } -# -# This is used to get the node ID from different sources: -# 1. Is the local file written? -# 2. Is openstack_id available as a node attribute? -# 3. Can we get it from the API? -# -# When the ID is retrieved, the local cache file is written. -# This prevents the agent to call the API each time the agent is used. -# _get_node_id() { - local crm_node - local node - local node_id - local result - - crm_node=$(crm_node -n) - - # - # Use local cache - # - if [ -f $OCF_RESKEY_node_id_cache_file ] ; then - node_id=$(cat $OCF_RESKEY_node_id_cache_file) - - if [ ! -z "$node_id" ] ; then - echo $node_id - return - fi - fi + node_id=$(${HA_SBIN_DIR}/attrd_updater --query -n openstack_id -N $(crm_node -n) | + awk -F= '{gsub("\"","");print $NF}') - # - # Query the attributes database - # - node_id=$(${HA_SBIN_DIR}/attrd_updater --query -n openstack_id -N $crm_node \ - | tr ' ' '\n' \ - | awk -F= '/value=/ {gsub("\"","");print $NF}') - - if [ ! -z "$node_id" ] ; then - echo $node_id | awk '{print $1}' - echo $node_id | awk '{print $1}' > $OCF_RESKEY_node_id_cache_file - return - fi - - # - # Use the API - # - node=$(crm_node -n | awk -F. '{print $1}') - - result=$($OCF_RESKEY_openstackcli server list \ - --format value --column ID --column Name \ - | grep $node) - - if [ $? -eq 0 ] ; then - echo $result | awk '{print $1}' - echo $result | awk '{print $1}' > $OCF_RESKEY_node_id_cache_file - return + if ! echo $node_id|grep -P "^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$"; then + ocf_exit_reason "openstack_id attribute must be set for node $crm_node" + exit $OCF_ERR_CONFIGURED fi - - ocf_exit_reason "openstack_id attribute must be set for node $crm_node" - return $OCF_ERR_CONFIGURED } osvol_validate() { - local node_id - check_binary "$OCF_RESKEY_openstackcli" - check_binary "awk" - check_binary "tr" - . $OCF_RESKEY_openrc - - node_id=$(_get_node_id) - - if [ -z "$node_id" ] ; then - ocf_exit_reason "openstack_id attribute must be set for node $crm_node" - return $OCF_ERR_CONFIGURED - fi - if [ -z "$OCF_RESKEY_openrc" ]; then ocf_exit_reason "openrc parameter not set" return $OCF_ERR_CONFIGURED @@ -215,6 +137,19 @@ return $OCF_ERR_CONFIGURED fi + . $OCF_RESKEY_openrc + + if ! $OCF_RESKEY_openstackcli volume list|grep -q $OCF_RESKEY_volume_id ; then + ocf_exit_reason "volume-id $OCF_RESKEY_volume_id not found" + return $OCF_ERR_CONFIGURED + fi + + ${HA_SBIN_DIR}/attrd_updater --query -n openstack_id -N $(crm_node -n) > /dev/null 2>&1 + if [ $? -ne 0 ] ; then + ocf_log warn "attr_updater failed to get openstack_id attribute of node $OCF_RESOURCE_INSTANCE" + return $OCF_ERR_GENERIC + fi + return $OCF_SUCCESS } @@ -222,7 +157,8 @@ local result local node_id local short_volume_id - local fdisk_command + + node_id=$(_get_node_id) if ocf_is_true $OCF_RESKEY_volume_local_check ; then # @@ -230,43 +166,38 @@ # We check the local devices # short_volume_id=$(echo $OCF_RESKEY_volume_id | awk '{print substr($0, 0, 20)}') - if uname | grep -q Linux ; then - fdisk_command="fdisk -l" - else - fdisk_command="fdisk" - fi - - $fdisk_command /dev/disk/by-id/virtio-$short_volume_id 1>/dev/null 2>&1 - if [ $? -eq 0 ] ; then + if lsblk /dev/disk/by-id/virtio-$short_volume_id 1>/dev/null 2>&1; then return $OCF_SUCCESS else - ocf_log warn "$OCF_RESKEY_volume_id is not attached to instance $(_get_node_id)" + ocf_log warn "$OCF_RESKEY_volume_id is not attached to instance $node_id" return $OCF_NOT_RUNNING fi - else - # - # Is the volue attached? - # We use the API - # - result=$($OCF_RESKEY_openstackcli volume show \ - --column status \ - --column attachments \ - --format value \ - $OCF_RESKEY_volume_id) + fi - 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|awk -F "'" '{print $4}') - ocf_log info "$OCF_RESKEY_volume_id is attached to instance $attached_server_id" + # + # Is the volue attached? + # We use the API + # + result=$($OCF_RESKEY_openstackcli volume show \ + --column status \ + --column attachments \ + --format value \ + $OCF_RESKEY_volume_id) + + 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| + 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" - # Compare node_id and the id of the node the volume is attached to - node_id=$(_get_node_id) + # Compare node_id and the id of the node the volume is attached to - if [ "$node_id" != "$attached_server_id" ] ; then - return $OCF_NOT_RUNNING - fi + if [ "$node_id" != "$attached_server_id" ] ; then + ocf_log warn "$OCF_RESKEY_volume_id is not attached to this instance" + return $OCF_NOT_RUNNING fi fi @@ -288,7 +219,7 @@ node_id=$(_get_node_id) # - # Unmout the volume + # Detach the volume # if ! $OCF_RESKEY_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" @@ -312,7 +243,7 @@ fi # - # Unmout it from another node + # Detach it from another node # TODO: make it optional in case multi-attachment is allowed by Cinder # if [ ! -z $attached_server_id ] ; then @@ -360,19 +291,23 @@ exit $OCF_ERR_PERM fi -osvol_validate - case $__OCF_ACTION in start) + osvol_validate || exit $? osvol_start;; stop) + osvol_validate || exit $? osvol_stop;; monitor|status) + osvol_validate || exit $? osvol_monitor;; validate-all) - exit $?;; + osvol_validate + ;; *) echo $USAGE exit $OCF_ERR_UNIMPLEMENTED ;; esac + +exit $? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/openstack-floating-ip new/resource-agents-4.8.0+git28.5c54175d/heartbeat/openstack-floating-ip --- old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/openstack-floating-ip 2021-04-14 13:16:57.000000000 +0200 +++ new/resource-agents-4.8.0+git28.5c54175d/heartbeat/openstack-floating-ip 2021-04-30 16:27:24.000000000 +0200 @@ -147,10 +147,8 @@ local node_port_ids local port local buffer - local crm_node - crm_node=$(crm_node -n) - node_port_ids=$(${HA_SBIN_DIR}/attrd_updater --query -n openstack_ports -N $crm_node \ + 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}') @@ -194,7 +192,7 @@ return $OCF_ERR_GENERIC fi - ocf_log info "Successfully brought unset $OCF_RESKEY_ip_id" + ocf_log info "Successfully brought down $OCF_RESKEY_ip_id" return $OCF_SUCCESS } @@ -230,6 +228,7 @@ return $OCF_ERR_GENERIC fi + ocf_log info "Successfully brought up $OCF_RESKEY_ip_id" return $OCF_SUCCESS } @@ -255,19 +254,23 @@ exit $OCF_ERR_PERM fi -osflip_validate - case $__OCF_ACTION in start) + osflip_validate || exit $? osflip_start;; stop) + osflip_validate || exit $? osflip_stop;; monitor) + osflip_validate || exit $? osflip_monitor;; validate-all) - exit $?;; + osflip_validate + ;; *) echo $USAGE exit $OCF_ERR_UNIMPLEMENTED ;; esac + +exit $? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/openstack-info.in new/resource-agents-4.8.0+git28.5c54175d/heartbeat/openstack-info.in --- old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/openstack-info.in 2021-04-14 13:16:57.000000000 +0200 +++ new/resource-agents-4.8.0+git28.5c54175d/heartbeat/openstack-info.in 2021-04-30 16:27:24.000000000 +0200 @@ -270,7 +270,8 @@ meta-data) meta_data exit $OCF_SUCCESS ;; -start) OSInfo_start +start) OSInfo_validate || exit $? + OSInfo_start ;; stop) OSInfo_stop ;; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/openstack-virtual-ip new/resource-agents-4.8.0+git28.5c54175d/heartbeat/openstack-virtual-ip --- old/resource-agents-4.8.0+git12.3068bf8b/heartbeat/openstack-virtual-ip 1970-01-01 01:00:00.000000000 +0100 +++ new/resource-agents-4.8.0+git28.5c54175d/heartbeat/openstack-virtual-ip 2021-04-30 16:27:24.000000000 +0200 @@ -0,0 +1,280 @@ +#!/bin/sh +# +# +# OCF resource agent to move a virtual address in an Openstack tenant. +# +# Copyright (c) 2018 Mathieu GRZYBEK +# Based on code of Markus Guertler +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Further, this software is distributed without any warranty that it is +# free of the rightful claim of any third person regarding infringement +# or the like. Any license provided herein, whether implied or +# otherwise, applies only to this software file. Patent licenses, if +# any, provided herein do not apply to combinations of this program with +# other software, or any other product whatsoever. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. +# + + +####################################################################### +# Initialization: + +: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} +. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs + +# Defaults +OCF_RESKEY_openstackcli_default="/usr/bin/openstack" + +: ${OCF_RESKEY_openstackcli=${OCF_RESKEY_openstackcli_default}} + +####################################################################### + + +USAGE="usage: $0 {start|stop|status|meta-data}"; +############################################################################### + + +############################################################################### +# +# Functions +# +############################################################################### + + +metadata() { +cat <<END +<?xml version="1.0"?> +<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> +<resource-agent name="openstack-virtual-ip"> +<version>2.0</version> +<longdesc lang="en"> +Resource Agent to move a virtual IP address from an instance to another one +by adding an allowed-address pair associated with an instance port. +It relies on attributes given by openstack-info resource agent (openstack_ports, openstack_id attributes). +The attribute called "openstack_virtual_ip" is updated. +</longdesc> +<shortdesc lang="en">Move a virtual IP</shortdesc> + +<parameters> +<parameter name="openstackcli"> +<longdesc lang="en"> +Path to command line tools for openstack. +</longdesc> +<shortdesc lang="en">Path to Openstack CLI tool</shortdesc> +<content type="string" default="${OCF_RESKEY_openstackcli_default}" /> +</parameter> + +<parameter name="openrc" required="1"> +<longdesc lang="en"> +Valid Openstack credentials as openrc file from api_access/openrc. +</longdesc> +<shortdesc lang="en">openrc file</shortdesc> +<content type="string" /> +</parameter> + +<parameter name="ip" required="1"> +<longdesc lang="en"> +Virtual IP Address. +</longdesc> +<shortdesc lang="en">IP Address</shortdesc> +<content type="string" /> +</parameter> + +<parameter name="subnet_id" required="1"> +<longdesc lang="en"> +Subnet Identifier to use to attach the address. +</longdesc> +<shortdesc lang="en">Subnet ID</shortdesc> +<content type="string" /> +</parameter> + +</parameters> + +<actions> +<action name="start" timeout="180s" /> +<action name="stop" timeout="180s" /> +<action name="monitor" depth="0" timeout="30s" interval="60s" /> +<action name="validate-all" timeout="5s" /> +<action name="meta-data" timeout="5s" /> +</actions> +</resource-agent> +END +} + +osvip_port_id() { + # Get port_id from subnet_id + node_port_ids=$(${HA_SBIN_DIR}/attrd_updater --query -n openstack_ports -N $(crm_node -n) \ + | awk '{gsub("value=","") ; gsub("\"","") ; print $NF}') + + node_port_id=$(echo $node_port_ids \ + | tr ',' '\n' \ + | awk -F: "/$OCF_RESKEY_subnet_id/ {print \$2}") + + echo ${node_port_id} +} + +osvip_validate() { + check_binary "$OCF_RESKEY_openstackcli" + + if [ -z "$OCF_RESKEY_openrc" ]; then + ocf_exit_reason "openrc parameter not set" + return $OCF_ERR_CONFIGURED + fi + + if [ ! -f "$OCF_RESKEY_openrc" ] ; then + ocf_exit_reason "openrc file not found" + return $OCF_ERR_CONFIGURED + fi + + . $OCF_RESKEY_openrc + + ${HA_SBIN_DIR}/attrd_updater --query -n openstack_ports -N $(crm_node -n) > /dev/null 2>&1 + if [ $? -ne 0 ] ; then + ocf_log warn "attr_updater failed to get openstack_ports attribute of node $OCF_RESOURCE_INSTANCE" + return $OCF_ERR_GENERIC + fi + + return $OCF_SUCCESS +} + +osvip_monitor() { + local result + + node_port_id=$(osvip_port_id) + + result=$($OCF_RESKEY_openstackcli port show \ + --format value \ + --column allowed_address_pairs \ + ${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 + fi + + ${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -D -S state -n openstack_virtual_ip + ocf_log warn "$OCF_RESKEY_ip is not attached to any fixed address" + return $OCF_NOT_RUNNING +} + +osvip_stop() { + node_port_id=$(osvip_port_id) + + ocf_log info "Bringing down IP address $OCF_RESKEY_ip" + + osvip_monitor + if [ $? = $OCF_NOT_RUNNING ]; then + ocf_log info "Address $OCF_RESKEY_ip already down" + return $OCF_SUCCESS + fi + + mac_address=$($OCF_RESKEY_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}$" + 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 \ + --allowed-address \ + ip-address=$OCF_RESKEY_ip,mac-address=${mac_address} \ + $node_port_id; then + return $OCF_ERR_GENERIC + fi + + osvip_monitor + if [ $? != $OCF_NOT_RUNNING ]; then + ocf_log error "Couldn't unset IP address $OCF_RESKEY_ip." + return $OCF_ERR_GENERIC + fi + + ocf_log info "Successfully brought down $OCF_RESKEY_ip" + return $OCF_SUCCESS +} + +osvip_start() { + node_port_id=$(osvip_port_id) + + osvip_monitor + if [ $? = $OCF_SUCCESS ]; then + ocf_log info "$OCF_RESKEY_ip already started" + return $OCF_SUCCESS + fi + + ocf_log info "Moving IP address $OCF_RESKEY_ip to port ID $node_port_id" + + $OCF_RESKEY_openstackcli port set \ + --allowed-address ip-address=$OCF_RESKEY_ip \ + $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 + fi + + osvip_monitor + if [ $? != $OCF_SUCCESS ]; then + ocf_log error "$OCF_RESKEY_ip Cannot be set to port $node_port_id" + return $OCF_ERR_GENERIC + fi + + ocf_log info "Successfully brought up $OCF_RESKEY_ip" + return $OCF_SUCCESS +} + +############################################################################### +# +# MAIN +# +############################################################################### + +case $__OCF_ACTION in + meta-data) + metadata + exit $OCF_SUCCESS + ;; + usage|help) + echo $USAGE + exit $OCF_SUCCESS + ;; +esac + +if ! ocf_is_root; then + ocf_log err "You must be root for $__OCF_ACTION operation." + exit $OCF_ERR_PERM +fi + +case $__OCF_ACTION in + start) + osvip_validate || exit $? + osvip_start;; + stop) + osvip_validate || exit $? + osvip_stop;; + monitor) + osvip_validate || exit $? + osvip_monitor;; + validate-all) + osvip_validate + ;; + *) + echo $USAGE + exit $OCF_ERR_UNIMPLEMENTED + ;; +esac + +exit $?