Skip to content

Commit

Permalink
Leave only removing telegraf during update/turn-off
Browse files Browse the repository at this point in the history
  • Loading branch information
badrogger committed Apr 23, 2024
1 parent c828ee8 commit fd0af66
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 120 deletions.
16 changes: 0 additions & 16 deletions node_cli/operations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
)
from node_cli.operations.docker_lvmpy import lvmpy_install # noqa
from node_cli.operations.skale_node import download_skale_node, sync_skale_node, update_images
from node_cli.operations.telegraf import generate_telegraf_config, get_telegraf_options
from node_cli.core.checks import CheckType, run_checks as run_host_checks
from node_cli.core.iptables import configure_iptables
from node_cli.utils.docker_utils import (
Expand Down Expand Up @@ -139,9 +138,6 @@ def update(env_filepath: str, env: Dict) -> None:
distro.version()
)
update_images(env.get('CONTAINER_CONFIGS_DIR') != '')
if env.get('TELEGRAF'):
options = get_telegraf_options(env)
generate_telegraf_config(options)
compose_up(env)
return True

Expand Down Expand Up @@ -179,10 +175,6 @@ def init(env_filepath: str, env: dict) -> bool:
update_resource_allocation(env_type=env['ENV_TYPE'])
update_images(env.get('CONTAINER_CONFIGS_DIR') != '')

if env.get('TELEGRAF'):
options = get_telegraf_options(env)
generate_telegraf_config(options)

compose_up(env)
return True

Expand Down Expand Up @@ -234,10 +226,6 @@ def init_sync(
update_resource_allocation(env_type=env['ENV_TYPE'])
update_images(env.get('CONTAINER_CONFIGS_DIR') != '', sync_node=True)

if env.get('TELEGRAF'):
options = get_telegraf_options(env)
generate_telegraf_config(options)

compose_up(env, sync_node=True)
return True

Expand Down Expand Up @@ -280,10 +268,6 @@ def update_sync(env_filepath: str, env: Dict) -> bool:
)
update_images(env.get('CONTAINER_CONFIGS_DIR') != '', sync_node=True)

if env.get('TELEGRAF'):
options = get_telegraf_options(env)
generate_telegraf_config(options)

compose_up(env, sync_node=True)
return True

Expand Down
50 changes: 0 additions & 50 deletions node_cli/operations/telegraf.py

This file was deleted.

13 changes: 9 additions & 4 deletions node_cli/utils/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

SCHAIN_REMOVE_TIMEOUT = 300
IMA_REMOVE_TIMEOUT = 20
TELEGRAF_REMOVE_TIMEOUT = 20

MAIN_COMPOSE_CONTAINERS = ('skale-api', 'bounty', 'skale-admin')
BASE_COMPOSE_SERVICES = (
Expand Down Expand Up @@ -86,11 +87,13 @@ def get_all_ima_containers(_all=True) -> list:
return docker_client().containers.list(all=_all, filters={'name': 'skale_ima_*'})


def remove_dynamic_containers():
def remove_dynamic_containers() -> None:
logger.info('Removing sChains containers')
rm_all_schain_containers()
logger.info('Removing IMA containers')
rm_all_ima_containers()
logger.info('Removing telegraf (if exists)')
remove_telegraf()


def rm_all_schain_containers():
Expand All @@ -103,6 +106,11 @@ def rm_all_ima_containers():
remove_containers(ima_containers, timeout=IMA_REMOVE_TIMEOUT)


def remove_telegraf() -> None:
telegraf = docker_client().containers.list(filters={'name': 'skale_telegraf'})
remove_containers(telegraf, timeout=TELEGRAF_REMOVE_TIMEOUT)


def remove_containers(containers, timeout):
for container in containers:
safe_rm(container, timeout=timeout)
Expand Down Expand Up @@ -248,9 +256,6 @@ def compose_up(env, sync_node=False):
if str_to_bool(env.get('MONITORING_CONTAINERS', 'False')):
logger.info('Running monitoring containers')
run_cmd(cmd=get_up_compose_cmd(MONITORING_COMPOSE_SERVICES), env=env)
if str_to_bool(env.get('TELEGRAF', 'False')):
logger.info('Running monitoring containers')
run_cmd(cmd=get_up_compose_cmd(TELEGRAF_SERVICES), env=env)
if 'TG_API_KEY' in env and 'TG_CHAT_ID' in env:
logger.info('Running containers for Telegram notifications')
run_cmd(cmd=get_up_compose_cmd(NOTIFICATION_COMPOSE_SERVICES), env=env)
Expand Down
Empty file removed tests/operations/__init__.py
Empty file.
50 changes: 0 additions & 50 deletions tests/operations/telegraf_test.py

This file was deleted.

0 comments on commit fd0af66

Please sign in to comment.