Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: regression on deleting objects in the simulated environment
Browse files Browse the repository at this point in the history
drmorr0 committed Oct 9, 2024

Verified

This commit was signed with the committer’s verified signature.
jimklimov Jim Klimov
1 parent ef1dac0 commit 8518d5b
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
@@ -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?;
12 changes: 11 additions & 1 deletion sk-driver/src/tests/data/trace.json
Original file line number Diff line number Diff line change
@@ -93,7 +93,17 @@
}
}
],
"deleted_objs": []
"deleted_objs": [
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "nginx-deployment-2",
"namespace": "default"
},
"spec": {}
}
]
}
],
{
6 changes: 6 additions & 0 deletions sk-driver/src/tests/runner_test.rs
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 8518d5b

Please sign in to comment.