From 1f6d4d33b5543c488997febd1619c05589c505a1 Mon Sep 17 00:00:00 2001 From: badrogger Date: Thu, 13 Jun 2024 17:47:16 +0000 Subject: [PATCH] Add no btrfs build --- node_cli/configs/env.py | 3 ++- node_cli/operations/base.py | 12 ++++++++++-- node_cli/operations/volume.py | 33 +++++++++++++++++---------------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/node_cli/configs/env.py b/node_cli/configs/env.py index 7b6bf116..d22487cf 100644 --- a/node_cli/configs/env.py +++ b/node_cli/configs/env.py @@ -45,7 +45,8 @@ 'DEFAULT_GAS_PRICE_WEI': '', 'SKIP_DOCKER_CONFIG': '', 'ENFORCE_BTRFS': '', - 'SKIP_DOCKER_CLEANUP': '' + 'SKIP_DOCKER_CLEANUP': '', + 'NO_BTRFS': '' } diff --git a/node_cli/operations/base.py b/node_cli/operations/base.py index 557d1632..a9cfad5d 100644 --- a/node_cli/operations/base.py +++ b/node_cli/operations/base.py @@ -211,9 +211,13 @@ def init_sync( download_contracts(env) generate_nginx_config() + no_btrfs = env.get('NO_BTRFS') == 'True' + enforce_btrfs = env.get('ENFORCE_BTRFS') == 'True' + prepare_block_device( env['DISK_MOUNTPOINT'], - force=env['ENFORCE_BTRFS'] == 'True' + force=enforce_btrfs, + btrfs_enabled=no_btrfs ) update_meta( @@ -247,9 +251,13 @@ def update_sync(env_filepath: str, env: Dict) -> bool: backup_old_contracts() download_contracts(env) + no_btrfs = env.get('NO_BTRFS') == 'True' + enforce_btrfs = env.get('ENFORCE_BTRFS') == 'True' + prepare_block_device( env['DISK_MOUNTPOINT'], - force=env['ENFORCE_BTRFS'] == 'True' + force=enforce_btrfs, + btrfs_enabled=no_btrfs ) generate_nginx_config() diff --git a/node_cli/operations/volume.py b/node_cli/operations/volume.py index b6de918a..40cb4bf2 100644 --- a/node_cli/operations/volume.py +++ b/node_cli/operations/volume.py @@ -131,22 +131,23 @@ def mount_device(block_device, mountpoint): run_cmd(['mount', block_device, mountpoint]) -def prepare_block_device(block_device, force=False): - filesystem = None - try: - filesystem = get_block_device_filesystem(block_device) - except Exception as e: - logger.info('Cannot get filesystem type %s', e) - logger.debug('Cannot get filesystem type', exc_info=True) - if not force: - raise - - if filesystem == 'btrfs': - logger.info('%s already formatted as btrfs', block_device) - ensure_btrfs_for_all_space(block_device) - else: - logger.info('%s contains %s filesystem', block_device, filesystem) - format_as_btrfs(block_device) +def prepare_block_device(block_device, force=False, btrfs_enabled=True): + if btrfs_enabled: + filesystem = None + try: + filesystem = get_block_device_filesystem(block_device) + except Exception as e: + logger.info('Cannot get filesystem type %s', e) + logger.debug('Cannot get filesystem type', exc_info=True) + if not force: + raise + + if filesystem == 'btrfs': + logger.info('%s already formatted as btrfs', block_device) + ensure_btrfs_for_all_space(block_device) + else: + logger.info('%s contains %s filesystem', block_device, filesystem) + format_as_btrfs(block_device) mount_device(block_device, SCHAINS_MNT_DIR_SYNC)