setup and so-verify/so-status interop

This commit is contained in:
Jason Ertel
2023-03-06 18:37:37 -05:00
parent 1998c66073
commit f77068f73f
3 changed files with 32 additions and 8 deletions

View File

@@ -24,11 +24,13 @@ def showUsage(options, args):
print(' -h - Prints this usage information') print(' -h - Prints this usage information')
print(' -q - Suppress output; useful for automation of exit code value') print(' -q - Suppress output; useful for automation of exit code value')
print(' -j - Output in JSON format') print(' -j - Output in JSON format')
print(' -i - Consider the installation outcome regardless of whether the system appears healthy')
print('') print('')
print(' Exit codes:') print(' Exit codes:')
print(' 0 - Success, system appears to be running correctly') print(' 0 - Success, system appears to be running correctly')
print(' 1 - Error, one or more subsystems are not running') print(' 1 - Error, one or more subsystems are not running')
print(' 2 - System is starting') print(' 2 - System is starting')
print(' 3 - System installation encountered errors')
print(' 99 - Installation in progress') print(' 99 - Installation in progress')
sys.exit(1) sys.exit(1)
@@ -38,6 +40,12 @@ def fail(msg):
sys.exit(1) sys.exit(1)
def check_installation_status(options, console):
if "-i" in options and os.path.isfile('/root/failure'):
return 3
return 0
def check_system_status(options, console): def check_system_status(options, console):
code = 0 code = 0
highstate_end_time = 0 highstate_end_time = 0
@@ -64,6 +72,8 @@ def output(options, console, code, data):
elif "-q" not in options: elif "-q" not in options:
if code == 2: if code == 2:
console.print(" [bold yellow]:hourglass: [bold white]System appears to be starting. No highstate has completed since the system was restarted.") console.print(" [bold yellow]:hourglass: [bold white]System appears to be starting. No highstate has completed since the system was restarted.")
if code == 3:
console.print(" [bold red]:exclamation: [bold white]Installation encountered errors.")
elif code == 99: elif code == 99:
console.print(" [bold red]:exclamation: [bold white]Installation does not appear to be complete. A highstate has not fully completed.") console.print(" [bold red]:exclamation: [bold white]Installation does not appear to be complete. A highstate has not fully completed.")
else: else:
@@ -137,7 +147,9 @@ def check_container_status(options, console):
def check_status(options, console): def check_status(options, console):
container_list = [] container_list = []
code = check_system_status(options, console) code = check_installation_status(options, console)
if code == 0:
code = check_system_status(options, console)
if code == 0: if code == 0:
code, container_list = check_container_status(options, console) code, container_list = check_container_status(options, console)
output(options, console, code, container_list) output(options, console, code, container_list)
@@ -150,9 +162,8 @@ def main():
for option in args: for option in args:
if option.startswith("-"): if option.startswith("-"):
options.append(option) options.append(option)
args.remove(option)
if len(args) != 0 or "-h" in options: if "-h" in options or "--help" in options or "-?" in options:
showUsage(options, None) showUsage(options, None)
if os.environ["USER"] != "root": if os.environ["USER"] != "root":

View File

@@ -1774,6 +1774,10 @@ reinstall_init() {
local service_retry_count=20 local service_retry_count=20
# Disregard previous install outcomes
rm -f /root/failure
rm -f /root/success
{ {
# remove all of root's cronjobs # remove all of root's cronjobs
logCmd "crontab -r -u root" logCmd "crontab -r -u root"

View File

@@ -81,18 +81,27 @@ status_failed() {
main() { main() {
exit_code=0 exit_code=0
if log_has_errors; then if [ -f /root/success ]; then
echo "WARNING: Errors detected during setup" echo "Successfully completed setup a while ago"
elif [ -f /root/failure ]; then
echo "WARNING: Failed setup a while ago"
exit_code=1 exit_code=1
elif log_has_errors; then
echo "WARNING: Errors detected during setup"
exit_code=1
touch /root/failure
elif using_iso && cron_error_in_mail_spool; then elif using_iso && cron_error_in_mail_spool; then
echo "WARNING: Unexpected cron job output in mail spool" echo "WARNING: Unexpected cron job output in mail spool"
exit_code=1 exit_code=1
touch /root/failure
elif is_manager_node && status_failed; then elif is_manager_node && status_failed; then
echo "WARNING: Containers are not in a healthy state" echo "WARNING: Containers are not in a healthy state"
exit_code=1 exit_code=1
touch /root/failure
else else
echo "Successfully completed setup!" echo "Successfully completed setup!"
fi touch /root/success
fi
exit $exit_code exit $exit_code
} }