Skip to content

Commit

Permalink
Merge pull request #687 from skalenetwork/develop
Browse files Browse the repository at this point in the history
New beta version
  • Loading branch information
dmytrotkk authored Dec 14, 2022
2 parents 7b69d2a + e1c3e93 commit c859197
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 134 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* @dmitry-tk @kladkogex @badrogger
* @dmytrotkk @kladkogex @badrogger
*.md @skalenetwork/docowners
2 changes: 1 addition & 1 deletion node_cli/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '2.1.3'
__version__ = '2.2.0'

if __name__ == "__main__":
print(__version__)
9 changes: 3 additions & 6 deletions node_cli/configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@
SGX_CERTIFICATES_DIR_NAME = 'sgx_certs'

COMPOSE_PATH = os.path.join(CONTAINER_CONFIG_PATH, 'docker-compose.yml')
FILESTORAGE_INFO_FILE = os.path.join(
CONTAINER_CONFIG_PATH, 'filestorage_info.json')
FILESTORAGE_ARTIFACTS_FILE = os.path.join(
NODE_DATA_PATH, 'filestorage_artifacts.json')
ENVIRONMENT_PARAMS_FILEPATH = os.path.join(
CONTAINER_CONFIG_PATH, 'environment_params.yaml')
FILESTORAGE_INFO_FILE = os.path.join(CONTAINER_CONFIG_PATH, 'filestorage_info.json')
FILESTORAGE_ARTIFACTS_FILE = os.path.join(NODE_DATA_PATH, 'filestorage_artifacts.json')
STATIC_PARAMS_FILEPATH = os.path.join(CONTAINER_CONFIG_PATH, 'static_params.yaml')
NGINX_TEMPLATE_FILEPATH = os.path.join(CONTAINER_CONFIG_PATH, 'nginx.conf.j2')
NGINX_CONFIG_FILEPATH = os.path.join(NODE_DATA_PATH, 'nginx.conf')

Expand Down
13 changes: 5 additions & 8 deletions node_cli/core/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
CONTAINER_CONFIG_PATH,
DOCKER_CONFIG_FILEPATH,
DOCKER_DAEMON_HOSTS,
REPORTS_PATH
REPORTS_PATH,
STATIC_PARAMS_FILEPATH
)
from node_cli.core.resources import get_disk_size
from node_cli.utils.helper import run_cmd, safe_mkdir
Expand All @@ -66,15 +67,11 @@
FuncList = List[Func]


def get_env_params(
def get_static_params(
env_type: str = 'mainnet',
config_path: str = CONTAINER_CONFIG_PATH
) -> Dict:
environment_params_path = os.path.join(
config_path,
'environment_params.yaml'
)
with open(environment_params_path) as requirements_file:
with open(STATIC_PARAMS_FILEPATH) as requirements_file:
ydata = yaml.load(requirements_file, Loader=yaml.Loader)
return ydata['envs'][env_type]

Expand Down Expand Up @@ -526,7 +523,7 @@ def run_checks(
check_type: CheckType = CheckType.ALL
) -> ResultList:
logger.info('Executing checks. Type: %s', check_type)
requirements = get_env_params(env_type, config_path)
requirements = get_static_params(env_type, config_path)
checkers = get_all_checkers(disk, requirements)
checks = get_checks(checkers, check_type)
results = [check() for check in checks]
Expand Down
8 changes: 2 additions & 6 deletions node_cli/core/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
from node_cli.utils.helper import (
write_json, read_json, run_cmd, extract_env_params, safe_load_yml
)
from node_cli.configs import (
ALLOCATION_FILEPATH, ENVIRONMENT_PARAMS_FILEPATH,
SNAPSHOTS_SHARED_VOLUME
)
from node_cli.configs import ALLOCATION_FILEPATH, STATIC_PARAMS_FILEPATH, SNAPSHOTS_SHARED_VOLUME
from node_cli.configs.resource_allocation import (
RESOURCE_ALLOCATION_FILEPATH, TIMES, TIMEOUT,
TEST_DIVIDER, SMALL_DIVIDER, MEDIUM_DIVIDER, LARGE_DIVIDER,
Expand Down Expand Up @@ -75,8 +72,7 @@ def compose_resource_allocation_config(
env_type: str,
params_by_env_type: Dict = None
) -> Dict:
params_by_env_type = params_by_env_type or \
safe_load_yml(ENVIRONMENT_PARAMS_FILEPATH)
params_by_env_type = params_by_env_type or safe_load_yml(STATIC_PARAMS_FILEPATH)
common_config = params_by_env_type['common']
schain_cpu_alloc, ima_cpu_alloc = get_cpu_alloc(common_config)
schain_mem_alloc, ima_mem_alloc = get_memory_alloc(common_config)
Expand Down
16 changes: 8 additions & 8 deletions node_cli/utils/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

logger = logging.getLogger(__name__)

SCHAIN_REMOVE_TIMEOUT = 60
SCHAIN_REMOVE_TIMEOUT = 300
IMA_REMOVE_TIMEOUT = 20

MAIN_COMPOSE_CONTAINERS = ('skale-api', 'bounty', 'skale-admin')
Expand Down Expand Up @@ -93,28 +93,28 @@ def remove_dynamic_containers():

def rm_all_schain_containers():
schain_containers = get_all_schain_containers()
remove_containers(schain_containers, stop_timeout=SCHAIN_REMOVE_TIMEOUT)
remove_containers(schain_containers, timeout=SCHAIN_REMOVE_TIMEOUT)


def rm_all_ima_containers():
ima_containers = get_all_ima_containers()
remove_containers(ima_containers, stop_timeout=IMA_REMOVE_TIMEOUT)
remove_containers(ima_containers, timeout=IMA_REMOVE_TIMEOUT)


def remove_containers(containers, stop_timeout):
def remove_containers(containers, timeout):
for container in containers:
safe_rm(container, stop_timeout=stop_timeout)
safe_rm(container, timeout=timeout)


def safe_rm(container: Container, stop_timeout=DOCKER_DEFAULT_STOP_TIMEOUT, **kwargs):
def safe_rm(container: Container, timeout=DOCKER_DEFAULT_STOP_TIMEOUT, **kwargs):
"""
Saves docker container logs (last N lines) in the .skale/node_data/log/.removed_containers
folder. Then stops and removes container with specified params.
"""
container_name = container.name
logger.info(
f'Stopping container: {container_name}, timeout: {stop_timeout}')
container.stop(timeout=stop_timeout)
f'Stopping container: {container_name}, timeout: {timeout}')
container.stop(timeout=timeout)
backup_container_logs(container)
logger.info(f'Removing container: {container_name}, kwargs: {kwargs}')
container.remove(**kwargs)
Expand Down
98 changes: 0 additions & 98 deletions tests/.skale/config/environment_params.yaml

This file was deleted.

Loading

0 comments on commit c859197

Please sign in to comment.