-
Notifications
You must be signed in to change notification settings - Fork 274
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
[fix] #1990: Enable peer startup via env vars in the absence of config.json
#2188
Conversation
@@ -143,7 +146,9 @@ where | |||
broker: Broker, | |||
) -> Result<Self> { | |||
if !config.disable_panic_terminal_colors { | |||
color_eyre::install()?; | |||
if let Err(e) = color_eyre::install() { | |||
iroha_logger::error!("Tried to install eyre_hook twice: {:?}", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was not able to trace the exact reason, but somehow with this workflow when no config was provided color_eyre kept crashing. AFAICT the only other spots where install()
is used are kagami
and logger
, but they don't seem to be called at that stage. Will double check the error again, but this was a stumbling point for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm asking because I think this also happened to sdk devs when bootstraping iroha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then at least it's not only me, but something in the code. I guess then as a workaround this will suffice for now, and I'll create a separate issue for the problem later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kagami is a completely unrelated executable, so this is probably the only place this happens. Log and ignore for now, but we ned to figure out why this happens. IMO there's a tokio task that tries to do the same thing in a different thread and breaks the install process.
c493f24
to
166c5bf
Compare
53199e0
to
a7260ed
Compare
5731324
to
6b34b1c
Compare
Codecov Report
@@ Coverage Diff @@
## iroha2-dev #2188 +/- ##
==============================================
- Coverage 76.65% 0 -76.66%
==============================================
Files 185 0 -185
Lines 26672 0 -26672
==============================================
- Hits 20445 0 -20445
+ Misses 6227 0 -6227 Continue to review full report at Codecov.
|
"Additionally, in case of absence of both IROHA2_CONFIG_PATH and `config.json` | ||
in the current directory, all the variables from `config.json` should be set via the environment | ||
as follows:" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain that they need to passed as a JSON string. I'd add an example of that could be run from the command line in the comments/docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a paragraph in the amended commit describing that.
e8bbee3
to
7da5290
Compare
The environment variables replacing `config.json` should be passed as JSON strings, meaning that any inner quotes should be properly escaped in the command line as shown in the rather unwieldy example below. | ||
|
||
``` bash | ||
IROHA_TORII="{\"P2P_ADDR\": \"127.0.0.1:1339\", \"API_URL\": \"127.0.0.1:8080\"}" IROHA_SUMERAGI="{\"TRUSTED_PEERS\": [{\"address\": \"127.0.0.1:1337\",\"public_key\": \"ed01201c61faf8fe94e253b93114240394f79a607b7fa55f9e5a41ebec74b88055768b\"},{\"address\": \"127.0.0.1:1338\",\"public_key\": \"ed0120cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1\"},{\"address\": \"127.0.0.1:1339\",\"public_key\": \"ed0120faca9e8aa83225cb4d16d67f27dd4f93fc30ffa11adc1f5c88fd5495ecc91020\"},{\"address\": \"127.0.0.1:1340\",\"public_key\": \"ed01208e351a70b6a603ed285d666b8d689b680865913ba03ce29fb7d13a166c4e7f1f\"}]}" IROHA_KURA="{\"INIT_MODE\": \"strict\",\"BLOCK_STORE_PATH\": \"./blocks\"}" IROHA_BLOCK_SYNC="{\"GOSSIP_PERIOD_MS\": 10000,\"BATCH_SIZE\": 2}" IROHA_PUBLIC_KEY="ed01201c61faf8fe94e253b93114240394f79a607b7fa55f9e5a41ebec74b88055768b" IROHA_PRIVATE_KEY="{\"digest_function\": \"ed25519\",\"payload\": \"282ed9f3cf92811c3818dbc4ae594ed59dc1a2f78e4241e31924e101d6b1fb831c61faf8fe94e253b93114240394f79a607b7fa55f9e5a41ebec74b88055768b\"}" IROHA_GENESIS="{\"ACCOUNT_PUBLIC_KEY\": \"ed01204cffd0ee429b1bdd36b3910ec570852b8bb63f18750341772fb46bc856c5caaf\",\"ACCOUNT_PRIVATE_KEY\": {\"digest_function\": \"ed25519\",\"payload\": \"d748e18ce60cb30dea3e73c9019b7af45a8d465e3d71bcc9a5ef99a008205e534cffd0ee429b1bdd36b3910ec570852b8bb63f18750341772fb46bc856c5caaf\"}}" ./iroha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little ugly, but this is meant to be technical documentation. Add some <details>
tags around it and we can merge.
Signed-off-by: Ilia Churin <ilia.ch@netogami.net>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <ilia.ch@netogami.net>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <ilia.ch@netogami.net>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <ilia.ch@netogami.net>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <ilia.ch@netogami.net>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <churin.ilya@gmail.com>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <churin.ilya@gmail.com>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <churin.ilya@gmail.com>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <churin.ilya@gmail.com>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <churin.ilya@gmail.com>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <churin.ilya@gmail.com>
…ce of config.json (hyperledger#2188) Signed-off-by: Ilia Churin <churin.ilya@gmail.com>
Signed-off-by: Ilia Churin <churin.ilya@gmail.com>
Signed-off-by: Ilia Churin ilia.ch@netogami.net
Description of the Change
In the case when the minimal cli client (
iroha
) was provided with noconfig.json
either in the same directory or as an environment variable, do not stop the execution, but instead require that all the variables from the default json be provided as environment variables too, and load them onto default configuration.Issue
Resolves #1990.
Benefits
Presumably easier and more flexible setup of peer through cli.
Possible Drawbacks
As the fix chooses to fall back on default impl for config, it has the same problems that were discussed in #2101 and #2118. The question is which variables should be allowed to be set via environment, and which subset of them should be required when using default, if we're going to stick with it at all. As of now, the default configuration is generated with
Default
and all the variables from theconfigs/peer/config.json
are required to proceed if no file was found.