Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/sandboxwich-api/src/handlers/leases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub(crate) async fn claim_lease(
.push(
")
and (
kind in ('provision_sandbox', 'run_prompt', 'stop_sandbox')
kind in ('provision_sandbox', 'run_prompt', 'stop_sandbox', 'delete_home')
or exists (
select 1 from sandbox_placements p
where p.sandbox_id = coalesce(jobs.sandbox_id, jobs.parent_sandbox_id)
Expand Down
47 changes: 47 additions & 0 deletions crates/sandboxwich-api/tests/http_contract/homes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,53 @@ async fn managed_home_delete_is_explicit_and_asynchronous() {
.unwrap();
assert_eq!(deleting.home.state, HomeState::Deleting);
assert_eq!(deleting.operation.unwrap().kind, OperationKind::DeleteHome);

let registered: WorkerResponse = client
.post(format!("{}/workers/register", server.base_url))
.json(&RegisterWorkerRequest {
name: "managed-home-delete-worker".into(),
provider: "kubernetes".into(),
capabilities: vec![
WorkerCapability::ProvisionSandbox,
WorkerCapability::SandboxedContainer,
],
max_concurrent_jobs: Some(1),
labels: Default::default(),
})
.send()
.await
.unwrap()
.error_for_status()
.unwrap()
.json()
.await
.unwrap();
let claimed: ClaimLeaseResponse = worker_client(&registered)
.post(format!(
"{}/workers/{}/leases/claim",
server.base_url, registered.worker.id
))
.json(&ClaimLeaseRequest {
lease_seconds: Some(60),
sandbox_id: None,
kinds: Some(vec![JobKind::DeleteHome]),
})
.send()
.await
.unwrap()
.error_for_status()
.unwrap()
.json()
.await
.unwrap();
assert_eq!(
claimed
.lease
.expect("home delete must be claimable")
.job
.kind,
JobKind::DeleteHome
);
assert_eq!(
client
.delete(format!("{}/homes/{}", server.base_url, created.home.id))
Expand Down
Loading