Merge "Detect active/standby switch"
This commit is contained in:
commit
2c100e5f3c
|
@ -18,6 +18,9 @@ SYSINV_CONF_DEFAULT_FILE = 'sysinv.conf.default'
|
|||
SYSINV_CONF_DEFAULT_PATH = os.path.join(SYSINV_CONFIG_PATH,
|
||||
SYSINV_CONF_DEFAULT_FILE)
|
||||
|
||||
SYSINV_CONDUCTOR_ACTIVE_PATH = os.path.join(SYSINV_CONFIG_PATH,
|
||||
'.sysinv_conductor_active')
|
||||
|
||||
HTTPS_CONFIG_REQUIRED = os.path.join(tsc.CONFIG_PATH, '.https_config_required')
|
||||
ADMIN_ENDPOINT_CONFIG_REQUIRED = os.path.join(tsc.CONFIG_PATH, '.admin_endpoint_config_required')
|
||||
|
||||
|
@ -1624,6 +1627,7 @@ APP_EVALUATE_REAPPLY_TYPE_HOST_FORCE_SWACT = FORCE_SWACT_ACTION
|
|||
APP_EVALUATE_REAPPLY_TYPE_RUNTIME_APPLY_PUPPET = 'runtime-apply-puppet'
|
||||
APP_EVALUATE_REAPPLY_HOST_AVAILABILITY = 'host-availability-updated'
|
||||
APP_EVALUATE_REAPPLY_TYPE_SYSTEM_MODIFY = 'system-modify'
|
||||
APP_EVALUATE_REAPPLY_TYPE_DETECTED_SWACT = 'detected-swact'
|
||||
|
||||
APP_EVALUATE_REAPPLY_TRIGGER_TO_METADATA_MAP = {
|
||||
UNLOCK_ACTION:
|
||||
|
@ -1638,6 +1642,8 @@ APP_EVALUATE_REAPPLY_TRIGGER_TO_METADATA_MAP = {
|
|||
APP_EVALUATE_REAPPLY_TYPE_HOST_SWACT,
|
||||
FORCE_SWACT_ACTION:
|
||||
APP_EVALUATE_REAPPLY_TYPE_HOST_FORCE_SWACT,
|
||||
APP_EVALUATE_REAPPLY_TYPE_DETECTED_SWACT:
|
||||
APP_EVALUATE_REAPPLY_TYPE_DETECTED_SWACT,
|
||||
APP_EVALUATE_REAPPLY_TYPE_RUNTIME_APPLY_PUPPET:
|
||||
APP_EVALUATE_REAPPLY_TYPE_RUNTIME_APPLY_PUPPET,
|
||||
APP_EVALUATE_REAPPLY_HOST_AVAILABILITY:
|
||||
|
|
|
@ -220,6 +220,9 @@ class ConductorManager(service.PeriodicService):
|
|||
# track deferred runtime config which need to be applied
|
||||
self._host_deferred_runtime_config = []
|
||||
|
||||
# Guard for a function that should run only once per conductor start
|
||||
self._do_detect_swact = True
|
||||
|
||||
# Guard for a function that should run only once per conductor start
|
||||
self._has_loaded_missing_apps_metadata = False
|
||||
|
||||
|
@ -5799,6 +5802,53 @@ class ConductorManager(service.PeriodicService):
|
|||
else:
|
||||
return True
|
||||
|
||||
def _detect_swact_once(self, context):
|
||||
""" Detect that a swact occurred to trigger a reapply evaluation
|
||||
"""
|
||||
# Detection may be done only once per conductor restart
|
||||
if not self._do_detect_swact:
|
||||
return
|
||||
|
||||
# No meaning on AIO-SX
|
||||
if cutils.is_aio_simplex_system(self.dbapi):
|
||||
self._do_detect_swact = False
|
||||
return
|
||||
|
||||
new_active = cutils.get_local_controller_hostname()
|
||||
|
||||
# Define file
|
||||
file = constants.SYSINV_CONDUCTOR_ACTIVE_PATH
|
||||
|
||||
# Read file
|
||||
if os.path.exists(file):
|
||||
with open(file, 'r') as reader:
|
||||
stored = reader.read()
|
||||
|
||||
# Difference detected
|
||||
if stored != new_active:
|
||||
LOG.info("Detected swact from {} to {}"
|
||||
"".format(stored, new_active))
|
||||
|
||||
# Save the new active
|
||||
with open(file, 'w') as writer:
|
||||
writer.write(new_active)
|
||||
|
||||
# Trigger reapply evaluation
|
||||
self.evaluate_apps_reapply(
|
||||
context,
|
||||
trigger={'type': constants.APP_EVALUATE_REAPPLY_TYPE_DETECTED_SWACT})
|
||||
|
||||
else:
|
||||
LOG.info("Initial save active controller {}"
|
||||
"".format(new_active))
|
||||
|
||||
# Save the new active
|
||||
with open(file, 'w') as writer:
|
||||
writer.write(new_active)
|
||||
|
||||
# No need to detect again until conductor restart
|
||||
self._do_detect_swact = False
|
||||
|
||||
@periodic_task.periodic_task(spacing=CONF.conductor.audit_interval,
|
||||
run_immediately=True)
|
||||
def _k8s_application_audit(self, context):
|
||||
|
@ -5855,6 +5905,9 @@ class ConductorManager(service.PeriodicService):
|
|||
if not self._has_loaded_missing_apps_metadata:
|
||||
self._load_metadata_of_missing_apps()
|
||||
|
||||
# Detect swact
|
||||
self._detect_swact_once(context)
|
||||
|
||||
# cache a database query
|
||||
app_statuses = {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue