[fix] #4030, #4063, #4064, #4079: re-architect logger and dynamic configuration#4100
Merged
0x009922 merged 28 commits intohyperledger-iroha:iroha2-devfrom Dec 12, 2023
Merged
Conversation
6 tasks
Erigara
reviewed
Nov 30, 2023
DCNick3
reviewed
Nov 30, 2023
DCNick3
reviewed
Nov 30, 2023
Erigara
reviewed
Nov 30, 2023
0x009922
commented
Dec 4, 2023
60beea1 to
174ee74
Compare
Pull Request Test Coverage Report for Build 7175878272
💛 - Coveralls |
Erigara
reviewed
Dec 6, 2023
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
4ac7515 to
23bd7e6
Compare
DCNick3
reviewed
Dec 11, 2023
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Erigara
approved these changes
Dec 12, 2023
DCNick3
approved these changes
Dec 12, 2023
Asem-Abdelhady
pushed a commit
to Asem-Abdelhady/iroha
that referenced
this pull request
Jan 9, 2024
…ha#4064, hyperledger-iroha#4079: re-architect logger and dynamic configuration (hyperledger-iroha#4100) Co-authored-by: ⭐️NINIKA⭐️ <DCNick3@users.noreply.github.com> Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Asem-Abdelhady
pushed a commit
to Asem-Abdelhady/iroha
that referenced
this pull request
Jan 22, 2024
…ha#4064, hyperledger-iroha#4079: re-architect logger and dynamic configuration (hyperledger-iroha#4100) Co-authored-by: ⭐️NINIKA⭐️ <DCNick3@users.noreply.github.com> Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com> Signed-off-by: Asem-Abdelhady <asemshawkey@gmail.com>
Asem-Abdelhady
pushed a commit
to Asem-Abdelhady/iroha
that referenced
this pull request
Feb 9, 2024
…ha#4064, hyperledger-iroha#4079: re-architect logger and dynamic configuration (hyperledger-iroha#4100) Co-authored-by: ⭐️NINIKA⭐️ <DCNick3@users.noreply.github.com> Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Started by updating configuration endpoints according to #4063, this PR expanded to major update of dynamic configuration mechanism, Logger configuration (#4030, #4064) and initialisation.
Logger initialisation is a global one-time thing, which was done with
iroha_logger::init(Configuration)function, which might accept the config and initialise logger, or might not, without an error. While initialising, it injected aReloadHandleinto the configuration instance, so that all updates toconfig.logger.max_log_levelwould trigger updates set up withiniroha_logger::init. Than thatconfigwas copied many times inToriiand log level was actually reloaded onPOST /configurationupdates.However, the configuration value update was not reflected in subsequent
GET /configurationrequests (#4079), because each timeconfigis copied (it was copied for each request), it was editing a copy ofconfigwithout affecting an original one. Since a copy ofconfigwas still containingReloadHandlefrom Logger, the log level was updated.Another problem appeared because of combination of configuration & logger architecture, in tests. It appeared that some tests ran concurrently, each calling
iroha_logger::initwith independentConfigurations. However, only oneiroha_logger::initmight succeed, and another silently pretends that everything is ok. It worked fine, until one of Iroha instances fails to update the log level, because itsConfigurationpassed intoiroha_logger::initwas not injected with aReloadHandle.Shortly, the system was unsound, i.e. it was easy to misuse.
Changes in this PR:
ReloadHandleandSyncValuefrom configurationlogger.terminal_colorssetting to the CLI layer #4030 and [suggestion] Simplify logger's behaviour and configuration #4064init(Configuration) -> Result<Option<Telemetries>>intoinit_global(Configuration) -> Result<LoggerHandle>, initialising the Logger actor once per process, and failing if it was done alreadytest_logger() -> LoggerHandle, lazily initialising the Logger actor with pre-defined configuration, suitable for testsChores:
Linked issue
Closes #4030 #4063 #4064 #4079
Benefits
Checklist
bunyancan parse current JSON output202 AcceptedforPOST /configurationMigration guide
Update Logger configuration
In the configuration file, under
LOGGER.*namespace:MAX_LOG_LEVELtoLEVELCOMPACT_MODE; useFORMAT: "full"(iffalse) andFORMAT: "compact"(iftrue) insteadLOG_FILE_PATH; useFORMAT: "json"instead and redirect stdout to a file, e.g.iroha > log.jsonTERMINAL_COLORS; use--terminal-colors/--no-terminal-colorsCLI arguments insteadTELEMETRY_CAPACITYEnv variables:
LOG_LEVEL: instead ofMAX_LOG_LEVELLOG_FORMAT: new parameterLOG_TOKIO_CONSOLE_ADDR: instead ofTOKIO_CONSOLE_ADDRExample file before:
{ "LOGGER": { "MAX_LOG_LEVEL": "INFO", "TELEMETRY_CAPACITY": 1000, "COMPACT_MODE": false, "LOG_FILE_PATH": null, "TERMINAL_COLORS": true } }Example file after:
{ "LOGGER": { "LEVEL": "INFO", "FORMAT": "full" } }Update Kura configuration
In the configuration file, under
KURA.*namespace, removeACTOR_CHANNEL_CAPACITYandBLOCKS_PER_STORAGE_FILEfields.Update configuration endpoints usage
GET /configurationnow returns JSON with only{ logger: { level } }.POST /configurationnow accepts JSON in the same shapePOST /configurationrequest before:{"LogLevel":"DEBUG"}POST /configurationrequest after:{"logger":{"level":"DEBUG"}}