Skip to content

Commit

Permalink
fix: regression on deleting objects in the simulated environment
Browse files Browse the repository at this point in the history
  • Loading branch information
drmorr0 committed Oct 9, 2024
1 parent 333e6fc commit ab9a909
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sk-driver/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ pub async fn run_trace(ctx: DriverContext, client: kube::Client) -> EmptyResult

for obj in &evt.deleted_objs {
info!("deleting object {}", obj.namespaced_name());
let virtual_ns = format!("{}-{}", ctx.virtual_ns_prefix, obj.namespace().unwrap());
let mut vobj = obj.clone();
vobj.metadata.namespace = Some(virtual_ns);
apiset
.api_for_obj(obj)
.api_for_obj(&vobj)
.await?
.delete(&obj.name_any(), &Default::default())
.await?;
Expand Down
12 changes: 11 additions & 1 deletion sk-driver/src/tests/data/trace.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,17 @@
}
}
],
"deleted_objs": []
"deleted_objs": [
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "nginx-deployment-2",
"namespace": "default"
},
"spec": {}
}
]
}
],
{
Expand Down
6 changes: 6 additions & 0 deletions sk-driver/src/tests/runner_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ async fn itest_run(#[case] has_start_marker: bool) {
));
then.json_body(status_ok());
})
.handle(|when, then| {
when.method(DELETE).path(format!(
"/apis/apps/v1/namespaces/{TEST_VIRT_NS_PREFIX}-{TEST_NS_NAME}/deployments/nginx-deployment-2"
));
then.json_body(status_ok());
})
.handle(|when, then| {
when.path(format!("/apis/simkube.io/v1/simulationroots/{TEST_DRIVER_ROOT_NAME}"))
.method(DELETE);
Expand Down

0 comments on commit ab9a909

Please sign in to comment.