Skip to content

Commit

Permalink
Gracefully start apps when passive becomes active
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Oct 1, 2024
1 parent 9c656a4 commit 2b93392
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/middlewared/middlewared/plugins/failover_/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ def vrrp_master(self, job, fobj, ifname, event):
self.run_call('kmip.initialize_keys')
logger.info('Done syncing encryption keys with KMIP server')

self.start_apps()

logger.info('Migrating interface information (if required)')
self.run_call('interface.persist_link_addresses')
logger.info('Done migrating interface information (if required)')
Expand Down Expand Up @@ -938,6 +940,30 @@ def vrrp_backup(self, job, fobj, ifname, event):

return self.FAILOVER_RESULT

def start_apps(self):
pool = self.run_call('docker.config')['pool']
if not pool:
logger.info('Skipping starting apps as they are not configured')
return

logger.info('Going to initialize apps plugin as %r pool is configured for apps', pool)
logger.info('Mounting relevant docker datasets')
try:
self.run_call('docker.fs_manage.mount')
except Exception:
logger.error('Failed to mount docker datasets', exc_info=True)
return
else:
logger.info('Mounted docker datasets successfully')

logger.info('Starting docker service')
try:
self.run_call('docker.state.start_service')
except Exception:
logger.error('Failed to start docker service', exc_info=True)
else:
logger.info('Docker service started successfully')

def stop_apps(self):
if not self.middleware.call_sync('docker.config')['dataset']:
return
Expand Down

0 comments on commit 2b93392

Please sign in to comment.