Skip to content

Commit 830d050

Browse files
authored
Merge pull request #111 from dfinity/igor/fix-ic-key-fetch
Fix IC root key fetching
2 parents 3cd987d + 10c0ccc commit 830d050

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/metrics/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,10 @@ pub async fn middleware(
296296
let domain = ctx
297297
.as_ref()
298298
.map_or_else(String::new, |x| x.domain.name.to_string());
299-
let error_cause = error_cause
299+
300+
let (error_cause, error_cause_details) = error_cause
300301
.clone()
301-
.map_or_else(String::new, |x| x.to_string());
302+
.map_or_else(|| (String::new(), None), |x| (x.to_string(), x.details()));
302303

303304
let upstream = req_meta
304305
.upstream
@@ -382,6 +383,7 @@ pub async fn middleware(
382383
ic_cache_status = resp_meta.cache_status,
383384
ic_cache_bypass_reason = resp_meta.cache_bypass_reason,
384385
error = error_cause,
386+
error_details = error_cause_details,
385387
req_size = request_size,
386388
request_type,
387389
resp_size = response_size,

src/routing/ic/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use ic_bn_lib::http::{
2424
use ic_http_gateway::{
2525
HttpGatewayClient, HttpGatewayClientBuilder, HttpGatewayResponse, HttpGatewayResponseMetadata,
2626
};
27+
use tracing::warn;
2728

2829
use crate::Cli;
2930

@@ -121,9 +122,15 @@ pub fn setup(
121122
let key = fs::read(v).context("unable to read IC root key")?;
122123
agent.set_root_key(key);
123124
} else if cli.ic.ic_unsafe_root_key_fetch {
124-
tokio::runtime::Handle::current()
125-
.block_on(async { agent.fetch_root_key().await })
126-
.context("unable to fetch IC root key")?;
125+
warn!("Fetching IC root key (UNSAFE)");
126+
127+
let agent = agent.clone();
128+
let _ = futures::executor::block_on(async move {
129+
tokio::runtime::Handle::current()
130+
.spawn(async move { agent.fetch_root_key().await })
131+
.await
132+
})
133+
.context("unable to fetch IC root key")?;
127134
}
128135

129136
let client = HttpGatewayClientBuilder::new()

0 commit comments

Comments
 (0)