From 0813dc231162687796e4fd6405de2b7588e5cb7f Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Tue, 5 Mar 2024 07:22:55 -0800 Subject: [PATCH] Fix temporary mount of system dataset during move When moving the system dataset to a new pool we first temporarily mount the system dataset in the middleware run directory before running rsync to copy all of the data to the new path. During a recent refactor of the system dataset heirarchy the nuance of the temporary mount point was lost. --- src/middlewared/middlewared/plugins/sysdataset.py | 6 ++---- tests/api2/test_006_pool_and_sysds.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/middlewared/middlewared/plugins/sysdataset.py b/src/middlewared/middlewared/plugins/sysdataset.py index 49d025775e7a4..f4409df1df1d1 100644 --- a/src/middlewared/middlewared/plugins/sysdataset.py +++ b/src/middlewared/middlewared/plugins/sysdataset.py @@ -537,10 +537,8 @@ def __mount(self, pool, uuid, path=SYSDATASET_PATH): mounted = False for ds_config in get_system_dataset_spec(pool, uuid): dataset, name = ds_config['name'], os.path.basename(ds_config['name']) - if desired_mountpoint := ds_config.get('mountpoint'): - mountpoint = desired_mountpoint - else: - mountpoint = f'{path}/{name}' + + mountpoint = ds_config.get('mountpoint', f'{SYSDATASET_PATH}/{name}').replace(SYSDATASET_PATH, path) if os.path.ismount(mountpoint): continue diff --git a/tests/api2/test_006_pool_and_sysds.py b/tests/api2/test_006_pool_and_sysds.py index 1daa5efae6635..6ae688243fb75 100644 --- a/tests/api2/test_006_pool_and_sysds.py +++ b/tests/api2/test_006_pool_and_sysds.py @@ -80,6 +80,16 @@ def test_002_create_permanent_zpool(request, ws_client): assert results['pool'] == pool_name assert results['basename'] == f'{pool_name}/.system' + try: + sysdataset_update = ws_client.call('core.get_jobs', [ + ['method', '=', 'systemdataset.update'] + ], {'order_by': ['-id'], 'get': True}) + except Exception: + fail('Failed to get status of systemdataset update') + + if sysdataset_update['state'] != 'SUCCESS': + fail(f'System dataset move failed: {sysdataset_update["error"]}') + @pytest.mark.dependency(name='POOL_FUNCTIONALITY1') def test_003_verify_unused_disk_and_sysds_functionality_on_2nd_pool(ws_client, pool_data):