From a7cf816b43fa90a89661e5cf237ab0ba90809698 Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Thu, 7 Sep 2023 12:39:53 +0100 Subject: [PATCH 1/4] SKALED-1623 Don't force exit on signal after internal exit --- libdevcore/Common.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libdevcore/Common.cpp b/libdevcore/Common.cpp index 9828da2cc..e7135ae4c 100644 --- a/libdevcore/Common.cpp +++ b/libdevcore/Common.cpp @@ -47,11 +47,18 @@ void ExitHandler::exitHandler( int s ) { } void ExitHandler::exitHandler( int nSignalNo, ExitHandler::exit_code_t ec ) { - std::string strMessagePrefix = ExitHandler::shouldExit() ? - cc::error( "\nStop flag was already raised on. " ) + - cc::fatal( "WILL FORCE TERMINATE." ) + - cc::error( " Caught (second) signal. " ) : - cc::error( "\nCaught (first) signal. " ); + std::string strMessagePrefix; + if ( nSignalNo > 0 ) { + strMessagePrefix = ( ExitHandler::shouldExit() && s_nStopSignal > 0 ) ? + cc::error( "\nStop flag was already raised on. " ) + + cc::fatal( "WILL FORCE TERMINATE." ) + + cc::error( " Caught (second) signal. " ) : + cc::error( "\nCaught (first) signal. " ); + } else { + strMessagePrefix = ExitHandler::shouldExit() ? + cc::error( "\nInternal exit initiated. " ) : + cc::error( "\nInternal exit requested while already exiting. " ); + } std::cerr << strMessagePrefix << cc::error( skutils::signal::signal2str( nSignalNo ) ) << "\n\n"; std::cerr.flush(); @@ -153,7 +160,8 @@ void ExitHandler::exitHandler( int nSignalNo, ExitHandler::exit_code_t ec ) { // nice exit here: - if ( ExitHandler::shouldExit() ) { + // TODO deduplicate with first if() + if ( ExitHandler::shouldExit() && s_nStopSignal > 0 && nSignalNo > 0 ) { std::cerr << ( "\n" + cc::fatal( "SIGNAL-HANDLER:" ) + " " + cc::error( "Will force exit now..." ) + "\n\n" ); _exit( 13 ); From 9692d78e2f061ff1b944fe42f865869497d33489 Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Tue, 17 Oct 2023 19:43:41 +0100 Subject: [PATCH 2/4] SKALED-1623 Logs fix --- libdevcore/Common.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdevcore/Common.cpp b/libdevcore/Common.cpp index dcdc348fd..26a99db7f 100644 --- a/libdevcore/Common.cpp +++ b/libdevcore/Common.cpp @@ -56,8 +56,8 @@ void ExitHandler::exitHandler( int nSignalNo, ExitHandler::exit_code_t ec ) { cc::error( "\nCaught (first) signal. " ); } else { strMessagePrefix = ExitHandler::shouldExit() ? - cc::error( "\nInternal exit initiated. " ) : - cc::error( "\nInternal exit requested while already exiting. " ); + cc::error( "\nInternal exit requested while already exiting. " ) : + cc::error( "\nInternal exit initiated. " ); } std::cerr << strMessagePrefix << cc::error( skutils::signal::signal2str( nSignalNo ) ) << "\n\n"; From e47968b9039a7516033d6649699f1db8db7a1981 Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Wed, 15 Nov 2023 19:50:05 +0000 Subject: [PATCH 3/4] SKALED-1623 Remove coloring --- libdevcore/Common.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/libdevcore/Common.cpp b/libdevcore/Common.cpp index 26a99db7f..e15bb6ae7 100644 --- a/libdevcore/Common.cpp +++ b/libdevcore/Common.cpp @@ -50,18 +50,15 @@ void ExitHandler::exitHandler( int nSignalNo, ExitHandler::exit_code_t ec ) { std::string strMessagePrefix; if ( nSignalNo > 0 ) { strMessagePrefix = ( ExitHandler::shouldExit() && s_nStopSignal > 0 ) ? - cc::error( "\nStop flag was already raised on. " ) + - cc::fatal( "WILL FORCE TERMINATE." ) + - cc::error( " Caught (second) signal. " ) : - cc::error( "\nCaught (first) signal. " ); + string( "\nStop flag was already raised on. " ) + + "WILL FORCE TERMINATE." + " Caught (second) signal. " : + "\nCaught (first) signal. "; } else { strMessagePrefix = ExitHandler::shouldExit() ? - cc::error( "\nInternal exit requested while already exiting. " ) : - cc::error( "\nInternal exit initiated. " ); + string( "\nInternal exit requested while already exiting. " ) : + "\nInternal exit initiated. "; } - std::cerr << strMessagePrefix << cc::error( skutils::signal::signal2str( nSignalNo ) ) - << "\n\n"; - std::cerr.flush(); + std::cerr << strMessagePrefix << skutils::signal::signal2str( nSignalNo ) << "\n\n"; switch ( nSignalNo ) { case SIGINT: @@ -109,10 +106,10 @@ void ExitHandler::exitHandler( int nSignalNo, ExitHandler::exit_code_t ec ) { auto start_time = std::chrono::steady_clock::now(); std::thread( [nSignalNo, start_time]() { - std::cerr << ( "\n" + cc::fatal( "SELF-KILL:" ) + " " + cc::error( "Will sleep " ) + - cc::size10( ExitHandler::KILL_TIMEOUT ) + - cc::error( " seconds before force exit..." ) + "\n\n" ); - std::cerr.flush(); + std::cerr << ( "\n" + string( "SELF-KILL:" ) + " " + "Will sleep " + + cc::size10( ExitHandler::KILL_TIMEOUT ) + + " seconds before force exit..." ) + + "\n\n"; clog( VerbosityInfo, "exit" ) << "THREADS timer started"; @@ -140,11 +137,10 @@ void ExitHandler::exitHandler( int nSignalNo, ExitHandler::exit_code_t ec ) { std::this_thread::sleep_for( 100ms ); } - std::cerr << ( "\n" + cc::fatal( "SELF-KILL:" ) + " " + - cc::error( "Will force exit after sleeping " ) + + std::cerr << ( "\n" + string( "SELF-KILL:" ) + " " + + "Will force exit after sleeping " + cc::size10( ExitHandler::KILL_TIMEOUT ) + cc::error( " second(s)" ) + "\n\n" ); - std::cerr.flush(); // TODO deduplicate this with main() before return ExitHandler::exit_code_t ec = ExitHandler::requestedExitCode(); @@ -162,8 +158,7 @@ void ExitHandler::exitHandler( int nSignalNo, ExitHandler::exit_code_t ec ) { // TODO deduplicate with first if() if ( ExitHandler::shouldExit() && s_nStopSignal > 0 && nSignalNo > 0 ) { - std::cerr << ( "\n" + cc::fatal( "SIGNAL-HANDLER:" ) + " " + - cc::error( "Will force exit now..." ) + "\n\n" ); + std::cerr << ( "\n" + string( "SIGNAL-HANDLER:" ) + " " + "Will force exit now...\n\n" ); _exit( 13 ); } From 22eed1549b4ae8c21d7ffa58a81f680d771ccb47 Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Mon, 20 Nov 2023 19:11:26 +0200 Subject: [PATCH 4/4] SKALED-1623 Use new branch in skale-ci --- .github/workflows/functional-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index 14d743434..4042e3a05 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -24,6 +24,7 @@ with: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} repository: skalenetwork/skale-ci-integration_tests + ref: v3.18.0 submodules: recursive - name: Set up Node uses: actions/setup-node@v3.4.0