From fd9742c69136c967061d092b291eec1088cab5a7 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Mon, 15 Nov 2021 08:10:57 -0800 Subject: [PATCH 1/3] Return okay if instance to delete DNE Signed-off-by: Kate Goldenring --- shared/src/akri/instance.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shared/src/akri/instance.rs b/shared/src/akri/instance.rs index 3e7caefd1..ce5023af2 100644 --- a/shared/src/akri/instance.rs +++ b/shared/src/akri/instance.rs @@ -250,7 +250,12 @@ pub async fn delete_instance( "delete_instance kube_client.request returned kube error: {:?}", ae ); - Err(ae.into()) + // If not found (404 code), return okay. + if ae.code == 404 { + Ok(()) + } else { + Err(ae.into()) + } } Err(e) => { log::trace!("delete_instance kube_client.request error: {:?}", e); From 15791719f84dbeab440282f8712afc51b3045bae Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Mon, 15 Nov 2021 08:47:35 -0800 Subject: [PATCH 2/3] fix try_delete_instance Signed-off-by: Kate Goldenring --- shared/src/akri/instance.rs | 7 +--- shared/src/k8s/mod.rs | 79 +++++++++++++++++++++++++++---------- 2 files changed, 59 insertions(+), 27 deletions(-) diff --git a/shared/src/akri/instance.rs b/shared/src/akri/instance.rs index ce5023af2..3e7caefd1 100644 --- a/shared/src/akri/instance.rs +++ b/shared/src/akri/instance.rs @@ -250,12 +250,7 @@ pub async fn delete_instance( "delete_instance kube_client.request returned kube error: {:?}", ae ); - // If not found (404 code), return okay. - if ae.code == 404 { - Ok(()) - } else { - Err(ae.into()) - } + Err(ae.into()) } Err(e) => { log::trace!("delete_instance kube_client.request error: {:?}", e); diff --git a/shared/src/k8s/mod.rs b/shared/src/k8s/mod.rs index e0a50efce..e34f6561b 100644 --- a/shared/src/k8s/mod.rs +++ b/shared/src/k8s/mod.rs @@ -533,30 +533,19 @@ pub async fn try_delete_instance( break; } Err(e) => { - // Check if already was deleted else return error - match kube_interface - .find_instance(instance_name, instance_namespace) - .await - { - Err(e) => { - if let Some(kube::Error::Api(ae)) = e.downcast_ref::() { - if ae.code == ERROR_NOT_FOUND { - log::trace!( - "try_delete_instance - discovered Instance {} already deleted", - instance_name - ); - break; - } - log::error!("try_delete_instance - when looking up Instance {}, got kube API error: {:?}", instance_name, ae); - } - } - Ok(_) => { - log::error!( - "try_delete_instance - tried to delete Instance {} but still exists. {} retries left.", - instance_name, MAX_INSTANCE_UPDATE_TRIES - x - 1 + if let Some(ae) = e.downcast_ref::() { + if ae.code == ERROR_NOT_FOUND { + log::trace!( + "try_delete_instance - discovered Instance {} already deleted", + instance_name ); + break; } } + log::error!( + "try_delete_instance - tried to delete Instance {} but still exists. {} retries left.", + instance_name, MAX_INSTANCE_UPDATE_TRIES - x - 1 + ); if x == MAX_INSTANCE_UPDATE_TRIES - 1 { return Err(e); } @@ -571,6 +560,54 @@ pub async fn try_delete_instance( pub mod test_ownership { use super::*; + #[tokio::test] + async fn test_try_delete_instance() { + let mut mock_kube_interface = MockKubeInterface::new(); + mock_kube_interface + .expect_delete_instance() + .times(1) + .returning(move |_, _| { + let error_response = kube::error::ErrorResponse { + status: "random".to_string(), + message: "blah".to_string(), + reason: "NotFound".to_string(), + code: 404, + }; + Err(error_response.into()) + }); + try_delete_instance(&mock_kube_interface, "instance_name", "instance_namespace") + .await + .unwrap(); + } + + // Test that succeeds on second try + #[tokio::test] + async fn test_try_delete_instance_sequence() { + let mut seq = mockall::Sequence::new(); + let mut mock_kube_interface = MockKubeInterface::new(); + mock_kube_interface + .expect_delete_instance() + .times(1) + .returning(move |_, _| { + let error_response = kube::error::ErrorResponse { + status: "random".to_string(), + message: "blah".to_string(), + reason: "SomeError".to_string(), + code: 401, + }; + Err(error_response.into()) + }) + .in_sequence(&mut seq); + mock_kube_interface + .expect_delete_instance() + .times(1) + .returning(move |_, _| Ok(())) + .in_sequence(&mut seq); + try_delete_instance(&mock_kube_interface, "instance_name", "instance_namespace") + .await + .unwrap(); + } + #[tokio::test] async fn test_ownership_from_config() { let name = "asdf"; From 9846b7ef0ad12c19e6ede827cda0e6061b09af6f Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Mon, 15 Nov 2021 09:11:35 -0800 Subject: [PATCH 3/3] increase version Signed-off-by: Kate Goldenring --- Cargo.lock | 28 +++++++++---------- agent/Cargo.toml | 2 +- controller/Cargo.toml | 2 +- deployment/helm/Chart.yaml | 4 +-- .../debug-echo-discovery-handler/Cargo.toml | 2 +- .../onvif-discovery-handler/Cargo.toml | 2 +- .../opcua-discovery-handler/Cargo.toml | 2 +- .../udev-discovery-handler/Cargo.toml | 2 +- discovery-handlers/debug-echo/Cargo.toml | 2 +- discovery-handlers/onvif/Cargo.toml | 2 +- discovery-handlers/opcua/Cargo.toml | 2 +- discovery-handlers/udev/Cargo.toml | 2 +- discovery-utils/Cargo.toml | 2 +- samples/brokers/udev-video-broker/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- version.txt | 2 +- webhooks/validating/configuration/Cargo.toml | 2 +- 17 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86073741b..e952b23c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -333,7 +333,7 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "agent" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-debug-echo", "akri-discovery-utils", @@ -390,7 +390,7 @@ dependencies = [ [[package]] name = "akri-debug-echo" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-discovery-utils", "akri-shared", @@ -410,7 +410,7 @@ dependencies = [ [[package]] name = "akri-discovery-utils" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-shared", "anyhow", @@ -432,7 +432,7 @@ dependencies = [ [[package]] name = "akri-onvif" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-discovery-utils", "akri-shared", @@ -461,7 +461,7 @@ dependencies = [ [[package]] name = "akri-opcua" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-discovery-utils", "akri-shared", @@ -485,7 +485,7 @@ dependencies = [ [[package]] name = "akri-shared" -version = "0.7.1" +version = "0.7.2" dependencies = [ "anyhow", "async-trait", @@ -514,7 +514,7 @@ dependencies = [ [[package]] name = "akri-udev" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-discovery-utils", "anyhow", @@ -980,7 +980,7 @@ checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" [[package]] name = "controller" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-shared", "anyhow", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "debug-echo-discovery-handler" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-debug-echo", "akri-discovery-utils", @@ -2428,7 +2428,7 @@ checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" [[package]] name = "onvif-discovery-handler" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-discovery-utils", "akri-onvif", @@ -2512,7 +2512,7 @@ dependencies = [ [[package]] name = "opcua-discovery-handler" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-discovery-utils", "akri-opcua", @@ -4343,7 +4343,7 @@ dependencies = [ [[package]] name = "udev-discovery-handler" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-discovery-utils", "akri-udev", @@ -4354,7 +4354,7 @@ dependencies = [ [[package]] name = "udev-video-broker" -version = "0.7.1" +version = "0.7.2" dependencies = [ "akri-shared", "env_logger", @@ -4617,7 +4617,7 @@ dependencies = [ [[package]] name = "webhook-configuration" -version = "0.7.1" +version = "0.7.2" dependencies = [ "actix", "actix-rt 2.3.0", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index c7448fd27..b7812f1bc 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "agent" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring ", ""] edition = "2018" diff --git a/controller/Cargo.toml b/controller/Cargo.toml index eb3c9fa69..8ba4ee280 100644 --- a/controller/Cargo.toml +++ b/controller/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "controller" -version = "0.7.1" +version = "0.7.2" authors = [""] edition = "2018" diff --git a/deployment/helm/Chart.yaml b/deployment/helm/Chart.yaml index aa0057172..51a21b66b 100644 --- a/deployment/helm/Chart.yaml +++ b/deployment/helm/Chart.yaml @@ -15,9 +15,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.7.1 +version: 0.7.2 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 0.7.1 +appVersion: 0.7.2 diff --git a/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml b/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml index 25265734b..09d931fdf 100644 --- a/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "debug-echo-discovery-handler" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handler-modules/onvif-discovery-handler/Cargo.toml b/discovery-handler-modules/onvif-discovery-handler/Cargo.toml index 1877adabd..bd8cd478a 100644 --- a/discovery-handler-modules/onvif-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/onvif-discovery-handler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "onvif-discovery-handler" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handler-modules/opcua-discovery-handler/Cargo.toml b/discovery-handler-modules/opcua-discovery-handler/Cargo.toml index 99b39f749..98569a04a 100644 --- a/discovery-handler-modules/opcua-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/opcua-discovery-handler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opcua-discovery-handler" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handler-modules/udev-discovery-handler/Cargo.toml b/discovery-handler-modules/udev-discovery-handler/Cargo.toml index 6eff672c1..cc0ce99ab 100644 --- a/discovery-handler-modules/udev-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/udev-discovery-handler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "udev-discovery-handler" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handlers/debug-echo/Cargo.toml b/discovery-handlers/debug-echo/Cargo.toml index 9c97b1c1c..9ee9f96a6 100644 --- a/discovery-handlers/debug-echo/Cargo.toml +++ b/discovery-handlers/debug-echo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-debug-echo" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handlers/onvif/Cargo.toml b/discovery-handlers/onvif/Cargo.toml index bb9348f4e..5bffd301b 100644 --- a/discovery-handlers/onvif/Cargo.toml +++ b/discovery-handlers/onvif/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-onvif" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handlers/opcua/Cargo.toml b/discovery-handlers/opcua/Cargo.toml index 3eee18c15..3eb8b7a3f 100644 --- a/discovery-handlers/opcua/Cargo.toml +++ b/discovery-handlers/opcua/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-opcua" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-handlers/udev/Cargo.toml b/discovery-handlers/udev/Cargo.toml index 91df81989..66cd0793a 100644 --- a/discovery-handlers/udev/Cargo.toml +++ b/discovery-handlers/udev/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-udev" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring "] edition = "2018" diff --git a/discovery-utils/Cargo.toml b/discovery-utils/Cargo.toml index 013ab48e2..6a720136a 100644 --- a/discovery-utils/Cargo.toml +++ b/discovery-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-discovery-utils" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring "] edition = "2018" diff --git a/samples/brokers/udev-video-broker/Cargo.toml b/samples/brokers/udev-video-broker/Cargo.toml index def4169d7..7cb4e9c4b 100644 --- a/samples/brokers/udev-video-broker/Cargo.toml +++ b/samples/brokers/udev-video-broker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "udev-video-broker" -version = "0.7.1" +version = "0.7.2" authors = ["Kate Goldenring ", ""] edition = "2018" diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 8ea74c7ba..1ffd6bd69 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "akri-shared" -version = "0.7.1" +version = "0.7.2" authors = [""] edition = "2018" diff --git a/version.txt b/version.txt index 39e898a4f..7486fdbc5 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.7.1 +0.7.2 diff --git a/webhooks/validating/configuration/Cargo.toml b/webhooks/validating/configuration/Cargo.toml index 398ee82eb..221e74853 100644 --- a/webhooks/validating/configuration/Cargo.toml +++ b/webhooks/validating/configuration/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "webhook-configuration" -version = "0.7.1" +version = "0.7.2" authors = ["DazWilkin "] edition = "2018"