@@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize};
16
16
use serde_json:: json;
17
17
use sha3:: { Digest , Sha3_256 } ;
18
18
use std:: { sync:: Arc , time:: Duration } ;
19
- use tracing:: error;
19
+ use tracing:: { error, info , instrument } ;
20
20
21
21
use crate :: { postgres:: Postgres , Error , Network , State } ;
22
22
@@ -77,6 +77,7 @@ impl DbSyncPort {
77
77
. await
78
78
. map_err ( Error :: KubeError ) ?;
79
79
80
+ info ! ( { username } , "user created" ) ;
80
81
state. metrics . count_user_created ( & ns, & self . spec . network ) ;
81
82
} ;
82
83
@@ -88,9 +89,9 @@ impl DbSyncPort {
88
89
let ns = self . namespace ( ) . unwrap ( ) ;
89
90
let username = self . status . as_ref ( ) . unwrap ( ) . username . clone ( ) ;
90
91
pg. drop_user ( & username) . await ?;
91
- state
92
- . metrics
93
- . count_user_dropped ( & ns, & self . spec . network ) ;
92
+
93
+ info ! ( { username } , "user dropped" ) ;
94
+ state . metrics . count_user_dropped ( & ns, & self . spec . network ) ;
94
95
}
95
96
96
97
Ok ( Action :: await_change ( ) )
@@ -113,9 +114,9 @@ async fn reconcile(crd: Arc<DbSyncPort>, state: Arc<State>) -> Result<Action, Er
113
114
. map_err ( |e| Error :: FinalizerError ( Box :: new ( e) ) )
114
115
}
115
116
116
- fn error_policy ( crd : Arc < DbSyncPort > , err : & Error , state : Arc < State > ) -> Action {
117
- error ! ( "reconcile failed: {:?}" , err ) ;
118
- state. metrics . reconcile_failure ( & crd, err ) ;
117
+ fn error_policy ( crd : Arc < DbSyncPort > , error : & Error , state : Arc < State > ) -> Action {
118
+ error ! ( error = error . to_string ( ) , "reconcile failed" ) ;
119
+ state. metrics . reconcile_failure ( & crd, error ) ;
119
120
Action :: requeue ( Duration :: from_secs ( 5 ) )
120
121
}
121
122
@@ -135,12 +136,12 @@ async fn gen_username_hash(username: &str) -> Result<String, Error> {
135
136
Ok ( bech32_truncated)
136
137
}
137
138
139
+ #[ instrument( "controller run" , skip_all) ]
138
140
pub async fn run ( state : Arc < State > ) -> Result < ( ) , Error > {
141
+ info ! ( "listening crds running" ) ;
139
142
let client = Client :: try_default ( ) . await ?;
140
143
let crds = Api :: < DbSyncPort > :: all ( client. clone ( ) ) ;
141
144
142
- // let ctx = Context::new(client, state.clone());
143
-
144
145
Controller :: new ( crds, WatcherConfig :: default ( ) . any_semantic ( ) )
145
146
. shutdown_on_signal ( )
146
147
. run ( reconcile, error_policy, state)
0 commit comments