Exit if sge_qmaster host is not reachable

This commit is contained in:
Jeremy Gardais 2021-03-11 14:50:25 +01:00
parent b4220d218a
commit ba359c4f75
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
6 changed files with 222 additions and 0 deletions

View File

@ -151,6 +151,25 @@ state is: ${RED}${local_sge_queue_state:=/dev/null}${COLOR_DEBUG}."
return "${return_queue_enable}"
}
# }}}
is_sge_master_available() { # {{{
## Check with Netcat if SGE master (sge_qmaster) is reachable from this host.
### -z: Only scan for listening daemons, without sending any data to them.
### -w 10: Timeout the test after 10 seconds.
if nc -z -w 10 "${sge_master_uri}" "${sge_master_port}"; then
return_is_sge_master_available="0"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is reachable from this host."
else
return_is_sge_master_available="1"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is not reachable from this host."
fi
return "${return_is_sge_master_available}"
}
# }}}
is_any_queue_enable() { # {{{
@ -269,13 +288,32 @@ main() { # {{{
manage_args "${ARGS}"
## Define vars
sge_hostname="$(hostname -f)"
sge_queues_name="$(qhost -h "${sge_hostname:=/dev/null}" -q -xml \
| grep "queue name" \
| cut -d"'" -f2 )"
## If sge_master_uri wasn't defined (environment variable,…)
if [ -z "${sge_master_uri}" ]; then
## Use local host for sge_master_uri
sge_master_uri="physix-master.ipr.univ-rennes1.fr"
fi
## If sge_master_port wasn't defined (environment variable,…)
if [ -z "${sge_master_port}" ]; then
## Use local host for sge_master_port
sge_master_port="6444"
fi
maco_proc_pattern="(/opt/maco/bin/maco.autoupdate.sh)"
## If SGE Master is not reachable from this host {{{
### Exit
is_sge_master_available \
|| exit 0
## }}}
## If NO APT package upgrade is available
### Exit
is_apt_upgrade_absent \

View File

@ -70,6 +70,18 @@ define_vars() { # {{{
sge_hostname="$(hostname -f)"
fi
## If sge_master_uri wasn't defined (environment variable,…)
if [ -z "${sge_master_uri}" ]; then
## Use local host for sge_master_uri
sge_master_uri="physix-master.ipr.univ-rennes1.fr"
fi
## If sge_master_port wasn't defined (environment variable,…)
if [ -z "${sge_master_port}" ]; then
## Use local host for sge_master_port
sge_master_port="6444"
fi
## If EMPTY_ONLY_MODE wasn't defined (argument, environment variable,…)
if [ -z "${EMPTY_ONLY_MODE}" ]; then
### Set False by default
@ -101,6 +113,25 @@ SGE is not present on this host."
return "${return_is_sge_host}"
}
# }}}
is_sge_master_available() { # {{{
## Check with Netcat if SGE master (sge_qmaster) is reachable from this host.
### -z: Only scan for listening daemons, without sending any data to them.
### -w 10: Timeout the test after 10 seconds.
if nc -z -w 10 "${sge_master_uri}" "${sge_master_port}"; then
return_is_sge_master_available="0"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is reachable from this host."
else
return_is_sge_master_available="1"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is not reachable from this host."
fi
return "${return_is_sge_master_available}"
}
# }}}
is_apt_upgrade_absent() { # {{{
@ -179,6 +210,12 @@ main() { # {{{
## Define all vars
define_vars
## If SGE Master is not reachable from this host {{{
### Exit
is_sge_master_available \
|| exit 0
## }}}
## If NO APT package upgrade is available {{{
### Ensure to remove any temp file related to APT upgrades
### AND Exit

View File

@ -88,6 +88,25 @@ SGE is not present on this host."
return "${return_is_sge_host}"
}
# }}}
is_sge_master_available() { # {{{
## Check with Netcat if SGE master (sge_qmaster) is reachable from this host.
### -z: Only scan for listening daemons, without sending any data to them.
### -w 10: Timeout the test after 10 seconds.
if nc -z -w 10 "${sge_master_uri}" "${sge_master_port}"; then
return_is_sge_master_available="0"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is reachable from this host."
else
return_is_sge_master_available="1"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is not reachable from this host."
fi
return "${return_is_sge_master_available}"
}
# }}}
is_apt_upgrade_present() { # {{{
@ -274,6 +293,24 @@ main() { # {{{
maco_proc_pattern="(/opt/maco/bin/maco.autoupdate.sh)"
apt_proc_pattern="(aptitude.*full-upgrade|/usr/bin/dpkg.*--configure|dpkg-deb|/bin/sh /usr/lib/needrestart/dpkg-status)"
## If sge_master_uri wasn't defined (environment variable,…)
if [ -z "${sge_master_uri}" ]; then
## Use local host for sge_master_uri
sge_master_uri="physix-master.ipr.univ-rennes1.fr"
fi
## If sge_master_port wasn't defined (environment variable,…)
if [ -z "${sge_master_port}" ]; then
## Use local host for sge_master_port
sge_master_port="6444"
fi
## If SGE Master is not reachable from this host {{{
### Exit
is_sge_master_available \
|| exit 0
## }}}
## If APT package upgrade is available
### Exit (wait for APT upgrade to be applied first)
is_apt_upgrade_present \

View File

@ -124,6 +124,25 @@ Test var: ${1}."
return "${return_var_empty}"
}
# }}}
is_sge_master_available() { # {{{
## Check with Netcat if SGE master (sge_qmaster) is reachable from this host.
### -z: Only scan for listening daemons, without sending any data to them.
### -w 10: Timeout the test after 10 seconds.
if nc -z -w 10 "${sge_master_uri}" "${sge_master_port}"; then
return_is_sge_master_available="0"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is reachable from this host."
else
return_is_sge_master_available="1"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is not reachable from this host."
fi
return "${return_is_sge_master_available}"
}
# }}}
is_maco_urgent_upgrade_require() { # {{{
@ -234,6 +253,23 @@ Disable SGE queue."
# }}}
main() { # {{{
## If sge_master_uri wasn't defined (environment variable,…)
if [ -z "${sge_master_uri}" ]; then
## Use local host for sge_master_uri
sge_master_uri="physix-master.ipr.univ-rennes1.fr"
fi
## If sge_master_port wasn't defined (environment variable,…)
if [ -z "${sge_master_port}" ]; then
## Use local host for sge_master_port
sge_master_port="6444"
fi
## If SGE Master is not reachable from this host {{{
### Exit
is_sge_master_available \
|| exit 0
## }}}
## Get all Maco's versions (date)
readonly CURRENT_MACO_VERSION=$(< "${MACO_LOCAL_DIR}/maco-version.txt" awk -v FS=. '{ print $1 "-" $2 "-" $3 "T" $4 ":" $5 ":" $6 }' )
readonly LATEST_MACO_VERSION=$(< "${MACO_INSTALL_DIR}/maco-version.txt" awk -v FS=. '{ print $1 "-" $2 "-" $3 "T" $4 ":" $5 ":" $6 }' )

View File

@ -62,6 +62,18 @@ define_vars() { # {{{
sge_hostname="$(hostname -f)"
fi
## If sge_master_uri wasn't defined (environment variable,…)
if [ -z "${sge_master_uri}" ]; then
## Use local host for sge_master_uri
sge_master_uri="physix-master.ipr.univ-rennes1.fr"
fi
## If sge_master_port wasn't defined (environment variable,…)
if [ -z "${sge_master_port}" ]; then
## Use local host for sge_master_port
sge_master_port="6444"
fi
## If the host to manage is the current one
if is_current_host "${sge_hostname}" ; then
debug_message "define_vars \
@ -82,6 +94,25 @@ ${sge_hostname} is not the current host."
| cut -d"'" -f2 \
| tr -s '\n' ' ' )"
}
# }}}
is_sge_master_available() { # {{{
## Check with Netcat if SGE master (sge_qmaster) is reachable from this host.
### -z: Only scan for listening daemons, without sending any data to them.
### -w 10: Timeout the test after 10 seconds.
if nc -z -w 10 "${sge_master_uri}" "${sge_master_port}"; then
return_is_sge_master_available="0"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is reachable from this host."
else
return_is_sge_master_available="1"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is not reachable from this host."
fi
return "${return_is_sge_master_available}"
}
# }}}
is_current_host() { # {{{
@ -218,6 +249,12 @@ main() { # {{{
## Define all vars according the selected options
define_vars
## If SGE Master is not reachable from this host {{{
### Exit
is_sge_master_available \
|| exit 0
## }}}
## Simple debug message with color to valid current variables
debug_message "main Try to manage \
SGE queue(s): ${RED}${sge_queues_name_print:=/dev/null}${COLOR_DEBUG}\

View File

@ -97,6 +97,18 @@ define_vars() { # {{{
sge_hostname="$(hostname -f)"
fi
## If sge_master_uri wasn't defined (environment variable,…)
if [ -z "${sge_master_uri}" ]; then
## Use local host for sge_master_uri
sge_master_uri="physix-master.ipr.univ-rennes1.fr"
fi
## If sge_master_port wasn't defined (environment variable,…)
if [ -z "${sge_master_port}" ]; then
## Use local host for sge_master_port
sge_master_port="6444"
fi
## If the host to manage is the current one
if is_current_host "${sge_hostname}" ; then
debug_message "define_vars \
@ -162,6 +174,25 @@ SGE is not present on this host."
return "${return_is_sge_host}"
}
# }}}
is_sge_master_available() { # {{{
## Check with Netcat if SGE master (sge_qmaster) is reachable from this host.
### -z: Only scan for listening daemons, without sending any data to them.
### -w 10: Timeout the test after 10 seconds.
if nc -z -w 10 "${sge_master_uri}" "${sge_master_port}"; then
return_is_sge_master_available="0"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is reachable from this host."
else
return_is_sge_master_available="1"
debug_message "is_sge_master_available \
SGE Master (${sge_master_uri}:${sge_master_port}) is not reachable from this host."
fi
return "${return_is_sge_master_available}"
}
# }}}
is_current_host() { # {{{
@ -450,6 +481,12 @@ main() { # {{{
## Define all vars according the selected options
define_vars
## If SGE Master is not reachable from this host {{{
### Exit
is_sge_master_available \
|| exit 0
## }}}
## If we need to watch for upgrades
if [ "${CHECK_UPGRADE}" -eq "0" ]; then
## If APT package upgrade is available