Skip to content

Commit

Permalink
Merge pull request #1005 from skalenetwork/hotfix-update-config-monitor
Browse files Browse the repository at this point in the history
Run update config skaled monitor even if config updated but skaled still exited
  • Loading branch information
badrogger authored Nov 6, 2023
2 parents c42f1a6 + 7554458 commit aedb8ac
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.2
2.5.3
2 changes: 1 addition & 1 deletion core/schains/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def get_all(self, log: bool = True, save: bool = False, needed: Optional[List[st
needed=needed
)
plain_checks.update(subj_checks)
if not self.estate.ima_linked:
if not self.estate or not self.estate.ima_linked:
if 'ima_container' in plain_checks:
del plain_checks['ima_container']

Expand Down
14 changes: 8 additions & 6 deletions core/schains/monitor/config_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ def execute(self) -> None:

def run(self):
typename = type(self).__name__
logger.info('Config monitor type %s starting', typename)
self.am._upd_last_seen()
self.execute()
self.am.log_executed_blocks()
self.am._upd_last_seen()
logger.info('Config monitor type %s finished', typename)
logger.info('Config monitor type starting %s', typename)
try:
self.am._upd_last_seen()
self.execute()
self.am.log_executed_blocks()
self.am._upd_last_seen()
finally:
logger.info('Config monitor type finished %s', typename)


class RegularConfigMonitor(BaseConfigMonitor):
Expand Down
20 changes: 10 additions & 10 deletions core/schains/monitor/skaled_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ def execute(self) -> None:

def run(self):
typename = type(self).__name__
logger.info('Skaled monitor type %s starting', typename)
self.am._upd_last_seen()
self.execute()
self.am._upd_schain_record()
self.am.log_executed_blocks()
self.am._upd_last_seen()
logger.info('Skaled monitor type %s finished', typename)
logger.info('Skaled monitor type starting %s', typename)
try:
self.am._upd_last_seen()
self.execute()
self.am._upd_schain_record()
self.am.log_executed_blocks()
self.am._upd_last_seen()
finally:
logger.info('Skaled monitor type finished %s', typename)


class RegularSkaledMonitor(BaseSkaledMonitor):
Expand Down Expand Up @@ -233,9 +235,7 @@ def is_config_update_time(
) -> bool:
if not skaled_status:
return False
return not status['config_updated'] and \
not status['skaled_container'] and \
skaled_status.exit_time_reached
return not status['skaled_container'] and skaled_status.exit_time_reached


def is_recreate_mode(schain_record: SChainRecord) -> bool:
Expand Down
11 changes: 11 additions & 0 deletions tests/schains/monitor/skaled_monitor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def test_get_skaled_monitor_new_node(
def test_get_skaled_monitor_update_config(
skaled_am,
skaled_checks_outdated_config,
skaled_checks_new_config,
schain_db,
skaled_status_exit_time_reached,
):
Expand All @@ -399,6 +400,16 @@ def test_get_skaled_monitor_update_config(
)
assert mon == UpdateConfigSkaledMonitor

status = skaled_checks_new_config.get_all()
status['skaled_container'] = False
mon = get_skaled_monitor(
skaled_am,
status,
schain_record,
skaled_status_exit_time_reached
)
assert mon == UpdateConfigSkaledMonitor


def test_get_skaled_monitor_recreate(
skaled_am,
Expand Down

0 comments on commit aedb8ac

Please sign in to comment.