Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run update config skaled monitor even if config updated but skaled still exited #1008

Merged
merged 33 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d38b0bf
Merge pull request #864 from skalenetwork/merge-develop
dmytrotkk Sep 20, 2022
4d89dc2
Merge pull request #866 from skalenetwork/develop
dmytrotkk Sep 22, 2022
228bc08
Merge branch 'develop' into merge-develop
badrogger Nov 25, 2022
809d8ca
Merge pull request #886 from skalenetwork/merge-develop
dmytrotkk Nov 25, 2022
b3aaa5a
Merge pull request #890 from skalenetwork/develop
dmytrotkk Dec 1, 2022
beb45c2
Merge pull request #901 from skalenetwork/develop
dmytrotkk Dec 14, 2022
b3f33d5
Merge pull request #905 from skalenetwork/develop
dmytrotkk Dec 30, 2022
4a6cfb9
Merge pull request #918 from skalenetwork/develop
dmytrotkk Feb 9, 2023
1e4b01e
Merge pull request #925 from skalenetwork/beta
DmytroNazarenko Feb 16, 2023
789dfdb
Merge branch 'beta' into beta-to-stable
badrogger Sep 22, 2023
7bfb952
Merge pull request #983 from skalenetwork/beta-to-stable
DmytroNazarenko Sep 22, 2023
88f108e
Restart skaled and IMA during PostRotationMonitor
badrogger Oct 4, 2023
2d9b7ef
Fix test
badrogger Oct 4, 2023
4678efa
Set prerelease false in stable branch
badrogger Oct 5, 2023
fa64881
Add hardhat node submodule
badrogger Aug 25, 2023
ad668fb
Switch to https link for hardhat-node
badrogger Aug 25, 2023
2859f70
Do not remove IMA container
badrogger Oct 6, 2023
ca3f8d9
Merge pull request #991 from skalenetwork/hotfix/989-rotation-restart…
DmytroNazarenko Oct 6, 2023
f9c46e9
Cleanup SM image after deployment
badrogger Oct 9, 2023
d7b6f18
Merge pull request #994 from skalenetwork/rmi-sm
DmytroNazarenko Oct 9, 2023
f49aeb8
Merge branch 'develop' into merge-develop
badrogger Oct 18, 2023
0c8fd17
Remove base monitor tests
badrogger Oct 18, 2023
23147a6
Merge pull request #997 from skalenetwork/merge-develop
DmytroNazarenko Oct 19, 2023
9be32a6
Merge branch 'develop' into merge-develop-2.2.1
badrogger Oct 23, 2023
0caa466
Bump VERSION
badrogger Oct 23, 2023
c42f1a6
Merge pull request #1002 from skalenetwork/merge-develop-2.2.1
DmytroNazarenko Oct 23, 2023
36e1b71
Run update config monitor regardless of outdated config
badrogger Nov 3, 2023
cfe7b55
Add test
badrogger Nov 3, 2023
3198acf
Fix removing schain after failed dkg
badrogger Nov 6, 2023
4145980
Add try-finally to Config Monitor
badrogger Nov 6, 2023
19c8f35
Rollback Dockerfile
badrogger Nov 6, 2023
7554458
Bump VERSION to 2.5.3
badrogger Nov 6, 2023
aedb8ac
Merge pull request #1005 from skalenetwork/hotfix-update-config-monitor
badrogger Nov 6, 2023
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
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Version $VERSION"
export RELEASE=true
( test $BRANCH = "stable" && export PRERELEASE=false ) || export PRERELEASE=true
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
echo "RELEASE=$RELEASE" >> $GITHUB_ENV
export CONTAINER_NAME="admin"
bash ./helper-scripts/build_and_publish.sh
Expand All @@ -47,4 +49,4 @@ jobs:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
draft: false
prerelease: true
prerelease: ${{ env.PRERELEASE }}
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.1
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
38 changes: 38 additions & 0 deletions core/schains/monitor/post_rotation_monitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
#
# This file is part of SKALE Admin
#
# Copyright (C) 2021 SKALE Labs
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import logging

Check warning on line 20 in core/schains/monitor/post_rotation_monitor.py

View check run for this annotation

Codecov / codecov/patch

core/schains/monitor/post_rotation_monitor.py#L20

Added line #L20 was not covered by tests

from core.schains.monitor.base_monitor import BaseMonitor

Check warning on line 22 in core/schains/monitor/post_rotation_monitor.py

View check run for this annotation

Codecov / codecov/patch

core/schains/monitor/post_rotation_monitor.py#L22

Added line #L22 was not covered by tests


logger = logging.getLogger(__name__)

Check warning on line 25 in core/schains/monitor/post_rotation_monitor.py

View check run for this annotation

Codecov / codecov/patch

core/schains/monitor/post_rotation_monitor.py#L25

Added line #L25 was not covered by tests


class PostRotationMonitor(BaseMonitor):

Check warning on line 28 in core/schains/monitor/post_rotation_monitor.py

View check run for this annotation

Codecov / codecov/patch

core/schains/monitor/post_rotation_monitor.py#L28

Added line #L28 was not covered by tests
"""
PostRotationMonitor be executed for the sChain on the staying node when rotation is complete.
This type of monitor reloads skaled container.
"""
@BaseMonitor.monitor_runner
def run(self):
logger.info(f'{self.p} was stopped after rotation. Going to restart')
self.config(overwrite=True)
self.firewall_rules()
self.recreated_schain_containers()

Check warning on line 38 in core/schains/monitor/post_rotation_monitor.py

View check run for this annotation

Codecov / codecov/patch

core/schains/monitor/post_rotation_monitor.py#L33-L38

Added lines #L33 - L38 were not covered by tests
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
Loading