Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return okay if get 404 when trying to delete an Instance #420

Merged
merged 3 commits into from
Nov 15, 2021
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
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "agent"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>", "<[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion controller/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "controller"
version = "0.7.1"
version = "0.7.2"
authors = ["<[email protected]>"]
edition = "2018"

Expand Down
4 changes: 2 additions & 2 deletions deployment/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "debug-echo-discovery-handler"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "onvif-discovery-handler"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opcua-discovery-handler"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "udev-discovery-handler"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/debug-echo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-debug-echo"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/onvif/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-onvif"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/opcua/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-opcua"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/udev/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-udev"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-discovery-utils"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion samples/brokers/udev-video-broker/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "udev-video-broker"
version = "0.7.1"
version = "0.7.2"
authors = ["Kate Goldenring <[email protected]>", "<[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "akri-shared"
version = "0.7.1"
version = "0.7.2"
authors = ["<[email protected]>"]
edition = "2018"

Expand Down
79 changes: 58 additions & 21 deletions shared/src/k8s/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<kube::Error>() {
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::<kube::error::ErrorResponse>() {
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);
}
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.1
0.7.2
2 changes: 1 addition & 1 deletion webhooks/validating/configuration/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "webhook-configuration"
version = "0.7.1"
version = "0.7.2"
authors = ["DazWilkin <[email protected]>"]
edition = "2018"

Expand Down