Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions node_cli/cli/passive_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ def _init_passive(
expose_value=False,
prompt='Are you sure you want to update SKALE node software?',
)
@click.option('--unsafe', 'unsafe_ok', help='Allow unsafe update', hidden=True, is_flag=True)
@click.argument('env_file')
@streamed_cmd
def _update_passive(env_file, unsafe_ok):
def _update_passive(env_file):
update_passive(env_file)


Expand Down
1 change: 0 additions & 1 deletion node_cli/configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
SGX_CERTIFICATES_DIR_NAME = 'sgx_certs'

COMPOSE_PATH = os.path.join(CONTAINER_CONFIG_PATH, 'docker-compose.yml')
PASSIVE_COMPOSE_PATH = os.path.join(CONTAINER_CONFIG_PATH, 'docker-compose-passive.yml')
FAIR_COMPOSE_PATH = os.path.join(CONTAINER_CONFIG_PATH, 'docker-compose-fair.yml')
STATIC_PARAMS_FILEPATH = os.path.join(CONTAINER_CONFIG_PATH, 'static_params.yaml')
FAIR_STATIC_PARAMS_FILEPATH = os.path.join(CONTAINER_CONFIG_PATH, 'fair_static_params.yaml')
Expand Down
1 change: 0 additions & 1 deletion node_cli/core/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ def docker_compose(self) -> CheckResult:
)
output = v_cmd_result.stdout.decode('utf-8').rstrip()
if v_cmd_result.returncode != 0:
info = f'Checking docker compose version failed with: {output}'
return self._failed(name=name, info=output)

actual_version = output.split(',')[0].split()[-1].strip()
Expand Down
3 changes: 2 additions & 1 deletion node_cli/core/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import logging
import os
from shutil import copyfile
from shutil import copyfile, chown
from urllib.parse import urlparse

from node_cli.core.resources import update_resource_allocation
Expand Down Expand Up @@ -94,6 +94,7 @@ def prepare_host(env_filepath: str, env_type: str, allocation: bool = False) ->
try:
logger.info('Preparing host started')
make_dirs()
chown(REDIS_DATA_PATH, user=999, group=1000)
save_env_params(env_filepath)

if allocation:
Expand Down
2 changes: 1 addition & 1 deletion node_cli/core/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create_logs_dump(path, filter_container=None):
if filter_container:
containers = get_containers(filter_container)
else:
containers = get_containers('skale')
containers = get_containers('sk_*')

for container in containers:
log_filepath = os.path.join(containers_logs_path, f'{container.name}.log')
Expand Down
2 changes: 0 additions & 2 deletions node_cli/core/nftables.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ def add_loopback_rule(self, chain) -> None:

def get_base_ruleset(self) -> str:
self.nft.set_json_output(False)
output = ''
try:
cmd = f'list chain {self.family} {self.table} {self.chain}'
rc, output, error = self.nft.cmd(cmd)
Expand All @@ -539,7 +538,6 @@ def get_base_ruleset(self) -> str:
finally:
self.nft.set_json_output(True)

return output

def setup_firewall(self, enable_monitoring: bool = False) -> None:
"""Setup firewall rules."""
Expand Down
4 changes: 2 additions & 2 deletions node_cli/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
logger = logging.getLogger(__name__)
TEXTS = safe_load_texts()

BASE_CONTAINERS_AMOUNT = 5
BLUEPRINT_NAME = 'node'


Expand Down Expand Up @@ -207,7 +206,7 @@ def init_passive(

@check_inited
@check_user
def update_passive(env_filepath: str, unsafe_ok: bool = False) -> None:
def update_passive(env_filepath: str) -> None:
logger.info('Node update started')
prev_version = CliMetaManager().get_meta_info().version
if (__version__ == 'test' or __version__.startswith('2.6')) and prev_version == '2.5.0':
Expand Down Expand Up @@ -263,6 +262,7 @@ def compose_node_env(
else:
user_config = get_validated_user_config(
node_type=node_type,
node_mode=node_mode,
env_filepath=INIT_ENV_FILEPATH,
is_fair_boot=is_fair_boot,
skip_user_conf_validation=skip_user_conf_validation,
Expand Down
7 changes: 2 additions & 5 deletions node_cli/core/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,10 @@ def get_cpu_alloc(common_config: Dict) -> ResourceAlloc:
cpu_proportions = common_config['schain']['cpu']
schain_max_cpu_shares = int(cpu_proportions['skaled'] * MAX_CPU_SHARES)
ima_max_cpu_shares = int(cpu_proportions['ima'] * MAX_CPU_SHARES)
return (ResourceAlloc(schain_max_cpu_shares), ResourceAlloc(ima_max_cpu_shares))
return ResourceAlloc(schain_max_cpu_shares), ResourceAlloc(ima_max_cpu_shares)


def verify_disk_size(
disk_device: str,
env_configs: dict,
) -> Dict:
def verify_disk_size(disk_device: str, env_configs: dict):
disk_size = get_disk_size(disk_device)
env_disk_size = env_configs['server']['disk']
check_disk_size(disk_size, env_disk_size)
Expand Down
1 change: 0 additions & 1 deletion node_cli/fair/staking.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def get_exit_requests(raw: bool = False) -> None:
exit_requests = payload.get('exit_requests')
if not isinstance(exit_requests, list):
error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
return
if raw:
print(json.dumps(exit_requests, indent=2))
return
Expand Down
4 changes: 2 additions & 2 deletions node_cli/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
update as update_op,
init as init_op,
init_passive as init_passive_op,
init_fair_boot as init_fair_boot_op,
update_fair_boot as update_fair_boot_op,
update_passive as update_passive_op,
turn_off as turn_off_op,
turn_on as turn_on_op,
Expand All @@ -31,7 +29,9 @@
configure_nftables,
)
from node_cli.operations.fair import ( # noqa
init_fair_boot as init_fair_boot_op,
init as init_fair_op,
update_fair_boot as update_fair_boot_op,
update as update_fair_op,
FairUpdateType,
restore as restore_fair_op,
Expand Down
96 changes: 21 additions & 75 deletions node_cli/operations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,48 +159,6 @@ def update(env_filepath: str, env: Dict, node_mode: NodeMode) -> bool:
return True


@checked_host
def update_fair_boot(env_filepath: str, env: Dict, node_mode: NodeMode = NodeMode.ACTIVE) -> bool:
compose_rm(node_type=NodeType.FAIR, node_mode=node_mode, env=env)
remove_dynamic_containers()
cleanup_volume_artifacts(env['BLOCK_DEVICE'])

sync_skale_node()
ensure_btrfs_kernel_module_autoloaded()

if env.get('SKIP_DOCKER_CONFIG') != 'True':
configure_docker()

enable_monitoring = str_to_bool(env.get('MONITORING_CONTAINERS', 'False'))
configure_nftables(enable_monitoring=enable_monitoring)

generate_nginx_config()
prepare_block_device(env['BLOCK_DEVICE'], force=env['ENFORCE_BTRFS'] == 'True')

prepare_host(env_filepath, env['ENV_TYPE'])

meta_manager = FairCliMetaManager()
current_stream = meta_manager.get_meta_info().config_stream
skip_cleanup = env.get('SKIP_DOCKER_CLEANUP') == 'True'
if not skip_cleanup and current_stream != env['NODE_VERSION']:
logger.info(
'Stream version was changed from %s to %s',
current_stream,
env['NODE_VERSION'],
)
docker_cleanup()

meta_manager.update_meta(
VERSION,
env['NODE_VERSION'],
distro.id(),
distro.version(),
)
update_images(env=env, node_type=NodeType.FAIR, node_mode=NodeMode.ACTIVE)
compose_up(env=env, node_type=NodeType.FAIR, node_mode=NodeMode.ACTIVE, is_fair_boot=True)
return True


@checked_host
def init(env_filepath: str, env: dict, node_mode: NodeMode) -> None:
sync_skale_node()
Expand Down Expand Up @@ -236,39 +194,6 @@ def init(env_filepath: str, env: dict, node_mode: NodeMode) -> None:
compose_up(env=env, node_type=NodeType.SKALE, node_mode=node_mode)


@checked_host
def init_fair_boot(env_filepath: str, env: dict, node_mode: NodeMode = NodeMode.ACTIVE) -> None:
sync_skale_node()
cleanup_volume_artifacts(env['BLOCK_DEVICE'])

ensure_btrfs_kernel_module_autoloaded()
if env.get('SKIP_DOCKER_CONFIG') != 'True':
configure_docker()

enable_monitoring = str_to_bool(env.get('MONITORING_CONTAINERS', 'False'))
configure_nftables(enable_monitoring=enable_monitoring)

prepare_host(env_filepath, env_type=env['ENV_TYPE'])
link_env_file()
mark_active_node()

configure_filebeat()
configure_flask()
generate_nginx_config()
prepare_block_device(env['BLOCK_DEVICE'], force=env['ENFORCE_BTRFS'] == 'True')

meta_manager = FairCliMetaManager()
meta_manager.update_meta(
VERSION,
env['NODE_VERSION'],
distro.id(),
distro.version(),
)
update_images(env=env, node_type=NodeType.FAIR, node_mode=NodeMode.ACTIVE)

compose_up(env=env, node_type=NodeType.FAIR, node_mode=NodeMode.ACTIVE, is_fair_boot=True)


def init_passive(
env_filepath: str,
env: dict,
Expand All @@ -291,6 +216,16 @@ def init_passive(
env_filepath,
env_type=env['ENV_TYPE'],
)
failed_checks = run_host_checks(
env['BLOCK_DEVICE'],
TYPE,
NodeMode.PASSIVE,
env['ENV_TYPE'],
CONTAINER_CONFIG_PATH,
check_type=CheckType.PREINSTALL
)
if failed_checks:
print_failed_requirements_checks(failed_checks)

set_passive_node_options(archive=archive, indexer=indexer)

Expand Down Expand Up @@ -339,6 +274,17 @@ def update_passive(env_filepath: str, env: Dict) -> bool:

prepare_host(env_filepath, env['ENV_TYPE'], allocation=True)

failed_checks = run_host_checks(
env['BLOCK_DEVICE'],
TYPE,
NodeMode.PASSIVE,
env['ENV_TYPE'],
CONTAINER_CONFIG_PATH,
check_type=CheckType.PREINSTALL
)
if failed_checks:
print_failed_requirements_checks(failed_checks)

meta_manager = CliMetaManager()
meta_manager.update_meta(
VERSION,
Expand Down
6 changes: 1 addition & 5 deletions node_cli/operations/docker_lvmpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
SCHAINS_MNT_DIR_REGULAR,
VOLUME_GROUP,
)
from node_cli.operations.volume import ensure_filestorage_mapping
from lvmpy.src.install import setup as setup_lvmpy

logger = logging.getLogger(__name__)
Expand All @@ -49,11 +50,6 @@ def update_docker_lvmpy_env(env):
return env


def ensure_filestorage_mapping(mapping_dir=FILESTORAGE_MAPPING):
if not os.path.isdir(FILESTORAGE_MAPPING):
os.makedirs(FILESTORAGE_MAPPING)


def sync_docker_lvmpy_repo(env):
if os.path.isdir(DOCKER_LVMPY_PATH):
shutil.rmtree(DOCKER_LVMPY_PATH)
Expand Down
35 changes: 34 additions & 1 deletion node_cli/operations/fair.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from node_cli.core.nginx import generate_nginx_config
from node_cli.core.schains import cleanup_no_lvm_datadir
from node_cli.core.static_config import get_fair_chain_name
from node_cli.core.node_options import set_passive_node_options, upsert_node_mode
from node_cli.core.node_options import mark_active_node, set_passive_node_options, upsert_node_mode
from node_cli.fair.record.chain_record import (
get_fair_chain_record,
migrate_chain_record,
Expand Down Expand Up @@ -80,6 +80,39 @@ class FairUpdateType(Enum):
FROM_BOOT = 'from_boot'


@checked_host
def init_fair_boot(env_filepath: str, env: dict) -> None:
sync_skale_node()
cleanup_volume_artifacts(env['BLOCK_DEVICE'])

ensure_btrfs_kernel_module_autoloaded()
if env.get('SKIP_DOCKER_CONFIG') != 'True':
configure_docker()

enable_monitoring = str_to_bool(env.get('MONITORING_CONTAINERS', 'False'))
configure_nftables(enable_monitoring=enable_monitoring)

prepare_host(env_filepath, env_type=env['ENV_TYPE'])
link_env_file()
mark_active_node()

configure_filebeat()
configure_flask()
generate_nginx_config()
prepare_block_device(env['BLOCK_DEVICE'], force=env['ENFORCE_BTRFS'] == 'True')

meta_manager = FairCliMetaManager()
meta_manager.update_meta(
VERSION,
env['NODE_VERSION'],
distro.id(),
distro.version(),
)
update_images(env=env, node_type=NodeType.FAIR, node_mode=NodeMode.ACTIVE)

compose_up(env=env, node_type=NodeType.FAIR, node_mode=NodeMode.ACTIVE, is_fair_boot=True)


@checked_host
def init(
env_filepath: str,
Expand Down
Loading