diff --git a/Cargo.lock b/Cargo.lock index a28070f..338ebba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -997,8 +997,6 @@ dependencies = [ [[package]] name = "kube" version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "977951a1d7dbce4c6f9c2cbed0711f568df9944010fafa88161a20f7e5163bd3" dependencies = [ "k8s-openapi", "kube-client", @@ -1010,8 +1008,6 @@ dependencies = [ [[package]] name = "kube-client" version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625e8a89c79dd4e590217838f32274ccbb0f4ecc1db181f84aba3df635fca729" dependencies = [ "base64", "bytes", @@ -1045,8 +1041,6 @@ dependencies = [ [[package]] name = "kube-core" version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0491dcd9adca79a96c63404aa978137f5fe1d3db5dcb6e5c0b073f915dbdd49d" dependencies = [ "chrono", "form_urlencoded", @@ -1063,8 +1057,6 @@ dependencies = [ [[package]] name = "kube-derive" version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f19faefec284e5eec6680c74cd54d29823f38f0cf8811d54265877e1963996ad" dependencies = [ "darling", "proc-macro2", @@ -1076,8 +1068,6 @@ dependencies = [ [[package]] name = "kube-runtime" version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb67002cbacd6cd99d1b1d0890785a84b6408158972f2561317bc4cdc06c981e" dependencies = [ "ahash", "backoff", diff --git a/Cargo.toml b/Cargo.toml index c8d79eb..ddf9935 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,8 +51,9 @@ tonic = { version = "0.6.2", optional = true } [dependencies.kube] features = ["runtime", "client", "derive"] -version = "0.72.0" +#version = "0.72.0" # testing new releases - ignore #git = "https://github.com/kube-rs/kube-rs.git" #rev = "7715cabd4d1976493e6b8949471f283df927a79e" +path = "../kube-rs/kube" diff --git a/src/manager.rs b/src/manager.rs index c8abd4b..f799301 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -6,7 +6,7 @@ use kube::{ api::{Api, ListParams, Patch, PatchParams, ResourceExt}, client::Client, runtime::{ - controller::{Action, Context, Controller}, + controller::{Action, Controller}, events::{Event, EventType, Recorder, Reporter}, }, CustomResource, Resource, @@ -63,15 +63,15 @@ struct Data { } #[instrument(skip(ctx, doc), fields(trace_id))] -async fn reconcile(doc: Arc, ctx: Context) -> Result { +async fn reconcile(doc: Arc, ctx: Arc) -> Result { let trace_id = telemetry::get_trace_id(); Span::current().record("trace_id", &field::display(&trace_id)); let start = Instant::now(); - ctx.get_ref().metrics.reconciliations.inc(); + ctx.metrics.reconciliations.inc(); - let client = ctx.get_ref().client.clone(); - ctx.get_ref().state.write().await.last_event = Utc::now(); - let reporter = ctx.get_ref().state.read().await.reporter.clone(); + let client = ctx.client.clone(); + ctx.state.write().await.last_event = Utc::now(); + let reporter = ctx.state.read().await.reporter.clone(); let recorder = Recorder::new(client.clone(), reporter, doc.object_ref(&())); let name = ResourceExt::name(doc.as_ref()); let ns = ResourceExt::namespace(doc.as_ref()).expect("doc is namespaced"); @@ -108,8 +108,7 @@ async fn reconcile(doc: Arc, ctx: Context) -> Result, ctx: Context) -> Result) -> Action { +fn error_policy(error: &Error, ctx: Arc) -> Action { warn!("reconcile failed: {:?}", error); - ctx.get_ref().metrics.failures.inc(); + ctx.metrics.failures.inc(); Action::requeue(Duration::from_secs(5 * 60)) } @@ -190,7 +189,7 @@ impl Manager { let client = Client::try_default().await.expect("create client"); let metrics = Metrics::new(); let state = Arc::new(RwLock::new(State::new())); - let context = Context::new(Data { + let context = Arc::new(Data { client: client.clone(), metrics: metrics.clone(), state: state.clone(),