Skip to content

Commit

Permalink
Fixing code
Browse files Browse the repository at this point in the history
  • Loading branch information
ausias-armesto committed Nov 30, 2023
1 parent e678b7c commit a9ef79b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/context_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl ContextData {
attribute: Option<String>
) {
let recorder = Recorder::new(self.client.clone(), self.state.read().await.reporter.clone(), resource.object_ref(&()));
recorder.publish(event.to_event(attribute)).await;
recorder.publish(event.to_event(attribute)).await.unwrap();
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/controller_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ use kube::{
},
Resource, Result,
};
use std::{
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher},
sync::Arc,
};
use std::sync::Arc;
use tokio::time::Duration;
use tracing::error;

use crate::{
constants::{self},
context_data::ContextData,
identity_hoprd::{IdentityHoprd, IdentityHoprdSpec},
identity_hoprd::IdentityHoprd,
model::Error,
};

Expand Down
8 changes: 2 additions & 6 deletions src/controller_identity_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ use kube::{
},
Resource, Result,
};
use std::{
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher},
sync::Arc,
};
use std::sync::Arc;
use tokio::time::Duration;
use tracing::error;

use crate::{
constants::{self},
context_data::ContextData,
identity_pool::{IdentityPool, IdentityPoolSpec},
identity_pool::IdentityPool,
model::Error,
servicemonitor::ServiceMonitor, identity_hoprd::IdentityHoprd,
};
Expand Down
9 changes: 5 additions & 4 deletions src/hoprd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::cluster::ClusterHoprdPhaseEnum;
use crate::events::{HoprdEventEnum, ResourceEvent, ClusterHoprdEventEnum, IdentityHoprdEventEnum, IdentityPoolEventEnum};
use crate::events::{HoprdEventEnum, ClusterHoprdEventEnum, IdentityHoprdEventEnum, IdentityPoolEventEnum};
use crate::resource_generics;
use crate::hoprd_deployment_spec::HoprdDeploymentSpec;
use crate::identity_hoprd::{IdentityHoprd, IdentityHoprdPhaseEnum};
Expand Down Expand Up @@ -365,21 +365,22 @@ impl Hoprd {
match deployment {
WatchEvent::Added(deployment) => {
if deployment.status.as_ref().unwrap().ready_replicas.unwrap_or(0).eq(&1) {
info!("Hoprd node {} deployment with uid {:?} is ready", self.name_any(), deployment.uid().unwrap());
debug!("Hoprd node {} deployment with uid {:?} is ready", self.name_any(), deployment.uid().unwrap());
return Ok(())
}
}
WatchEvent::Modified(deployment) => {
if deployment.status.as_ref().unwrap().ready_replicas.unwrap_or(0).eq(&1) {
info!("Hoprd node {} deployment with uid {:?} is ready", self.name_any(), deployment.uid().unwrap());
debug!("Hoprd node {} deployment with uid {:?} is ready", self.name_any(), deployment.uid().unwrap());
return Ok(())
}
}
WatchEvent::Deleted(_) => {
return Err(Error::ClusterHoprdSynchError("Deleted operation not expected".to_owned()))
}
WatchEvent::Bookmark(_) => {
return Err(Error::ClusterHoprdSynchError("Bookmark operation not expected".to_owned()))
warn!("Hoprd node {} deployment bookmarked", self.name_any());
return Ok(())
}
WatchEvent::Error(_) => {
return Err(Error::ClusterHoprdSynchError("Error operation not expected".to_owned()))
Expand Down
2 changes: 0 additions & 2 deletions src/identity_hoprd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ impl IdentityHoprd {
if identity_pool_option.is_some() {
let mut identity_pool_arc = identity_pool_option.unwrap();
let identity_pool: &mut IdentityPool = Arc::<IdentityPool>::make_mut(&mut identity_pool_arc);
context_data.send_event(identity_pool, IdentityPoolEventEnum::IdentityDeleted, Some(identity_name.to_owned())).await;
identity_pool.update_phase(context_data.client.clone(), IdentityPoolPhaseEnum::IdentityDeleted).await?;
context_state.update_identity_pool(identity_pool.to_owned());
} else {
Expand Down Expand Up @@ -286,7 +285,6 @@ impl IdentityHoprd {
let mut context_state = context_data.state.write().await;
let mut identity_pool_arc = context_state.get_identity_pool(&self.namespace().unwrap(), &self.spec.identity_pool_name).unwrap();
let identity_pool: &mut IdentityPool = Arc::<IdentityPool>::make_mut(&mut identity_pool_arc);
context_data.send_event(identity_pool, IdentityPoolEventEnum::Unlocked, Some(self.name_any())).await;
identity_pool.update_phase(context_data.client.clone(), IdentityPoolPhaseEnum::Unlocked).await?;
context_state.update_identity_pool(identity_pool.to_owned());
}
Expand Down
2 changes: 1 addition & 1 deletion test-data/cluster-hoprd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
hoprds.hoprnet.org/pullRequest: "1234"
namespace: hoprd-operator
spec:
identityPoolName: pool-hoprd-operator
identityPoolName: identity-pool-hoprd-operator
replicas: 1
version: latest
enabled: true
Expand Down
4 changes: 2 additions & 2 deletions test-data/hoprd-node-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
namespace: hoprd-operator
spec:
version: latest
identityPoolName: pool-hoprd-operator
identityName: pool-hoprd-operator-2
identityPoolName: identity-pool-hoprd-operator
identityName: identity-pool-hoprd-operator-1
enabled: true
config: |
hopr:
Expand Down

0 comments on commit a9ef79b

Please sign in to comment.