Skip to content

Commit 40e0cfa

Browse files
committed
Merge branch 'kpop/CON-1058/links' into 'master'
feat(ic-recovery): [CON-1058] print urls to dashboards after some steps ``` Jun 27 07:59:26.006 INFO ################################### Jun 27 07:59:26.006 INFO V UnhaltDestinationSubnet V Jun 27 07:59:26.006 INFO ################################### Jun 27 07:59:26.015 INFO Please check the dashboard to see if it is safe to unhalt the destination subnet and/or remove the canister migrations entry Jun 27 07:59:26.015 INFO https://grafana.mainnet.dfinity.network/d/K08U69_4k/subnet-splitting?var-datasource=IC+Metrics&var-ic=mercury&var-ic_subnet=xqxyq-bcezi-vonf7-hsbgm-3n5jq-hx3qg-r5gpr-7xi4g-7emfo-gadd6-hae&var-registry_version=27 Jun 27 07:59:26.015 INFO Press [ENTER] to continue... Jun 27 07:58:39.552 INFO ####################################### Jun 27 07:58:39.552 INFO V HaltSourceSubnetAtCupHeight V Jun 27 07:58:39.552 INFO ####################################### Jun 27 07:58:39.565 INFO Please check the dashboard if it is safe to begin subnet splitting Jun 27 07:58:39.565 INFO https://grafana.mainnet.dfinity.network/d/cB-qtJX4k/subnet-splitting-pre-flight?var-datasource=IC+Metrics&var-ic=mercury&var-ic_subnet=4heh6-kgou6-qsxov-psrhm-l3pi6-6cc45-c6oyl-pbayl-vayfm-hmxx2-vae&var-registry_version=27 Jun 27 07:58:39.565 INFO Press [ENTER] to continue... ``` Closes CON-1058 Closes CON-1058 See merge request dfinity-lab/public/ic!13207
2 parents cc0a343 + e511a9e commit 40e0cfa

File tree

2 files changed

+85
-8
lines changed

2 files changed

+85
-8
lines changed

rs/recovery/src/registry_helper.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,8 @@ impl RegistryHelper {
112112
}
113113

114114
/// Polls the [RegistryReplicator] for the most recent version of the registry and then
115-
/// extracts the appropriate entries based on the provided closure.
116-
fn get<T>(
117-
&self,
118-
field_extractor: impl Fn(RegistryVersion, &RegistryClientImpl) -> RegistryClientResult<T>,
119-
) -> VersionedRecoveryResult<T> {
115+
/// gets the latest registry version.
116+
pub fn latest_registry_version(&self) -> RecoveryResult<RegistryVersion> {
120117
match self.polling_strategy {
121118
RegistryPollingStrategy::WithEveryRead => {
122119
block_on(self.registry_replicator.poll(vec![self.nns_url.clone()])).map_err(
@@ -135,7 +132,16 @@ impl RegistryHelper {
135132
RecoveryError::RegistryError(format!("Failed to poll the newest registry: {}", err))
136133
})?;
137134

138-
let registry_version = self.registry_client.get_latest_version();
135+
Ok(self.registry_client.get_latest_version())
136+
}
137+
138+
/// Polls the [RegistryReplicator] for the most recent version of the registry and then
139+
/// extracts the appropriate entries based on the provided closure.
140+
fn get<T>(
141+
&self,
142+
field_extractor: impl Fn(RegistryVersion, &RegistryClientImpl) -> RegistryClientResult<T>,
143+
) -> VersionedRecoveryResult<T> {
144+
let registry_version = self.latest_registry_version()?;
139145

140146
let field =
141147
field_extractor(registry_version, self.registry_client.as_ref()).map_err(|err| {

rs/recovery/subnet_splitting/src/subnet_splitting.rs

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
use clap::Parser;
1212
use ic_base_types::SubnetId;
1313
use ic_recovery::{
14-
cli::{consent_given, read_optional},
14+
cli::{consent_given, read_optional, wait_for_confirmation},
1515
error::{RecoveryError, RecoveryResult},
1616
recovery_iterator::RecoveryIterator,
1717
recovery_state::{HasRecoveryState, RecoveryState},
@@ -22,9 +22,10 @@ use ic_recovery::{
2222
use ic_registry_routing_table::CanisterIdRange;
2323
use ic_state_manager::manifest::{manifest_from_path, manifest_hash};
2424
use serde::{Deserialize, Serialize};
25-
use slog::Logger;
25+
use slog::{info, warn, Logger};
2626
use strum::{EnumMessage, IntoEnumIterator};
2727
use strum_macros::{EnumIter, EnumString};
28+
use url::Url;
2829

2930
use std::{iter::Peekable, net::IpAddr, path::PathBuf};
3031

@@ -282,6 +283,31 @@ impl RecoveryIterator<StepType, StepTypeIter> for SubnetSplitting {
282283
fn read_step_params(&mut self, step_type: StepType) {
283284
match step_type {
284285
StepType::HaltSourceSubnetAtCupHeight => {
286+
let url = match self.recovery.registry_helper.latest_registry_version() {
287+
Ok(registry_version) => {
288+
format!(
289+
"https://grafana.mainnet.dfinity.network/d/cB-qtJX4k/subnet-splitting-pre-flight?var-datasource=IC+Metrics&var-ic=mercury&var-ic_subnet={}&var-registry_version={}",
290+
self.params.destination_subnet_id, registry_version
291+
)
292+
}
293+
Err(err) => {
294+
warn!(
295+
self.logger,
296+
"Failed to get the latest registry version: {}", err
297+
);
298+
format!(
299+
"https://grafana.mainnet.dfinity.network/d/cB-qtJX4k/subnet-splitting-pre-flight?var-datasource=IC+Metrics&var-ic=mercury&var-ic_subnet={}",
300+
self.params.destination_subnet_id
301+
)
302+
}
303+
};
304+
305+
print_url_and_ask_for_confirmation(
306+
&self.logger,
307+
url,
308+
"Please check the dashboard to see if it is safe to begin subnet splitting",
309+
);
310+
285311
if self.params.pub_key.is_none() {
286312
self.params.pub_key = read_optional(
287313
&self.logger,
@@ -320,6 +346,34 @@ impl RecoveryIterator<StepType, StepTypeIter> for SubnetSplitting {
320346
}
321347
}
322348

349+
StepType::UnhaltDestinationSubnet | StepType::CompleteCanisterMigration => {
350+
let url = match self.recovery.registry_helper.latest_registry_version() {
351+
Ok(registry_version) => {
352+
format!(
353+
"https://grafana.mainnet.dfinity.network/d/K08U69_4k/subnet-splitting?var-datasource=IC+Metrics&var-ic=mercury&var-ic_subnet={}&var-registry_version={}",
354+
self.params.source_subnet_id, registry_version
355+
)
356+
}
357+
Err(err) => {
358+
warn!(
359+
self.logger,
360+
"Failed to get the latest registry version: {}", err
361+
);
362+
format!(
363+
"https://grafana.mainnet.dfinity.network/d/K08U69_4k/subnet-splitting?var-datasource=IC+Metrics&var-ic=mercury&var-ic_subnet={}",
364+
self.params.source_subnet_id,
365+
)
366+
}
367+
};
368+
369+
print_url_and_ask_for_confirmation(
370+
&self.logger,
371+
url,
372+
"Please check the dashboard to see if it is safe to unhalt the \
373+
destination subnet and/or remove the canister migrations entry",
374+
);
375+
}
376+
323377
_ => (),
324378
}
325379
}
@@ -453,3 +507,20 @@ impl HasRecoveryState for SubnetSplitting {
453507
})
454508
}
455509
}
510+
511+
fn print_url_and_ask_for_confirmation(
512+
logger: &Logger,
513+
url: String,
514+
text_to_display: impl std::fmt::Display,
515+
) {
516+
match Url::parse(&url) {
517+
Ok(url) => {
518+
info!(logger, "{}", text_to_display);
519+
info!(logger, "{}", url);
520+
wait_for_confirmation(logger);
521+
}
522+
Err(err) => {
523+
warn!(logger, "Failed to parse url {}: {}", url, err);
524+
}
525+
}
526+
}

0 commit comments

Comments
 (0)