diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 0c9c3879f..0842d06df 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -33,7 +33,7 @@ jobs: - name: Rust install uses: dtolnay/rust-toolchain@master with: - toolchain: 1.73.0 + toolchain: 1.75.0 components: clippy, rustfmt - name: Install Linux requirements # TODO: When ubuntu-latest gets updated to >= 23.04 replace the wget+unzip with just protobuf-compiler in apt diff --git a/.github/workflows/run-tarpaulin.yml b/.github/workflows/run-tarpaulin.yml index 6d902bd47..3e10c3532 100644 --- a/.github/workflows/run-tarpaulin.yml +++ b/.github/workflows/run-tarpaulin.yml @@ -16,7 +16,7 @@ on: env: CARGO_TERM_COLOR: always - CARGO_VERSION: 1.73.0 + CARGO_VERSION: 1.75.0 jobs: build: diff --git a/README.md b/README.md index 80990c109..f7516ebb3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Akri Logo

[![Slack channel #akri](https://img.shields.io/badge/slack-akri-blueviolet.svg?logo=slack)](https://kubernetes.slack.com/messages/akri) -[![Rust Version](https://img.shields.io/badge/rustc-1.73.0-blue.svg)](https://blog.rust-lang.org/2023/03/31/Rust-1.73.0.html) +[![Rust Version](https://img.shields.io/badge/rustc-1.75.0-blue.svg)](https://blog.rust-lang.org/2023/03/31/Rust-1.75.0.html) [![Kubernetes Version](https://img.shields.io/badge/kubernetes-≥%201.16-blue.svg)](https://kubernetes.io/) [![codecov](https://codecov.io/gh/project-akri/akri/branch/main/graph/badge.svg?token=V468HO7CDE)](https://codecov.io/gh/project-akri/akri) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5339/badge)](https://bestpractices.coreinfrastructure.org/projects/5339) diff --git a/agent/Cargo.toml b/agent/Cargo.toml index c12918e87..ec7cd42fa 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring ", ""] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/build/setup.sh b/build/setup.sh index 9c16b080a..7cb501657 100755 --- a/build/setup.sh +++ b/build/setup.sh @@ -23,10 +23,10 @@ then if [ -x "$(command -v sudo)" ]; then echo "Install rustup" - sudo curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.73.0 + sudo curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.75.0 else echo "Install rustup" - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.73.0 + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.75.0 fi else echo "Found rustup" diff --git a/controller/Cargo.toml b/controller/Cargo.toml index be57c749f..13c551325 100644 --- a/controller/Cargo.toml +++ b/controller/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["", ""] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/controller/src/util/instance_action.rs b/controller/src/util/instance_action.rs index f7a535e12..5df0a743b 100644 --- a/controller/src/util/instance_action.rs +++ b/controller/src/util/instance_action.rs @@ -118,7 +118,7 @@ pub(crate) struct PodContext { } pub(crate) fn create_pod_context(k8s_pod: &Pod, action: PodAction) -> anyhow::Result { - let pod_name = k8s_pod.metadata.name.as_ref().unwrap(); + let pod_name = k8s_pod.name_unchecked(); let labels = &k8s_pod.labels(); // Early exits above ensure unwrap will not panic let node_to_run_pod_on = labels.get(AKRI_TARGET_NODE_LABEL_NAME).ok_or_else(|| { @@ -131,7 +131,7 @@ pub(crate) fn create_pod_context(k8s_pod: &Pod, action: PodAction) -> anyhow::Re Ok(PodContext { node_name: Some(node_to_run_pod_on.to_string()), - namespace: k8s_pod.metadata.namespace.clone(), + namespace: k8s_pod.namespace(), action, }) } @@ -143,7 +143,7 @@ fn determine_action_for_pod( k8s_pod: &Pod, nodes_to_act_on: &mut HashMap, ) -> anyhow::Result<()> { - let pod_name = k8s_pod.metadata.name.as_ref().unwrap(); + let pod_name = k8s_pod.name_unchecked(); let pod_phase = k8s_pod .status .as_ref() @@ -164,7 +164,7 @@ fn determine_action_for_pod( phase: pod_phase.to_string(), status_start_time: pod_start_time, unknown_node: !nodes_to_act_on.contains_key(node_to_run_pod_on), - trace_node_name: k8s_pod.metadata.name.clone().unwrap(), + trace_node_name: k8s_pod.name_unchecked(), }; update_pod_context.action = pod_action_info.select_pod_action()?; nodes_to_act_on.insert(node_to_run_pod_on.to_string(), update_pod_context); @@ -305,19 +305,15 @@ pub async fn handle_instance_change( ctx: Arc, ) -> Result { trace!("handle_instance_change - enter"); - let instance_namespace = instance - .metadata - .namespace - .as_ref() - .context("no namespace")?; - let api: Box> = ctx.client.namespaced(instance_namespace); + let instance_namespace = instance.namespace().unwrap(); + let api: Box> = ctx.client.namespaced(&instance_namespace); let Ok(Some(configuration)) = api.get(&instance.spec.configuration_name).await else { // In this scenario, a configuration has been deleted without the Akri Agent deleting the associated Instances. // Furthermore, Akri Agent is still modifying the Instances. This should not happen beacuse Agent // is designed to shutdown when it's Configuration watcher fails. error!( "handle_instance_change - no configuration found for {:?} yet instance {:?} exists - check that device plugin is running properly", - &instance.spec.configuration_name, &instance.metadata.name + &instance.spec.configuration_name, &instance.name_unchecked() ); return Ok(default_requeue_action()); @@ -352,41 +348,35 @@ pub async fn handle_instance_change_job( client: Arc, ) -> anyhow::Result<()> { trace!("handle_instance_change_job - enter"); - let api: Box> = client.namespaced(instance.metadata.namespace.as_ref().unwrap()); - if api - .get(instance.metadata.name.as_ref().unwrap()) - .await? - .is_some() - { + let api: Box> = client.namespaced(&instance.namespace().unwrap()); + if api.get(&instance.name_unchecked()).await?.is_some() { // Job already exists, do nothing return Ok(()); } + let instance_name = instance.name_unchecked(); // Create name for Job. Includes Configuration generation in the suffix // to track what version of the Configuration the Job is associated with. let job_name = pod::create_broker_app_name( - instance.metadata.name.as_ref().unwrap(), + &instance_name, None, instance.spec.shared, &format!("{}-job", config_generation), ); - let instance_name = instance.metadata.name.as_ref().unwrap(); - let instance_namespace = instance.metadata.namespace.as_ref().unwrap(); - let instance_uid = instance.metadata.uid.as_ref().unwrap(); 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, OwnershipInfo::new( OwnershipType::Instance, - instance_name.to_string(), - instance_uid.to_string(), + instance_name, + instance.uid().unwrap(), ), &capability_id, job_spec, &job_name, )?; - let api: Box> = client.namespaced(instance_namespace); + let api: Box> = client.namespaced(&instance.namespace().unwrap()); // TODO: Consider using server side apply instead of create api.create(&new_job).await?; Ok(()) @@ -405,8 +395,6 @@ pub async fn handle_instance_change_pod( ) -> anyhow::Result<()> { trace!("handle_instance_change_pod - enter"); - let instance_name = instance.metadata.name.clone().unwrap(); - // If InstanceAction::Remove, assume all nodes require PodAction::NoAction (reflect that there is no running Pod unless we find one) // Otherwise, assume all nodes require PodAction::Add (reflect that there is no running Pod, unless we find one) let default_action = PodAction::Add; @@ -430,8 +418,11 @@ pub async fn handle_instance_change_pod( nodes_to_act_on ); - let lp = - ListParams::default().labels(&format!("{}={}", AKRI_INSTANCE_LABEL_NAME, instance_name)); + let lp = ListParams::default().labels(&format!( + "{}={}", + AKRI_INSTANCE_LABEL_NAME, + instance.name_unchecked() + )); let api = ctx .client .namespaced(&instance.namespace().context("no namespace")?); @@ -473,7 +464,7 @@ pub(crate) async fn do_pod_action_for_nodes( ((v.action) == PodAction::Remove) | ((v.action) == PodAction::RemoveAndAdd) }) { handle_deletion_work( - instance.metadata.name.as_ref().unwrap(), + &instance.name_unchecked(), &instance.spec.configuration_name, instance.spec.shared, node_to_delete_pod, @@ -496,17 +487,17 @@ pub(crate) async fn do_pod_action_for_nodes( .collect::>(); // Iterate over nodes_to_act_on where value == (PodAction::Add | PodAction::RemoveAndAdd) - let instance_name = instance.metadata.name.clone().unwrap(); + let instance_name = instance.name_unchecked(); let capability_id = format!("{}/{}", AKRI_PREFIX, instance_name); for new_node in nodes_to_add { let new_pod = pod::create_new_pod_from_spec( - instance.metadata.namespace.as_ref().unwrap(), + &instance.namespace().unwrap(), &instance_name, &instance.spec.configuration_name, OwnershipInfo::new( OwnershipType::Instance, instance_name.clone(), - instance.metadata.uid.clone().unwrap(), + instance.uid().unwrap(), ), &capability_id, &new_node, diff --git a/controller/src/util/node_watcher.rs b/controller/src/util/node_watcher.rs index a188215c4..a82bcc2f1 100644 --- a/controller/src/util/node_watcher.rs +++ b/controller/src/util/node_watcher.rs @@ -89,7 +89,7 @@ pub async fn reconcile(node: Arc, ctx: Arc) -> Result, ctx: Arc) -> Result { match event { Event::Apply(node) => { - let node_name = node.metadata.name.clone().unwrap(); + let node_name = node.name_unchecked(); info!("handle_node - Added or modified: {}", node_name); if is_node_ready(&node) { ctx.known_nodes @@ -109,12 +109,9 @@ async fn reconcile_inner(event: Event, ctx: Arc) -> Res Ok(Action::await_change()) } Event::Cleanup(node) => { - info!("handle_node - Deleted: {:?}", &node.metadata.name); + info!("handle_node - Deleted: {:?}", &node.name_unchecked()); call_handle_node_disappearance_if_needed(&node, ctx.clone()).await?; - ctx.known_nodes - .write() - .await - .remove(&node.metadata.name.as_deref().unwrap().to_string()); + ctx.known_nodes.write().await.remove(&node.name_unchecked()); Ok(Action::await_change()) } } @@ -126,7 +123,7 @@ async fn call_handle_node_disappearance_if_needed( node: &Node, ctx: Arc, ) -> anyhow::Result<()> { - let node_name = node.metadata.name.as_deref().unwrap(); + let node_name = node.name_unchecked(); trace!( "call_handle_node_disappearance_if_needed - enter: {:?}", &node.metadata.name @@ -135,7 +132,7 @@ async fn call_handle_node_disappearance_if_needed( .known_nodes .read() .await - .get(node_name) + .get(&node_name) .unwrap_or(&NodeState::Running) .clone(); trace!( @@ -152,7 +149,7 @@ async fn call_handle_node_disappearance_if_needed( "call_handle_node_disappearance_if_needed - call handle_node_disappearance: {:?}", &node.metadata.name ); - handle_node_disappearance(node_name, ctx.clone()).await?; + handle_node_disappearance(&node_name, ctx.clone()).await?; ctx.known_nodes .write() .await @@ -194,7 +191,7 @@ async fn handle_node_disappearance( instances.items.len() ); for instance in instances.items { - let instance_name = instance.metadata.name.clone().unwrap(); + let instance_name = instance.name_unchecked(); trace!( "handle_node_disappearance - make sure node is not referenced here: {:?}", @@ -316,7 +313,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let node_json = file::read_file_to_string("../test/json/node-a.json"); let node: Node = serde_json::from_str(&node_json).unwrap(); - let node_name = node.metadata.name.clone().unwrap(); + let node_name = node.name_unchecked(); let mut mock = MockControllerKubeClient::default(); mock.node .expect_all() @@ -337,7 +334,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let node_json = file::read_file_to_string("../test/json/node-a-not-ready.json"); let node: Node = serde_json::from_str(&node_json).unwrap(); - let node_name = node.metadata.name.clone().unwrap(); + let node_name = node.name_unchecked(); let mut mock = MockControllerKubeClient::default(); mock.node .expect_all() @@ -358,7 +355,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let node_json = file::read_file_to_string("../test/json/node-a-not-ready.json"); let node: Node = serde_json::from_str(&node_json).unwrap(); - let node_name = node.metadata.name.clone().unwrap(); + let node_name = node.name_unchecked(); let mut mock = MockControllerKubeClient::default(); mock.node .expect_all() @@ -384,7 +381,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let node_json = file::read_file_to_string("../test/json/node-a-not-ready.json"); let node: Node = serde_json::from_str(&node_json).unwrap(); - let node_name = node.metadata.name.clone().unwrap(); + let node_name = node.name_unchecked(); let mut mock = MockControllerKubeClient::default(); mock.node .expect_all() @@ -428,7 +425,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let node_json = file::read_file_to_string("../test/json/node-a-not-ready.json"); let node: Node = serde_json::from_str(&node_json).unwrap(); - let node_name = node.metadata.name.clone().unwrap(); + let node_name = node.name_unchecked(); let mut mock = MockControllerKubeClient::default(); mock.node .expect_all() @@ -468,7 +465,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let node_json = file::read_file_to_string("../test/json/node-a-not-ready.json"); let node: Node = serde_json::from_str(&node_json).unwrap(); - let node_name = node.metadata.name.clone().unwrap(); + let node_name = node.name_unchecked(); let mut mock = MockControllerKubeClient::default(); mock.node .expect_all() diff --git a/controller/src/util/pod_watcher.rs b/controller/src/util/pod_watcher.rs index 4eb527b2d..3efd7719b 100644 --- a/controller/src/util/pod_watcher.rs +++ b/controller/src/util/pod_watcher.rs @@ -8,7 +8,6 @@ use akri_shared::{ }, }; -use anyhow::Context; use futures::StreamExt; use k8s_openapi::api::core::v1::Pod; @@ -52,23 +51,19 @@ enum BrokerPodOwnerKind { fn get_broker_pod_owner_kind(pod: &Pod) -> BrokerPodOwnerKind { let instance_kind = "Instance".to_string(); let job_kind = "Job".to_string(); - match &pod.metadata.owner_references { - Some(or) => { - if or - .iter() - .any(|r| r.kind == instance_kind && r.controller.unwrap_or(false)) - { - BrokerPodOwnerKind::Instance - } else if or - .iter() - .any(|r| r.kind == job_kind && r.controller.unwrap_or(false)) - { - BrokerPodOwnerKind::Job - } else { - BrokerPodOwnerKind::Other - } - } - None => BrokerPodOwnerKind::Other, + let or = &pod.owner_references(); + if or + .iter() + .any(|r| r.kind == instance_kind && r.controller.unwrap_or(false)) + { + BrokerPodOwnerKind::Instance + } else if or + .iter() + .any(|r| r.kind == job_kind && r.controller.unwrap_or(false)) + { + BrokerPodOwnerKind::Job + } else { + BrokerPodOwnerKind::Other } } @@ -126,10 +121,10 @@ async fn reconcile_inner(event: Event, ctx: Arc) -> Resu ); match phase.as_str() { "Unknown" | "Pending" => { - ctx.known_pods.write().await.insert( - pod.metadata.name.clone().context("Pod name is None")?, - PodState::Pending, - ); + ctx.known_pods + .write() + .await + .insert(pod.name_unchecked(), PodState::Pending); } "Running" => { handle_running_pod_if_needed(&pod, ctx).await?; @@ -171,12 +166,12 @@ async fn handle_running_pod_if_needed( ctx: Arc, ) -> anyhow::Result<()> { trace!("handle_running_pod_if_needed - enter"); - let pod_name = pod.metadata.name.as_deref().context("Pod name is None")?; + let pod_name = pod.name_unchecked(); let last_known_state = ctx .known_pods .read() .await - .get(pod_name) + .get(&pod_name) .unwrap_or(&PodState::Pending) .clone(); trace!( @@ -202,11 +197,7 @@ async fn handle_running_pod_if_needed( /// expected and accepted. async fn handle_ended_pod_if_needed(pod: &Pod, ctx: Arc) -> anyhow::Result<()> { trace!("handle_ended_pod_if_needed - enter"); - let pod_name = pod - .metadata - .name - .clone() - .context("Pod does not have name")?; + let pod_name = pod.name_unchecked(); let last_known_state = ctx .known_pods .read() @@ -240,11 +231,7 @@ async fn handle_deleted_pod_if_needed( ctx: Arc, ) -> anyhow::Result<()> { trace!("handle_deleted_pod_if_needed - enter"); - let pod_name = pod - .metadata - .name - .clone() - .ok_or_else(|| anyhow::format_err!("Pod {:?} does not have name", pod))?; + let pod_name = pod.name_unchecked(); // Ensure that, for each pod, handle_non_running_pod is called once // per transition into the Deleted state if ctx @@ -283,11 +270,7 @@ fn get_instance_and_configuration_from_pod(pod: &Pod) -> anyhow::Result<(String, /// supported by Running broker Pods. async fn handle_non_running_pod(pod: &Pod, ctx: Arc) -> anyhow::Result<()> { trace!("handle_non_running_pod - enter"); - let namespace = pod - .metadata - .namespace - .as_ref() - .context("Pod has no namespace")?; + let namespace = pod.namespace().unwrap(); let (instance_id, config_name) = get_instance_and_configuration_from_pod(pod)?; let selector = format!("{}={}", AKRI_CONFIGURATION_LABEL_NAME, config_name); let broker_pods: ObjectList = ctx @@ -299,41 +282,33 @@ async fn handle_non_running_pod(pod: &Pod, ctx: Arc) -> anyho }) .await?; // Clean up instance services so long as all pods are terminated or terminating - let svc_api = ctx.client.namespaced(namespace); + let svc_api = ctx.client.namespaced(&namespace); cleanup_svc_if_unsupported( &broker_pods.items, &create_service_app_name(&config_name), - namespace, + &namespace, svc_api.as_ref(), ) .await?; let instance_pods: Vec = broker_pods .items .into_iter() - .filter(|x| { - match x - .metadata - .labels - .as_ref() - .unwrap_or(&BTreeMap::new()) - .get(AKRI_INSTANCE_LABEL_NAME) - { - Some(name) => name == &instance_id, - None => false, - } + .filter(|x| match x.labels().get(AKRI_INSTANCE_LABEL_NAME) { + Some(name) => name == &instance_id, + None => false, }) .collect(); cleanup_svc_if_unsupported( &instance_pods, &create_service_app_name(&instance_id), - namespace, + &namespace, svc_api.as_ref(), ) .await?; // Only redeploy Pods that are managed by the Akri Controller (controlled by an Instance OwnerReference) if get_broker_pod_owner_kind(pod) == BrokerPodOwnerKind::Instance { - if let Ok(Some(instance)) = ctx.client.namespaced(namespace).get(&instance_id).await { + if let Ok(Some(instance)) = ctx.client.namespaced(&namespace).get(&instance_id).await { super::instance_action::handle_instance_change(&instance, ctx).await?; } } @@ -378,15 +353,11 @@ async fn cleanup_svc_if_unsupported( /// by the configuration. async fn handle_running_pod(pod: &Pod, ctx: Arc) -> anyhow::Result<()> { trace!("handle_running_pod - enter"); - let namespace = pod - .metadata - .namespace - .as_ref() - .context("Namespace not found for pod")?; + let namespace = pod.namespace().unwrap(); let (instance_name, configuration_name) = get_instance_and_configuration_from_pod(pod)?; let Some(configuration) = ctx .client - .namespaced(namespace) + .namespaced(&namespace) .get(&configuration_name) .await? else { @@ -398,8 +369,11 @@ async fn handle_running_pod(pod: &Pod, ctx: Arc) -> anyhow::R ); return Ok(()); }; - let Some(instance): Option = - ctx.client.namespaced(namespace).get(&instance_name).await? + let Some(instance): Option = ctx + .client + .namespaced(&namespace) + .get(&instance_name) + .await? else { // In this scenario, a instance has likely been deleted in the middle of handle_running_pod. trace!( @@ -408,15 +382,11 @@ async fn handle_running_pod(pod: &Pod, ctx: Arc) -> anyhow::R ); return Ok(()); }; - let instance_uid = instance - .metadata - .uid - .as_ref() - .context("UID not found for instance")?; + let instance_uid = instance.uid().unwrap(); add_instance_and_configuration_services( &instance_name, - instance_uid, - namespace, + &instance_uid, + &namespace, &configuration_name, &configuration, ctx, @@ -462,11 +432,7 @@ async fn add_instance_and_configuration_services( api.apply(instance_svc, &ctx.identifier).await?; } if let Some(configuration_service_spec) = &configuration.spec.configuration_service_spec { - let configuration_uid = configuration - .metadata - .uid - .as_ref() - .context("UID not found for configuration")?; + let configuration_uid = configuration.uid().unwrap(); let ownership = OwnershipInfo::new( OwnershipType::Configuration, configuration_name.to_string(), @@ -775,38 +741,22 @@ mod tests { } fn valid_instance_svc(instance_svc: &Service, instance_name: &str, namespace: &str) -> bool { - instance_svc.metadata.name.as_ref().unwrap() == &format!("{}-svc", instance_name) - && instance_svc.metadata.namespace.as_ref().unwrap() == namespace - && instance_svc - .metadata - .owner_references - .as_ref() - .unwrap() - .len() - == 1 - && instance_svc.metadata.owner_references.as_ref().unwrap()[0].kind == "Instance" - && instance_svc.metadata.owner_references.as_ref().unwrap()[0].name == instance_name - && instance_svc - .metadata - .labels - .as_ref() - .unwrap() - .get(AKRI_INSTANCE_LABEL_NAME) - .unwrap() - == instance_name + instance_svc.name_unchecked() == format!("{}-svc", instance_name) + && instance_svc.namespace().unwrap() == namespace + && instance_svc.owner_references().len() == 1 + && instance_svc.owner_references()[0].kind == "Instance" + && instance_svc.owner_references()[0].name == instance_name + && instance_svc.labels().get(AKRI_INSTANCE_LABEL_NAME).unwrap() == instance_name } fn valid_config_svc(config_svc: &Service, config_name: &str, namespace: &str) -> bool { - config_svc.metadata.name.as_ref().unwrap() == &format!("{}-svc", config_name) - && config_svc.metadata.namespace.as_ref().unwrap() == namespace - && config_svc.metadata.owner_references.as_ref().unwrap().len() == 1 - && config_svc.metadata.owner_references.as_ref().unwrap()[0].kind == "Configuration" - && config_svc.metadata.owner_references.as_ref().unwrap()[0].name == config_name + config_svc.name_unchecked() == format!("{}-svc", config_name) + && config_svc.namespace().unwrap() == namespace + && config_svc.owner_references().len() == 1 + && config_svc.owner_references()[0].kind == "Configuration" + && config_svc.owner_references()[0].name == config_name && config_svc - .metadata - .labels - .as_ref() - .unwrap() + .labels() .get(AKRI_CONFIGURATION_LABEL_NAME) .unwrap() == config_name @@ -817,7 +767,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let pod = make_pod_with_owners_and_phase("instance_name", "copnfig_name", "Unknown", "Instance"); - let pod_name = pod.metadata.name.clone().unwrap(); + let pod_name = pod.name_unchecked(); let ctx = Arc::new(ControllerContext::new( Arc::new(MockControllerKubeClient::default()), "test", @@ -836,7 +786,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let pod = make_pod_with_owners_and_phase("instance_name", "config_name", "Pending", "Instance"); - let pod_name = pod.metadata.name.clone().unwrap(); + let pod_name = pod.name_unchecked(); let ctx = Arc::new(ControllerContext::new( Arc::new(MockControllerKubeClient::default()), "test", @@ -856,7 +806,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let pod = make_pod_with_owners_and_phase("instance_name", "config_name", "Running", "Instance"); - let pod_name = pod.metadata.name.clone().unwrap(); + let pod_name = pod.name_unchecked(); let ctx = Arc::new(ControllerContext::new( Arc::new(MockControllerKubeClient::default()), "test", @@ -881,7 +831,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let pod = make_pod_with_owners_and_phase("instance_name", "config_name", "Running", "Instance"); - let pod_name = pod.metadata.name.clone().unwrap(); + let pod_name = pod.name_unchecked(); let mut mock = MockControllerKubeClient::default(); let mut mock_config_api: MockApi = MockApi::new(); mock_config_api.expect_get().return_once(|_| { @@ -895,7 +845,7 @@ mod tests { mock.config .expect_namespaced() .return_once(|_| Box::new(mock_config_api)) - .with(mockall::predicate::eq("test-ns")); + .withf(|x| x == "test-ns"); let mut mock_instance_api: MockApi = MockApi::new(); mock_instance_api.expect_get().return_once(|_| { Ok(Some(make_instance( @@ -907,7 +857,7 @@ mod tests { mock.instance .expect_namespaced() .return_once(|_| Box::new(mock_instance_api)) - .with(mockall::predicate::eq("test-ns")); + .withf(|x| x == "test-ns"); let mut mock_svc_api: MockApi = MockApi::new(); let mut seq = Sequence::new(); @@ -1000,7 +950,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); // NOTE: setting Job kind for the Pod owner to ensure `handle_instance_change` is not called let pod1 = make_pod_with_owners_and_phase("instance_name", "config_name", phase, "Job"); - let pod_name = pod1.metadata.name.clone().unwrap(); + let pod_name = pod1.name_unchecked(); // Unrelated pod that should be filtered out let pod2 = make_pod_with_owners_and_phase("foo", "config_name", phase, "Job"); let pod_list = make_obj_list(vec![pod1.clone(), pod2]); @@ -1040,7 +990,7 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); // NOTE: setting Job kind for the Pod owner to ensure `handle_instance_change` is not called let pod1 = make_pod_with_owners_and_phase("instance_name", "config_name", "Failed", "Job"); - let pod_name = pod1.metadata.name.clone().unwrap(); + let pod_name = pod1.name_unchecked(); // Have one pod of the config still running to ensure that the config service is not deleted let pod2 = make_pod_with_owners_and_phase("foo", "config_name", "Running", "Job"); let pod_list = make_obj_list(vec![pod1.clone(), pod2]); @@ -1067,7 +1017,7 @@ mod tests { let phase = "Succeeded"; // NOTE: setting Job kind for the Pod owner to ensure `handle_instance_change` is not called let pod1 = make_pod_with_owners_and_phase("instance_name", "config_name", phase, "Job"); - let pod_name = pod1.metadata.name.clone().unwrap(); + let pod_name = pod1.name_unchecked(); // Unrelated pod that should be filtered out let pod2 = make_pod_with_owners_and_phase("foo", "config_name", phase, "Job"); let pod_list = make_obj_list(vec![pod1.clone(), pod2]); diff --git a/controller/src/util/shared_test_utils.rs b/controller/src/util/shared_test_utils.rs index 8b29bc7d3..16013ab5c 100644 --- a/controller/src/util/shared_test_utils.rs +++ b/controller/src/util/shared_test_utils.rs @@ -4,7 +4,7 @@ pub mod config_for_tests { use akri_shared::{akri::configuration::Configuration, k8s::api::MockApi, os::file}; use chrono::DateTime; use k8s_openapi::api::core::v1::Pod; - use kube::api::ObjectList; + use kube::{api::ObjectList, ResourceExt}; use log::trace; pub type PodList = ObjectList; @@ -172,15 +172,8 @@ pub mod config_for_tests { mock_api .expect_apply() .withf(move |pod_to_create, _| { - pod_to_create.metadata.name.as_ref().unwrap() == pod_name - && pod_to_create - .metadata - .labels - .as_ref() - .unwrap() - .get(label_id) - .unwrap() - == label_value + pod_to_create.name_unchecked() == pod_name + && pod_to_create.labels().get(label_id).unwrap() == label_value }) .returning(move |pod, _| match error { false => Ok(pod), diff --git a/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml b/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml index 0960793e2..d9e5bd4fc 100644 --- a/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/debug-echo-discovery-handler/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring "] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/discovery-handler-modules/onvif-discovery-handler/Cargo.toml b/discovery-handler-modules/onvif-discovery-handler/Cargo.toml index 2f1ffa7b4..87906614e 100644 --- a/discovery-handler-modules/onvif-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/onvif-discovery-handler/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring "] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/discovery-handler-modules/opcua-discovery-handler/Cargo.toml b/discovery-handler-modules/opcua-discovery-handler/Cargo.toml index d4fcb8a6e..8e0fe4357 100644 --- a/discovery-handler-modules/opcua-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/opcua-discovery-handler/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring "] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/discovery-handler-modules/udev-discovery-handler/Cargo.toml b/discovery-handler-modules/udev-discovery-handler/Cargo.toml index 598ec0f0f..0d46fc156 100644 --- a/discovery-handler-modules/udev-discovery-handler/Cargo.toml +++ b/discovery-handler-modules/udev-discovery-handler/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring "] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/discovery-handlers/debug-echo/Cargo.toml b/discovery-handlers/debug-echo/Cargo.toml index 3baf0e875..002294a4a 100644 --- a/discovery-handlers/debug-echo/Cargo.toml +++ b/discovery-handlers/debug-echo/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring "] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/discovery-handlers/onvif/Cargo.toml b/discovery-handlers/onvif/Cargo.toml index 0be685c3b..8295e0fd2 100644 --- a/discovery-handlers/onvif/Cargo.toml +++ b/discovery-handlers/onvif/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring "] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/discovery-handlers/opcua/Cargo.toml b/discovery-handlers/opcua/Cargo.toml index 7e58a1ce7..069b56a2a 100644 --- a/discovery-handlers/opcua/Cargo.toml +++ b/discovery-handlers/opcua/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring "] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/discovery-handlers/udev/Cargo.toml b/discovery-handlers/udev/Cargo.toml index ff8d9399b..2acfcea3e 100644 --- a/discovery-handlers/udev/Cargo.toml +++ b/discovery-handlers/udev/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring "] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/discovery-utils/Cargo.toml b/discovery-utils/Cargo.toml index 62f805ccd..127c6c5e2 100644 --- a/discovery-utils/Cargo.toml +++ b/discovery-utils/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring "] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/samples/brokers/udev-video-broker/Cargo.toml b/samples/brokers/udev-video-broker/Cargo.toml index 412827b5f..010ac146a 100644 --- a/samples/brokers/udev-video-broker/Cargo.toml +++ b/samples/brokers/udev-video-broker/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["Kate Goldenring ", ""] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 00ba55901..f482ac2bd 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = [""] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/webhooks/validating/configuration/Cargo.toml b/webhooks/validating/configuration/Cargo.toml index 054257ab9..46a78d587 100644 --- a/webhooks/validating/configuration/Cargo.toml +++ b/webhooks/validating/configuration/Cargo.toml @@ -4,7 +4,7 @@ version = "0.13.1" license = "Apache-2.0" authors = ["DazWilkin "] edition = "2021" -rust-version = "1.73.0" +rust-version = "1.75.0" [dependencies] actix-web = { version = "4", features = ["openssl"] }