Skip to content

Commit

Permalink
Merge branch 'REL-306-sort-subnets-release' into 'main'
Browse files Browse the repository at this point in the history
fix(dashboard): Sort subnets deterministically in the release rollout dashboard

See merge request dfinity-lab/core/release!731
  • Loading branch information
sasa-tomic committed Jun 1, 2023
2 parents 9d41fe0 + 9b71f7b commit da0f535
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions rs/ic-management-backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use ic_types::PrincipalId;
use log::{debug, error, info, warn};
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::convert::TryFrom;
use std::ops::{Add, Deref};
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -231,7 +231,7 @@ async fn nodes_healths(registry: web::Data<Arc<RwLock<registry::RegistryState>>>
.unwrap_or(ic_management_types::Status::Unknown),
)
})
.collect::<HashMap<_, _>>()
.collect::<BTreeMap<_, _>>()
}))
}

Expand Down
22 changes: 11 additions & 11 deletions rs/ic-management-backend/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use itertools::Itertools;
use std::convert::TryFrom;
use std::sync::Arc;
use std::{
collections::{HashMap, HashSet},
collections::{BTreeMap, HashMap, HashSet},
net::Ipv6Addr,
};

Expand Down Expand Up @@ -48,11 +48,11 @@ pub struct RegistryState {
local_registry: Arc<LocalRegistry>,

version: u64,
subnets: HashMap<PrincipalId, Subnet>,
nodes: HashMap<PrincipalId, Node>,
operators: HashMap<PrincipalId, Operator>,
subnets: BTreeMap<PrincipalId, Subnet>,
nodes: BTreeMap<PrincipalId, Node>,
operators: BTreeMap<PrincipalId, Operator>,
guests: Vec<Guest>,
known_subnets: HashMap<PrincipalId, String>,
known_subnets: BTreeMap<PrincipalId, String>,

replica_releases: Vec<ReplicaRelease>,
gitlab_client_public: Option<gitlab::AsyncGitlab>,
Expand Down Expand Up @@ -137,9 +137,9 @@ impl RegistryState {
network,
local_registry,
version: 0,
subnets: HashMap::<PrincipalId, Subnet>::new(),
nodes: HashMap::new(),
operators: HashMap::new(),
subnets: BTreeMap::<PrincipalId, Subnet>::new(),
nodes: BTreeMap::new(),
operators: BTreeMap::new(),
guests: Vec::new(),
replica_releases: Vec::new(),
gitlab_client_public,
Expand Down Expand Up @@ -493,11 +493,11 @@ impl RegistryState {
self.version
}

pub fn subnets(&self) -> HashMap<PrincipalId, Subnet> {
pub fn subnets(&self) -> BTreeMap<PrincipalId, Subnet> {
self.subnets.clone()
}

pub fn nodes(&self) -> HashMap<PrincipalId, Node> {
pub fn nodes(&self) -> BTreeMap<PrincipalId, Node> {
self.nodes.clone()
}

Expand Down Expand Up @@ -561,7 +561,7 @@ impl RegistryState {
.collect())
}

pub fn operators(&self) -> HashMap<PrincipalId, Operator> {
pub fn operators(&self) -> BTreeMap<PrincipalId, Operator> {
self.operators.clone()
}

Expand Down
10 changes: 5 additions & 5 deletions rs/ic-management-backend/src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ic_types::PrincipalId;
use itertools::Itertools;
use log::info;
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
use std::collections::{BTreeMap, BTreeSet};
use std::str::FromStr;
use strum_macros::{Display, EnumString};

Expand Down Expand Up @@ -140,7 +140,7 @@ impl RolloutConfig {
pub struct RolloutBuilder {
pub proposal_agent: ProposalAgent,
pub prometheus_client: prometheus_http_query::Client,
pub subnets: HashMap<PrincipalId, Subnet>,
pub subnets: BTreeMap<PrincipalId, Subnet>,
pub releases: Vec<ReplicaRelease>,
pub network: Network,
}
Expand Down Expand Up @@ -285,7 +285,7 @@ impl RolloutBuilder {
&self,
release: &ReplicaRelease,
since: chrono::DateTime<Utc>,
) -> Result<HashMap<PrincipalId, SubnetUpdateState>> {
) -> Result<BTreeMap<PrincipalId, SubnetUpdateState>> {
const STATE_FIELD: &str = "state";
let query = format!(
r#"
Expand Down Expand Up @@ -437,8 +437,8 @@ impl RolloutBuilder {
.updates
.iter()
.map(|u| u.replica_release.clone())
.collect::<HashSet<_>>();
let mut update_states = HashMap::new();
.collect::<BTreeSet<_>>();
let mut update_states = BTreeMap::new();
for release in releases {
let release_update_states = self.get_update_states(&release, last_stage.start_date_time).await?;
update_states.insert(release, release_update_states);
Expand Down
2 changes: 1 addition & 1 deletion rs/ic-management-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ pub struct NodeVersion {
pub replica_version: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ReplicaRelease {
pub commit_hash: String,
pub branch: String,
Expand Down

0 comments on commit da0f535

Please sign in to comment.