From 9e26baa9bf7f91eab49a2bd55926f3a640b6de3a Mon Sep 17 00:00:00 2001 From: Matthias Twardawski Date: Tue, 30 Apr 2024 15:53:02 +0200 Subject: [PATCH] OpenDuT deployment: added match to determine peer state while open a connection. --- doc/src/user-manual/cleo/setup.md | 6 +++--- opendut-carl/src/peer/broker.rs | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/src/user-manual/cleo/setup.md b/doc/src/user-manual/cleo/setup.md index 29671eab2..ee9106528 100644 --- a/doc/src/user-manual/cleo/setup.md +++ b/doc/src/user-manual/cleo/setup.md @@ -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. @@ -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 diff --git a/opendut-carl/src/peer/broker.rs b/opendut-carl/src/peer/broker.rs index da00348ba..b0d0b3791 100644 --- a/opendut-carl/src/peer/broker.rs +++ b/opendut-carl/src/peer/broker.rs @@ -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; @@ -94,6 +95,15 @@ impl PeerMessagingBroker { } self.resources_manager.resources_mut(|resources| { + match resources.get::(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::(peer_id) .modify(|peer_state| match peer_state { PeerState::Up { inner: _, remote_host: peer_remote_host } => { @@ -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;