Skip to content

Commit 32dec7b

Browse files
committed
Remove await_change
As per kube-rs docs, await_change is unadvisable for cases where eventual consistency is desired because reconcile events can be lost occasionally. We saw this happen in tests where owned resources with finalizers stayed behind after TEC deletion. Instead, requeue after 1 minute (ongoing deletion cases) or 5 minutes (resources applied cases). This is shorter than kube-rs's "sane default" of 60 minutes, but aligns better with testing, user expectations, and is also what KubeVirt appears to be doing. Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
1 parent 2f61d4c commit 32dec7b

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

operator/src/reference_values.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ async fn image_add_reconcile(
291291
}
292292

293293
let (action, reason) = match handle_new_image(client.clone(), image).await {
294-
Ok(reason) => (Action::await_change(), reason),
294+
Ok(reason) => (Action::requeue(Duration::from_secs(300)), reason),
295295
Err(e) => {
296296
warn!("PCR computation for {name} failed: {e}");
297297
let action = Action::requeue(Duration::from_secs(60));
@@ -320,7 +320,7 @@ async fn image_remove_reconcile(
320320
let name = image.metadata.name.as_ref().unwrap_or(&default);
321321
if cluster.is_none() {
322322
info!("No TrustedExecutionCluster found, skipping disallow_image for {name}");
323-
return Ok(Action::await_change());
323+
return Ok(Action::requeue(Duration::from_secs(60)));
324324
}
325325
let cluster = cluster.unwrap();
326326
let tec_name = cluster.metadata.name.unwrap_or("<no name>".to_string());
@@ -329,10 +329,10 @@ async fn image_remove_reconcile(
329329
"TrustedExecutionCluster {tec_name} is being deleted, \
330330
skipping disallow_image for {name}"
331331
);
332-
return Ok(Action::await_change());
332+
return Ok(Action::requeue(Duration::from_secs(60)));
333333
}
334334
disallow_image(client, name).await?;
335-
Ok(Action::await_change())
335+
Ok(Action::requeue(Duration::from_secs(60)))
336336
}
337337

338338
pub async fn launch_rv_image_controller(client: Client) {

operator/src/register_server.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use kube::runtime::{
2020
};
2121
use kube::{Api, Client, Resource};
2222
use log::info;
23-
use std::{collections::BTreeMap, sync::Arc};
23+
use std::{collections::BTreeMap, sync::Arc, time::Duration};
2424

2525
use crate::trustee;
2626
use operator::*;
@@ -142,7 +142,7 @@ async fn keygen_reconcile(
142142
trustee::mount_secret(kube_client, id).await
143143
}
144144
.await
145-
.map(|_| Action::await_change())
145+
.map(|_| Action::requeue(Duration::from_secs(300)))
146146
.map_err(|e| finalizer::Error::<ControllerError>::ApplyFailed(e.into()))
147147
}
148148
Event::Cleanup(machine) => {
@@ -168,7 +168,7 @@ async fn keygen_reconcile(
168168
skipping unmount_secret for Machine {}",
169169
machine.metadata.name.as_deref().unwrap_or("unknown")
170170
);
171-
return Ok(Action::await_change());
171+
return Ok(Action::requeue(Duration::from_secs(60)));
172172
}
173173
Err(kube::Error::Api(ae)) if ae.code == 404 => {
174174
// TEC already deleted, skip unmount_secret
@@ -177,7 +177,7 @@ async fn keygen_reconcile(
177177
skipping unmount_secret for Machine {}",
178178
machine.metadata.name.as_deref().unwrap_or("unknown")
179179
);
180-
return Ok(Action::await_change());
180+
return Ok(Action::requeue(Duration::from_secs(60)));
181181
}
182182
_ => {
183183
// TEC exists and is not being deleted, proceed with unmount_secret
@@ -187,7 +187,7 @@ async fn keygen_reconcile(
187187

188188
trustee::unmount_secret(kube_client, id)
189189
.await
190-
.map(|_| Action::await_change())
190+
.map(|_| Action::requeue(Duration::from_secs(60)))
191191
.map_err(|e| finalizer::Error::<ControllerError>::CleanupFailed(e.into()))
192192
}
193193
}

0 commit comments

Comments
 (0)