Skip to content

Commit

Permalink
OpenDuT deployment: added match to determine peer state while open a …
Browse files Browse the repository at this point in the history
…connection.
  • Loading branch information
mtwardawski committed May 2, 2024
1 parent 6940e72 commit 3003212
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions doc/src/user-manual/cleo/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ OPENDUT_CLEO_NETWORK_OIDC_CLIENT_ISSUER_URL
The script will not set the environment variables for CLIENT_ID and CLIENT_SECRET. This has to be done by the users themselves.
This can easily be done by entering the following commands:
````
export OPENDUT_CLEO_NETWORK_OIDC_CLIENT_ID={{ CLIENT ID VARIBALE }}
export OPENDUT_CLEO_NETWORK_OIDC_CLIENT_SECRET={{ CLIENT SECRET VARIBALE }}
export OPENDUT_CLEO_NETWORK_OIDC_CLIENT_ID={{ CLIENT ID VARIABLE }}
export OPENDUT_CLEO_NETWORK_OIDC_CLIENT_SECRET={{ CLIENT SECRET VARIABLE }}
````
These two variables can be obtained by logging in to Keycloak.

Expand All @@ -53,7 +53,7 @@ it has to be created manually.
1. Download archive from `https://{CARL-HOST}/api/cleo/{architecture}/download`
2. Extract `tar xvf opendut-cleo-{architecture}.tar.gz`
3. Execute `source set-env-var.sh`
4. Add two environment variable `export OPENDUT_CLEO_NETWORK_OIDC_CLIENT_ID={{ CLIENT ID VARIBALE }}` and `export OPENDUT_CLEO_NETWORK_OIDC_CLIENT_SECRET={{ CLIENT SECRET VARIBALE }}`
4. Add two environment variable `export OPENDUT_CLEO_NETWORK_OIDC_CLIENT_ID={{ CLIENT ID VARIABLE }}` and `export OPENDUT_CLEO_NETWORK_OIDC_CLIENT_SECRET={{ CLIENT SECRET VARIABLE }}`
5. (Optional) Check if certificate exists at location provided by `OPENDUT_CLEO_NETWORK_TLS_CA`.

## Additional notes
Expand Down
12 changes: 11 additions & 1 deletion opendut-carl/src/peer/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use opendut_carl_api::proto::services::peer_messaging_broker::upstream;
use opendut_types::peer::PeerId;
use opendut_types::peer::configuration::PeerConfiguration;
use opendut_types::peer::state::{PeerState, PeerUpState};
use opendut_types::ShortName;

use crate::resources::manager::ResourcesManagerRef;

Expand Down Expand Up @@ -94,6 +95,15 @@ impl PeerMessagingBroker {
}

self.resources_manager.resources_mut(|resources| {
match resources.get::<PeerState>(peer_id) {
None => {
info!("Peer <{}> opened stream which has not been seen before.", peer_id);
}
Some(peer_state) => {
debug!("Peer <{}> opened stream which was previously in state: {}", peer_id, peer_state.short_name());
}
};

resources.update::<PeerState>(peer_id)
.modify(|peer_state| match peer_state {
PeerState::Up { inner: _, remote_host: peer_remote_host } => {
Expand All @@ -115,7 +125,7 @@ impl PeerMessagingBroker {
error!("Failed to send ApplyPeerConfiguration message: {error}")
};
} else {
error!("Failed to send ApplyPeerConfiguration message, because no PeerConfiguration found for peer: {peer_id}")
error!("Failed to send ApplyPeerConfiguration message, because no PeerConfiguration found for peer <{peer_id}>.")
}

let timeout_duration = self.options.peer_disconnect_timeout;
Expand Down

0 comments on commit 3003212

Please sign in to comment.