Use harder exits and add cleanup termination
This commit is contained in:
parent
7c36388c8f
commit
d48f58930b
|
@ -110,7 +110,7 @@ try:
|
||||||
pvcnoded_config_file = os.environ['PVCD_CONFIG_FILE']
|
pvcnoded_config_file = os.environ['PVCD_CONFIG_FILE']
|
||||||
except Exception:
|
except Exception:
|
||||||
print('ERROR: The "PVCD_CONFIG_FILE" environment variable must be set before starting pvcnoded.')
|
print('ERROR: The "PVCD_CONFIG_FILE" environment variable must be set before starting pvcnoded.')
|
||||||
exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
# Set local hostname and domain variables
|
# Set local hostname and domain variables
|
||||||
myfqdn = gethostname()
|
myfqdn = gethostname()
|
||||||
|
@ -142,7 +142,7 @@ def readConfig(pvcnoded_config_file, myhostname):
|
||||||
o_config = yaml.load(cfgfile, Loader=yaml.SafeLoader)
|
o_config = yaml.load(cfgfile, Loader=yaml.SafeLoader)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('ERROR: Failed to parse configuration file: {}'.format(e))
|
print('ERROR: Failed to parse configuration file: {}'.format(e))
|
||||||
exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
# Handle the basic config (hypervisor-only)
|
# Handle the basic config (hypervisor-only)
|
||||||
try:
|
try:
|
||||||
|
@ -179,7 +179,7 @@ def readConfig(pvcnoded_config_file, myhostname):
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('ERROR: Failed to load configuration: {}'.format(e))
|
print('ERROR: Failed to load configuration: {}'.format(e))
|
||||||
exit(1)
|
cleanup()
|
||||||
config = config_general
|
config = config_general
|
||||||
|
|
||||||
# Handle debugging config
|
# Handle debugging config
|
||||||
|
@ -236,7 +236,7 @@ def readConfig(pvcnoded_config_file, myhostname):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('ERROR: Failed to load configuration: {}'.format(e))
|
print('ERROR: Failed to load configuration: {}'.format(e))
|
||||||
exit(1)
|
cleanup()
|
||||||
config = {**config, **config_networking}
|
config = {**config, **config_networking}
|
||||||
|
|
||||||
# Create the by-id address entries
|
# Create the by-id address entries
|
||||||
|
@ -250,7 +250,7 @@ def readConfig(pvcnoded_config_file, myhostname):
|
||||||
network = ip_network(config[network_key])
|
network = ip_network(config[network_key])
|
||||||
except Exception:
|
except Exception:
|
||||||
print('ERROR: Network address {} for {} is not valid!'.format(config[network_key], network_key))
|
print('ERROR: Network address {} for {} is not valid!'.format(config[network_key], network_key))
|
||||||
exit(1)
|
cleanup()
|
||||||
|
|
||||||
# If we should be autoselected
|
# If we should be autoselected
|
||||||
if config[address_key] == 'by-id':
|
if config[address_key] == 'by-id':
|
||||||
|
@ -270,7 +270,7 @@ def readConfig(pvcnoded_config_file, myhostname):
|
||||||
raise
|
raise
|
||||||
except Exception:
|
except Exception:
|
||||||
print('ERROR: Floating address {} for {} is not valid!'.format(config[floating_key], floating_key))
|
print('ERROR: Floating address {} for {} is not valid!'.format(config[floating_key], floating_key))
|
||||||
exit(1)
|
cleanup()
|
||||||
|
|
||||||
# Handle the storage config
|
# Handle the storage config
|
||||||
if config['enable_storage']:
|
if config['enable_storage']:
|
||||||
|
@ -281,7 +281,7 @@ def readConfig(pvcnoded_config_file, myhostname):
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('ERROR: Failed to load configuration: {}'.format(e))
|
print('ERROR: Failed to load configuration: {}'.format(e))
|
||||||
exit(1)
|
cleanup()
|
||||||
config = {**config, **config_storage}
|
config = {**config, **config_storage}
|
||||||
|
|
||||||
# Handle an empty ipmi_hostname
|
# Handle an empty ipmi_hostname
|
||||||
|
@ -578,7 +578,7 @@ try:
|
||||||
zkhandler.connect(persistent=True)
|
zkhandler.connect(persistent=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.out('ERROR: Failed to connect to Zookeeper cluster: {}'.format(e), state='e')
|
logger.out('ERROR: Failed to connect to Zookeeper cluster: {}'.format(e), state='e')
|
||||||
exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
logger.out('Validating Zookeeper schema', state='i')
|
logger.out('Validating Zookeeper schema', state='i')
|
||||||
|
|
||||||
|
@ -871,7 +871,7 @@ if enable_hypervisor:
|
||||||
lv_conn.close()
|
lv_conn.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.out('ERROR: Failed to connect to Libvirt daemon: {}'.format(e), state='e')
|
logger.out('ERROR: Failed to connect to Libvirt daemon: {}'.format(e), state='e')
|
||||||
exit(1)
|
cleanup()
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# PHASE 7c - Ensure NFT is running on the local host
|
# PHASE 7c - Ensure NFT is running on the local host
|
||||||
|
|
Loading…
Reference in New Issue