From c63c26137d427184a388176b1f29ddbc6ff3a322 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Sun, 16 Mar 2025 05:33:12 +0100 Subject: [PATCH] Add more logging --- src/lldap.rs | 1 + src/resources.rs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lldap.rs b/src/lldap.rs index 9a6c81f..4c70c39 100644 --- a/src/lldap.rs +++ b/src/lldap.rs @@ -54,6 +54,7 @@ impl LldapConfig { } pub async fn build_client(&self) -> Result { + debug!("Creating LLDAP client"); let timeout = Duration::from_secs(1); let client = reqwest::ClientBuilder::new().timeout(timeout).build()?; diff --git a/src/resources.rs b/src/resources.rs index 46b929f..b9f0274 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -13,7 +13,7 @@ use passwords::PasswordGenerator; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_json::json; -use tracing::{debug, instrument}; +use tracing::{debug, instrument, trace}; use crate::context::{Context, ControllerEvents}; use crate::lldap; @@ -110,6 +110,7 @@ impl ServiceUser { let secrets = Api::::namespaced(client.clone(), &namespace); // TODO: Potentially issue: someone modifies the secret and removes the pass + trace!(name, "Get or create secret"); let mut created = false; let mut secret = secrets .entry(&secret_name) @@ -124,6 +125,7 @@ impl ServiceUser { new_secret(&username, oref) }); + trace!(name, "Committing secret"); secret .commit(&PostParams { dry_run: false, @@ -133,6 +135,7 @@ impl ServiceUser { let secret = secret; if created { + trace!(name, "Sending secret creating notification"); // The reason this is here instead of inside the or_insert is that we // want to send the event _after_ it successfully committed. // Also or_insert is not async! @@ -143,6 +146,7 @@ impl ServiceUser { let lldap_client = ctx.lldap_config.build_client().await?; + trace!(name, "Creating user if needed"); if lldap_client.list_users().await?.any(|id| id == username) { debug!(name, username, "User already exists"); } else { @@ -152,10 +156,12 @@ impl ServiceUser { ctx.recorder.user_created(self.as_ref(), &username).await?; } + trace!(name, "Updating password"); let password = secret.get().data.as_ref().unwrap().get("password").unwrap(); let password = from_utf8(&password.0).unwrap(); lldap_client.update_password(&username, password).await?; + trace!(name, "Updating status"); let service_users = Api::::namespaced(client.clone(), &namespace); let status = json!({ "status": ServiceUserStatus { secret_created: secret.get().meta().creation_timestamp.as_ref().map(|ts| ts.0) }