Skip to content

Commit

Permalink
Add some explanationes on wait's tracing and use tokio_async_drop for…
Browse files Browse the repository at this point in the history
… c8d leases

Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
  • Loading branch information
jprendes committed Mar 4, 2025
1 parent e465df2 commit 82d4960
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/containerd-shim-wasm/src/sandbox/containerd/lease.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use containerd_client::services::v1::DeleteRequest;
use containerd_client::services::v1::leases_client::LeasesClient;
use containerd_client::tonic::transport::Channel;
use containerd_client::{tonic, with_namespace};
use tokio_async_drop::tokio_async_drop;
use tonic::Request;

// Adds lease info to grpc header
Expand Down Expand Up @@ -74,7 +75,7 @@ impl LeaseGuardInner {
impl Drop for LeaseGuard {
fn drop(&mut self) {
let inner = self.inner.take().unwrap();
tokio::spawn(async move {
tokio_async_drop!({
match inner.release().await {
Ok(()) => log::info!("removed lease"),
Err(err) => log::warn!("error removing lease: {err}"),
Expand Down
6 changes: 6 additions & 0 deletions crates/containerd-shim-wasm/src/sandbox/shim/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ impl<T: Instance + Sync + Send, E: EventSender> Task for Local<T, E> {
let parent_span = Span::current();
parent_span.set_parent(extract_context(&_ctx.metadata));

// This future never completes as it runs an infinite loop.
// It will stop executing when dropped.
// We need to keep this future's lifetime tied to this
// method's lifetime.
// This means we shouldn't tokio::spawn it, but ruther
// tokio::select! it inside of this async method.
async move {
loop {
let current_span =
Expand Down

0 comments on commit 82d4960

Please sign in to comment.