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

controller: Stop panicking when unable to create pod. #615

Merged
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.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>", "<[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
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.11.0"
version = "0.11.1"
authors = ["<[email protected]>", "<[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
50 changes: 41 additions & 9 deletions controller/src/util/instance_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,32 +419,34 @@ pub async fn handle_instance_change(
}
};
if let Some(broker_spec) = &configuration.spec.broker_spec {
match broker_spec {
let instance_change_result = match broker_spec {
BrokerSpec::BrokerPodSpec(p) => {
handle_instance_change_pod(instance, p, action, kube_interface).await
}
BrokerSpec::BrokerJobSpec(j) => {
handle_instance_change_job(
instance.clone(),
instance,
*configuration.metadata.generation.as_ref().unwrap(),
j,
action,
kube_interface,
)
.await
}
};
if let Err(e) = instance_change_result {
error!("Unable to handle Broker action: {:?}", e);
}
} else {
Ok(())
}
Ok(())
}

/// Called when an Instance has changed that requires a Job broker. Action determined by InstanceAction.
/// InstanceAction::Add => Deploy a Job with JobSpec from Configuration. Label with Instance name.
/// InstanceAction::Remove => Delete all Jobs labeled with the Instance name
/// InstanceAction::Update => No nothing
pub async fn handle_instance_change_job(
instance: Instance,
instance: &Instance,
config_generation: i64,
job_spec: &JobSpec,
action: &InstanceAction,
Expand Down Expand Up @@ -472,7 +474,7 @@ pub async fn handle_instance_change_job(
trace!("handle_instance_change_job - instance added");
let capability_id = format!("{}/{}", AKRI_PREFIX, instance_name);
let new_job = job::create_new_job_from_spec(
&instance,
instance,
OwnershipInfo::new(
OwnershipType::Instance,
instance_name.to_string(),
Expand Down Expand Up @@ -841,13 +843,15 @@ mod handle_instance_tests {
new_pod_names: Vec<&'static str>,
new_pod_instance_names: Vec<&'static str>,
new_pod_namespaces: Vec<&'static str>,
new_pod_error: Vec<bool>,
}

fn configure_add_shared_config_a_359973(pod_name: &'static str) -> HandleAdditionWork {
HandleAdditionWork {
new_pod_names: vec![pod_name],
new_pod_instance_names: vec!["config-a-359973"],
new_pod_namespaces: vec!["config-a-namespace"],
new_pod_error: vec![false],
}
}
fn get_config_work() -> HandleConfigWork {
Expand All @@ -857,11 +861,12 @@ mod handle_instance_tests {
find_config_result: "../test/json/config-a.json",
}
}
fn configure_add_local_config_a_b494b6() -> HandleAdditionWork {
fn configure_add_local_config_a_b494b6(error: bool) -> HandleAdditionWork {
HandleAdditionWork {
new_pod_names: vec!["config-a-b494b6-pod"],
new_pod_instance_names: vec!["config-a-b494b6"],
new_pod_namespaces: vec!["config-a-namespace"],
new_pod_error: vec![error],
}
}

Expand All @@ -873,6 +878,7 @@ mod handle_instance_tests {
work.new_pod_namespaces[i],
AKRI_INSTANCE_LABEL_NAME,
work.new_pod_instance_names[i],
work.new_pod_error[i],
);
}
}
Expand Down Expand Up @@ -944,7 +950,33 @@ mod handle_instance_tests {
find_pods_delete_start_time: false,
config_work: get_config_work(),
deletion_work: None,
addition_work: Some(configure_add_local_config_a_b494b6()),
addition_work: Some(configure_add_local_config_a_b494b6(false)),
},
);
run_handle_instance_change_test(
&mut mock,
"../test/json/local-instance.json",
&InstanceAction::Add,
)
.await;
}

#[tokio::test]
async fn test_handle_instance_change_for_add_new_local_instance_error() {
let _ = env_logger::builder().is_test(true).try_init();

let mut mock = MockKubeInterface::new();
configure_for_handle_instance_change(
&mut mock,
&HandleInstanceWork {
find_pods_selector: "akri.sh/instance=config-a-b494b6",
find_pods_result: "../test/json/empty-list.json",
find_pods_phase: None,
find_pods_start_time: None,
find_pods_delete_start_time: false,
config_work: get_config_work(),
deletion_work: None,
addition_work: Some(configure_add_local_config_a_b494b6(true)),
},
);
run_handle_instance_change_test(
Expand Down Expand Up @@ -1139,7 +1171,7 @@ mod handle_instance_tests {
find_pods_delete_start_time: false,
config_work: get_config_work(),
deletion_work: None,
addition_work: Some(configure_add_local_config_a_b494b6()),
addition_work: Some(configure_add_local_config_a_b494b6(false)),
},
);
run_handle_instance_change_test(
Expand Down
6 changes: 5 additions & 1 deletion controller/src/util/shared_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ pub mod config_for_tests {
pod_namespace: &'static str,
label_id: &'static str,
label_value: &'static str,
error: bool,
) {
trace!("mock.expect_create_pod pod_name:{}", pod_name);
mock.expect_create_pod()
Expand All @@ -269,7 +270,10 @@ pub mod config_for_tests {
== label_value
&& namespace == pod_namespace
})
.returning(move |_, _| Ok(()));
.returning(move |_, _| match error {
false => Ok(()),
true => Err(anyhow::format_err!("create pod error")),
});
}

pub fn configure_remove_pod(
Expand Down
4 changes: 2 additions & 2 deletions deployment/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,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.11.0
version: 0.11.1

# 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.11.0
appVersion: 0.11.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "debug-echo-discovery-handler"
version = "0.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "onvif-discovery-handler"
version = "0.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opcua-discovery-handler"
version = "0.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "udev-discovery-handler"
version = "0.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
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.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
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.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
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.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
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.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
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.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
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.11.0"
version = "0.11.1"
authors = ["Kate Goldenring <[email protected]>", "<[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
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.11.0"
version = "0.11.1"
authors = ["<[email protected]>"]
edition = "2018"
rust-version = "1.68.1"
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.0
0.11.1
Loading
Loading