Skip to content

Commit c56e1c5

Browse files
committed
Finalizer calling logging
Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
1 parent ccbc432 commit c56e1c5

5 files changed

Lines changed: 33 additions & 31 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ concurrency:
2222
env:
2323
CARGO_TERM_COLOR: always
2424
# Pinned toolchain for linting
25-
ACTIONS_LINTS_TOOLCHAIN: 1.88.0
25+
ACTIONS_LINTS_TOOLCHAIN: 1.89.0
2626

2727
jobs:
2828
linting:

Cargo.lock

Lines changed: 18 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resolver = "3"
99

1010
[workspace.package]
1111
edition = "2024"
12-
rust-version = "1.88"
12+
rust-version = "1.89"
1313

1414
[workspace.dependencies]
1515
anyhow = "1.0.102"
@@ -23,7 +23,7 @@ env_logger = { version = "0.11.10", default-features = false, features = ["human
2323
http = "1.4.2"
2424
ignition-config = "0.6.1"
2525
k8s-openapi = { version = "0.28.0", features = ["v1_35", "schemars"] }
26-
kube = { version = "4.0.0", default-features = false, features = ["derive", "runtime", "openssl-tls"] }
26+
kube = { git = "https://github.com/Jakob-Naucke/kube-rs", branch = "finalizer-dbg", default-features = false, features = ["derive", "runtime", "openssl-tls"] }
2727
log = "0.4.32"
2828
serde = { version = "1.0.228", features = ["derive"] }
2929
serde_json = "1.0.150"

operator/src/reference_values.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ async fn image_reconcile(
230230
let cluster = get_opt_trusted_execution_cluster(kube_client.clone())
231231
.await
232232
.map_err(|e| -> ControllerError { e.into() })?;
233+
info!("image {image:?}");
233234

234235
let uid_owns = |uid: &String| {
235236
let refs = image.metadata.owner_references.as_ref();
@@ -249,7 +250,7 @@ async fn image_reconcile(
249250
}
250251

251252
let images: Api<ApprovedImage> = Api::default_namespaced(kube_client.clone());
252-
finalizer(&images, APPROVED_IMAGE_FINALIZER, image, |ev| async {
253+
let result = finalizer(&images, APPROVED_IMAGE_FINALIZER, image, |ev| async {
253254
match ev {
254255
Event::Apply(image) => image_add_reconcile(kube_client, &image, cluster)
255256
.await
@@ -259,8 +260,9 @@ async fn image_reconcile(
259260
.map_err(|e| finalizer::Error::<ControllerError>::CleanupFailed(e.into())),
260261
}
261262
})
262-
.await
263-
.map_err(|e| anyhow!("failed to reconcile on image {name}: {e}").into())
263+
.await;
264+
info!("finalizer() for image {name} returned {result:?}");
265+
result.map_err(|e| anyhow!("failed to reconcile on image {name}: {e}").into())
264266
}
265267

266268
async fn image_add_reconcile(
@@ -306,6 +308,7 @@ async fn image_remove_reconcile(
306308
) -> Result<Action> {
307309
let default = "<no name>".to_string();
308310
let name = image.metadata.name.as_ref().unwrap_or(&default);
311+
info!("Cleanup for image {image:?}");
309312
if cluster.is_none() {
310313
info!("No TrustedExecutionCluster found, skipping disallow_image for {name}");
311314
return Ok(Action::await_change());

operator/src/register_server.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ async fn keygen_reconcile(
131131
) -> Result<Action, ControllerError> {
132132
let kube_client_clone = Arc::unwrap_or_clone(client.clone());
133133
let machines: Api<Machine> = Api::default_namespaced(kube_client_clone.clone());
134-
finalizer(&machines, MACHINE_FINALIZER, machine, |ev| async move {
134+
info!("machine {machine:?}");
135+
let result = finalizer(&machines, MACHINE_FINALIZER, machine, |ev| async move {
135136
match ev {
136137
Event::Apply(machine) => {
137138
let kube_client = Arc::unwrap_or_clone(client);
@@ -148,6 +149,7 @@ async fn keygen_reconcile(
148149
Event::Cleanup(machine) => {
149150
let kube_client = Arc::unwrap_or_clone(client);
150151
let id = &machine.spec.id;
152+
info!("Cleanup for machine {machine:?}");
151153

152154
// Check if the TrustedExecutionCluster is being deleted
153155
// If so, skip unmounting the secret as everything will be cleaned up
@@ -194,8 +196,9 @@ async fn keygen_reconcile(
194196
}
195197
}
196198
})
197-
.await
198-
.map_err(|e| anyhow!("failed to reconcile on machine: {e}").into())
199+
.await;
200+
info!("finalizer() for machine returned {result:?}");
201+
result.map_err(|e| anyhow!("failed to reconcile on machine: {e}").into())
199202
}
200203

201204
pub async fn launch_keygen_controller(client: Client) {

0 commit comments

Comments
 (0)