Skip to content

Commit

Permalink
Fix sort nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ausias-armesto committed May 20, 2024
1 parent 3315af2 commit f2d73b6
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hoprd_operator"
version = "0.2.14"
version = "0.2.15"
authors = ["HOPR Association <[email protected]>"]
edition = "2021"

Expand Down
3 changes: 2 additions & 1 deletion src/cluster/cluster_hoprd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,11 @@ impl ClusterHoprd {
let api: Api<Hoprd> = Api::namespaced(client, &self.namespace().unwrap());
let current_nodes = self.get_my_nodes(api).await.unwrap();
debug!("ClusterHoprd {} in namespace {} has currently {} nodes", self.name_any(), self.namespace().unwrap(), current_nodes.len());
let current_node_numbers = current_nodes.iter().map(|n| {
let mut current_node_numbers = current_nodes.iter().map(|n| {
// Casting the node numbers and removing 1 unit to align them with the index of the array, so the nodes numbering starts from value 0 instead of 1
n.name_any().replace(&format!("{}-", self.metadata.name.as_ref().unwrap()), "").parse::<i32>().unwrap() - 1
}).collect::<Vec<i32>>();
current_node_numbers.sort();
let next = current_node_numbers.iter().enumerate().find_map(|(index, &value)| {
let index_i32: i32 = index.try_into().unwrap();
if index_i32 != value {
Expand Down
2 changes: 1 addition & 1 deletion src/hoprd/hoprd_deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub async fn modify_deployment(context_data: Arc<ContextData>, deployment_name:
.env.as_ref().unwrap().iter()
.find(|&env_var| env_var.name.eq(&constants::HOPRD_HOST.to_owned())).unwrap()
.value.as_ref().unwrap().to_owned();
let hoprd_host = hoprd_host_port.split(':').collect::<Vec<&str>>().get(0).unwrap().clone();
let hoprd_host = *hoprd_host_port.split(':').collect::<Vec<&str>>().get(0).unwrap();
let p2p_port = hoprd_host_port.split(':').collect::<Vec<&str>>().get(1).unwrap().to_string().parse::<i32>().unwrap();
let identity_pool: IdentityPool = identity_hoprd.get_identity_pool(context_data.client.clone()).await.unwrap();
let spec = build_deployment_spec(deployment.labels().to_owned(), hoprd_spec, identity_pool, identity_hoprd, &hoprd_host, p2p_port).await;
Expand Down
2 changes: 1 addition & 1 deletion src/hoprd/hoprd_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::identity_hoprd::identity_hoprd_resource::{IdentityHoprd, IdentityHopr
use crate::identity_pool::identity_pool_resource::{IdentityPool, IdentityPoolPhaseEnum};
use crate::model::Error;
use crate::{
hoprd::{hoprd_deployment_spec::HoprdDeploymentSpec, hoprd_deployment, hoprd_service, hoprd_ingress, hoprd_service::{ServiceTypeEnum, HoprdServiceSpec}},
hoprd::{hoprd_deployment_spec::HoprdDeploymentSpec, hoprd_deployment, hoprd_service, hoprd_ingress, hoprd_service::HoprdServiceSpec},
constants, context_data::ContextData,
};
use chrono::Utc;
Expand Down
2 changes: 1 addition & 1 deletion src/hoprd/hoprd_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ fn build_ports(p2p_port: i32, port_name: Option<&str>) -> Vec<ServicePort> {
name: Some(port_name.unwrap().to_owned()),
port: port,
protocol: Some(protocol.to_string()),
target_port: Some(IntOrString::Int(p2p_port)),
target_port: Some(IntOrString::Int(port)),
..ServicePort::default()
}
]
Expand Down

0 comments on commit f2d73b6

Please sign in to comment.