Skip to content

Commit

Permalink
Properly wait for catalog to sync on docker.update
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Sep 25, 2024
1 parent e760c7d commit 100f7e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/middlewared/middlewared/plugins/docker/fs_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def common_func(self, mount):
await self.middleware.call('zfs.dataset.mount', docker_ds, {'recursive': True, 'force_mount': True})
else:
await self.middleware.call('zfs.dataset.umount', docker_ds, {'force': True})
await self.middleware.call('catalog.sync')
return await self.middleware.call('catalog.sync')
except Exception as e:
await self.middleware.call(
'docker.state.set_status', Status.FAILED.value,
Expand All @@ -27,10 +27,10 @@ async def common_func(self, mount):
raise

async def mount(self):
await self.common_func(True)
return await self.common_func(True)

async def umount(self):
await self.common_func(False)
return await self.common_func(False)

async def ix_apps_is_mounted(self, dataset_to_check=None):
"""
Expand Down
4 changes: 3 additions & 1 deletion src/middlewared/middlewared/plugins/docker/state_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ async def status_change(self):

await self.create_update_docker_datasets(config['dataset'])
# Docker dataset would not be mounted at this point, so we will explicitly mount them now
await self.middleware.call('docker.fs_manage.mount')
catalog_sync_job = await self.middleware.call('docker.fs_manage.mount')
if catalog_sync_job:
await catalog_sync_job.wait()
await self.middleware.call('docker.state.start_service')
self.middleware.create_task(self.middleware.call('docker.state.periodic_check'))

Expand Down
6 changes: 5 additions & 1 deletion src/middlewared/middlewared/plugins/docker/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,19 @@ async def do_update(self, job, data):
except Exception as e:
raise CallError(f'Failed to stop docker service: {e}')

catalog_sync_job = None
try:
await self.middleware.call('docker.fs_manage.umount')
catalog_sync_job = await self.middleware.call('docker.fs_manage.umount')
except CallError as e:
# We handle this specially, if for whatever reason ix-apps dataset is not there,
# we don't make it fatal to change pools etc - however if some dataset other then
# boot pool is mounted at ix-apps dir, then we will error out as it's a problem
# and needs to be fixed before we can proceed
if e.errno != errno.ENOENT or await self.middleware.call('docker.fs_manage.ix_apps_is_mounted'):
raise
finally:
if catalog_sync_job:
await catalog_sync_job.wait()

await self.middleware.call('docker.state.set_status', Status.UNCONFIGURED.value)

Expand Down

0 comments on commit 100f7e5

Please sign in to comment.