From 59003eb1357d1068593b47a45d1b24d6c07bbdc4 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sun, 7 Dec 2025 00:03:09 +0100 Subject: [PATCH 01/19] chore(shared): update kube-rs Signed-off-by: Gaurav Gahlot --- shared/Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 0651529cf..3457ff0a6 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -11,12 +11,12 @@ rust-version.workspace = true [dependencies] anyhow = "1.0.38" async-trait = "0.1.0" -either = '*' -k8s-openapi = { version = "0.20.0", default-features = false, features = ["schemars", "v1_23"] } -kube = { version = "0.87.1", features = ["derive"] } +either = "1.13" +k8s-openapi = { version = "0.22.0", default-features = false, features = ["schemars", "v1_25"] } +kube = { version = "0.91.0", features = ["derive" ] } log = "0.4" mockall = "0.12" -prometheus = { version = "0.12.0", features = ["process"] } +prometheus = { version = "0.13.4", features = ["process"] } rand = "0.8.3" schemars = "0.8.0" serde = "1.0" From 5ee968060397b5d11cc549d359b27304b8b43af4 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 11:45:28 +0100 Subject: [PATCH 02/19] chore(controller): update kube-rs Signed-off-by: Gaurav Gahlot --- controller/Cargo.toml | 7 +++---- controller/src/util/instance_action.rs | 4 ++-- controller/src/util/node_watcher.rs | 4 ++-- controller/src/util/pod_watcher.rs | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/controller/Cargo.toml b/controller/Cargo.toml index b1c4bff56..d17d553ba 100644 --- a/controller/Cargo.toml +++ b/controller/Cargo.toml @@ -15,12 +15,11 @@ async-std = "1.5.0" chrono = "0.4.10" env_logger = "0.11.8" futures = "0.3.1" -k8s-openapi = { version = "0.20.0", default-features = false, features = ["schemars", "v1_23"] } -kube = { version = "0.87.1", features = ["derive"] } -kube-runtime = "0.87.1" +k8s-openapi = { version = "0.22.0", default-features = false, features = ["schemars", "v1_25"] } +kube = { version = "0.91.0", features = ["client", "derive", "runtime"] } lazy_static = "1.4" log = "0.4" -prometheus = { version = "0.12.0", features = ["process"] } +prometheus = { version = "0.13.4", features = ["process"] } tokio = { version = "1.0.2", features = ["full"] } [dev-dependencies] diff --git a/controller/src/util/instance_action.rs b/controller/src/util/instance_action.rs index 0824b02cb..32ed134a8 100644 --- a/controller/src/util/instance_action.rs +++ b/controller/src/util/instance_action.rs @@ -13,8 +13,8 @@ use futures::{StreamExt, TryStreamExt}; use k8s_openapi::api::batch::v1::JobSpec; use k8s_openapi::api::core::v1::{Pod, PodSpec}; use kube::api::Api; -use kube_runtime::watcher::{watcher, Config, Event}; -use kube_runtime::WatchStreamExt; +use kube::runtime::watcher::{watcher, Config, Event}; +use kube::runtime::WatchStreamExt; use log::{error, info, trace}; use std::collections::HashMap; use std::sync::Arc; diff --git a/controller/src/util/node_watcher.rs b/controller/src/util/node_watcher.rs index 30eaa1e82..47435d924 100644 --- a/controller/src/util/node_watcher.rs +++ b/controller/src/util/node_watcher.rs @@ -10,8 +10,8 @@ use akri_shared::{ use futures::{StreamExt, TryStreamExt}; use k8s_openapi::api::core::v1::{Node, NodeStatus}; use kube::api::Api; -use kube_runtime::watcher::{watcher, Config, Event}; -use kube_runtime::WatchStreamExt; +use kube::runtime::watcher::{watcher, Config, Event}; +use kube::runtime::WatchStreamExt; use log::{error, info, trace}; use std::collections::HashMap; use std::str::FromStr; diff --git a/controller/src/util/pod_watcher.rs b/controller/src/util/pod_watcher.rs index 35f61a975..af79f9907 100644 --- a/controller/src/util/pod_watcher.rs +++ b/controller/src/util/pod_watcher.rs @@ -13,8 +13,8 @@ use async_std::sync::Mutex; use futures::{StreamExt, TryStreamExt}; use k8s_openapi::api::core::v1::{Pod, ServiceSpec}; use kube::api::Api; -use kube_runtime::watcher::{watcher, Config, Event}; -use kube_runtime::WatchStreamExt; +use kube::runtime::watcher::{watcher, Config, Event}; +use kube::runtime::WatchStreamExt; use log::{error, info, trace}; use std::{collections::HashMap, sync::Arc}; From 451adde008721726bae9780d72ef642f7d7817a8 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 11:54:36 +0100 Subject: [PATCH 03/19] chore(discovery): auto-generated Signed-off-by: Gaurav Gahlot --- discovery-utils/src/discovery/v0.rs | 176 ++++++++++++++++++---------- 1 file changed, 111 insertions(+), 65 deletions(-) diff --git a/discovery-utils/src/discovery/v0.rs b/discovery-utils/src/discovery/v0.rs index 08781a68e..a20490c38 100644 --- a/discovery-utils/src/discovery/v0.rs +++ b/discovery-utils/src/discovery/v0.rs @@ -9,10 +9,7 @@ pub struct RegisterDiscoveryHandlerRequest { /// Endpoint for the registering `DiscoveryHandler` #[prost(string, tag = "2")] pub endpoint: ::prost::alloc::string::String, - #[prost( - enumeration = "register_discovery_handler_request::EndpointType", - tag = "3" - )] + #[prost(enumeration = "register_discovery_handler_request::EndpointType", tag = "3")] pub endpoint_type: i32, /// Specifies whether this device could be used by multiple nodes (e.g. an IP camera) /// or can only be ever be discovered by a single node (e.g. a local USB device) @@ -22,7 +19,17 @@ pub struct RegisterDiscoveryHandlerRequest { /// Nested message and enum types in `RegisterDiscoveryHandlerRequest`. pub mod register_discovery_handler_request { /// Specifies the type of endpoint. - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] #[repr(i32)] pub enum EndpointType { Uds = 0, @@ -68,7 +75,10 @@ pub struct DiscoverRequest { /// list of Key-value pairs containing additional information /// for the 'DiscoveryHandler' to discover devices #[prost(map = "string, message", tag = "2")] - pub discovery_properties: ::std::collections::HashMap<::prost::alloc::string::String, ByteData>, + pub discovery_properties: ::std::collections::HashMap< + ::prost::alloc::string::String, + ByteData, + >, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -87,8 +97,10 @@ pub struct Device { /// and set as environment variables in the device's broker Pods. May be information /// about where to find the device such as an RTSP URL or a device node (e.g. `/dev/video1`) #[prost(map = "string, string", tag = "2")] - pub properties: - ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + pub properties: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::string::String, + >, /// Optionally specify mounts for Pods that request this device as a resource #[prost(message, repeated, tag = "3")] pub mounts: ::prost::alloc::vec::Vec, @@ -133,8 +145,8 @@ pub struct DeviceSpec { /// Generated client implementations. pub mod registration_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; /// Registration is the service advertised by the Akri Agent. /// Any `DiscoveryHandler` can register with the Akri Agent. #[derive(Debug, Clone)] @@ -180,8 +192,9 @@ pub mod registration_client { >::ResponseBody, >, >, - >>::Error: - Into + Send + Sync, + , + >>::Error: Into + Send + Sync, { RegistrationClient::new(InterceptedService::new(inner, interceptor)) } @@ -220,20 +233,22 @@ pub mod registration_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/v0.Registration/RegisterDiscoveryHandler"); + let path = http::uri::PathAndQuery::from_static( + "/v0.Registration/RegisterDiscoveryHandler", + ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new( - "v0.Registration", - "RegisterDiscoveryHandler", - )); + req.extensions_mut() + .insert(GrpcMethod::new("v0.Registration", "RegisterDiscoveryHandler")); self.inner.unary(req, path, codec).await } } @@ -241,8 +256,8 @@ pub mod registration_client { /// Generated client implementations. pub mod discovery_handler_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct DiscoveryHandlerClient { inner: tonic::client::Grpc, @@ -286,8 +301,9 @@ pub mod discovery_handler_client { >::ResponseBody, >, >, - >>::Error: - Into + Send + Sync, + , + >>::Error: Into + Send + Sync, { DiscoveryHandlerClient::new(InterceptedService::new(inner, interceptor)) } @@ -329,14 +345,19 @@ pub mod discovery_handler_client { tonic::Response>, tonic::Status, > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v0.DiscoveryHandler/Discover"); + let path = http::uri::PathAndQuery::from_static( + "/v0.DiscoveryHandler/Discover", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v0.DiscoveryHandler", "Discover")); @@ -381,7 +402,10 @@ pub mod registration_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -437,19 +461,27 @@ pub mod registration_server { "/v0.Registration/RegisterDiscoveryHandler" => { #[allow(non_camel_case_types)] struct RegisterDiscoveryHandlerSvc(pub Arc); - impl - tonic::server::UnaryService - for RegisterDiscoveryHandlerSvc - { + impl< + T: Registration, + > tonic::server::UnaryService + for RegisterDiscoveryHandlerSvc { type Response = super::Empty; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, - request: tonic::Request, + request: tonic::Request< + super::RegisterDiscoveryHandlerRequest, + >, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::register_discovery_handler(&inner, request) + ::register_discovery_handler( + &inner, + request, + ) .await }; Box::pin(fut) @@ -478,14 +510,18 @@ pub mod registration_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } @@ -525,7 +561,8 @@ pub mod discovery_handler_server { /// Server streaming response type for the Discover method. type DiscoverStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, - > + Send + > + + Send + 'static; async fn discover( &self, @@ -555,7 +592,10 @@ pub mod discovery_handler_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -611,14 +651,16 @@ pub mod discovery_handler_server { "/v0.DiscoveryHandler/Discover" => { #[allow(non_camel_case_types)] struct DiscoverSvc(pub Arc); - impl - tonic::server::ServerStreamingService - for DiscoverSvc - { + impl< + T: DiscoveryHandler, + > tonic::server::ServerStreamingService + for DiscoverSvc { type Response = super::DiscoverResponse; type ResponseStream = T::DiscoverStream; - type Future = - BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -653,14 +695,18 @@ pub mod discovery_handler_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } From b85673adf90d2d2ff1a9b383f1b15c3426e8d981 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 11:59:24 +0100 Subject: [PATCH 04/19] chore(webhook): update dependencies Signed-off-by: Gaurav Gahlot --- webhooks/validating/configuration/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webhooks/validating/configuration/Cargo.toml b/webhooks/validating/configuration/Cargo.toml index 22f5403dc..cc76d771f 100644 --- a/webhooks/validating/configuration/Cargo.toml +++ b/webhooks/validating/configuration/Cargo.toml @@ -12,12 +12,12 @@ rust-version.workspace = true actix-web = { version = "4.10.0", features = ["openssl"] } akri-shared = { path = "../../../shared" } clap = "4.2.2" -k8s-openapi = { version = "0.17.0", default-features = false, features = ["schemars", "v1_23"] } +k8s-openapi = { version = "0.22.0", default-features = false, features = ["schemars", "v1_25"] } openapi = { git = "https://github.com/DazWilkin/openapi-admission-v1", tag = "v1.1.0" } openssl = "0.10" serde_json = "1.0.61" [dev-dependencies] actix-rt = "2.2.0" -kube = { version = "0.80.0", features = ["derive"] } +kube = { version = "0.91.0", features = ["derive"] } From e3f141ad652bc337e2dcd45194818a69a75a27a4 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 12:27:15 +0100 Subject: [PATCH 05/19] chore(agent): update dependencies Signed-off-by: Gaurav Gahlot --- agent/Cargo.toml | 8 +- agent/src/plugin_manager/v1.rs | 131 ++++++---- agent/src/plugin_manager/v1beta1.rs | 361 ++++++++++++++++++---------- 3 files changed, 327 insertions(+), 173 deletions(-) diff --git a/agent/Cargo.toml b/agent/Cargo.toml index eb9d61d63..123e054ae 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -25,13 +25,13 @@ env_logger = "0.11.8" futures = { version = "0.3.1", package = "futures" } hyper = "0.14.2" itertools = "0.12.0" -k8s-openapi = { version = "0.20.0", default-features = false, features = ["schemars", "v1_23"] } -kube = { version = "0.87.1", features = ["derive"] } -kube-runtime = { version = "0.87.1", features = ["unstable-runtime-reconcile-on"] } +k8s-openapi = { version = "0.22.0", default-features = false, features = ["schemars", "v1_25"] } +kube = { version = "0.91.0", features = ["derive", "runtime"] } +kube-runtime = { version = "0.91.0", features = ["unstable-runtime-reconcile-on"] } lazy_static = "1.4" log = "0.4" mockall_double = "0.3.1" -prometheus = { version = "0.12.0", features = ["process"] } +prometheus = { version = "0.13.4", features = ["process"] } prost = "0.12" serde = "1.0.104" serde_derive = "1.0.104" diff --git a/agent/src/plugin_manager/v1.rs b/agent/src/plugin_manager/v1.rs index f4cfc2df8..c255210b7 100644 --- a/agent/src/plugin_manager/v1.rs +++ b/agent/src/plugin_manager/v1.rs @@ -87,8 +87,8 @@ pub struct NumaNode { /// Generated client implementations. pub mod pod_resources_lister_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; /// PodResourcesLister is a service provided by the kubelet that provides information about the /// node resources consumed by pods and containers on the node #[derive(Debug, Clone)] @@ -134,8 +134,9 @@ pub mod pod_resources_lister_client { >::ResponseBody, >, >, - >>::Error: - Into + Send + Sync, + , + >>::Error: Into + Send + Sync, { PodResourcesListerClient::new(InterceptedService::new(inner, interceptor)) } @@ -173,16 +174,23 @@ pub mod pod_resources_lister_client { pub async fn list( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1.PodResourcesLister/List"); + let path = http::uri::PathAndQuery::from_static( + "/v1.PodResourcesLister/List", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1.PodResourcesLister", "List")); @@ -191,23 +199,28 @@ pub mod pod_resources_lister_client { pub async fn get_allocatable_resources( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1.PodResourcesLister/GetAllocatableResources", ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new( - "v1.PodResourcesLister", - "GetAllocatableResources", - )); + req.extensions_mut() + .insert( + GrpcMethod::new("v1.PodResourcesLister", "GetAllocatableResources"), + ); self.inner.unary(req, path, codec).await } } @@ -222,11 +235,17 @@ pub mod pod_resources_lister_server { async fn list( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_allocatable_resources( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } /// PodResourcesLister is a service provided by the kubelet that provides information about the /// node resources consumed by pods and containers on the node @@ -253,7 +272,10 @@ pub mod pod_resources_lister_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -309,11 +331,15 @@ pub mod pod_resources_lister_server { "/v1.PodResourcesLister/List" => { #[allow(non_camel_case_types)] struct ListSvc(pub Arc); - impl - tonic::server::UnaryService for ListSvc - { + impl< + T: PodResourcesLister, + > tonic::server::UnaryService + for ListSvc { type Response = super::ListPodResourcesResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -351,12 +377,15 @@ pub mod pod_resources_lister_server { "/v1.PodResourcesLister/GetAllocatableResources" => { #[allow(non_camel_case_types)] struct GetAllocatableResourcesSvc(pub Arc); - impl - tonic::server::UnaryService - for GetAllocatableResourcesSvc - { + impl< + T: PodResourcesLister, + > tonic::server::UnaryService + for GetAllocatableResourcesSvc { type Response = super::AllocatableResourcesResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -364,9 +393,10 @@ pub mod pod_resources_lister_server { let inner = Arc::clone(&self.0); let fut = async move { ::get_allocatable_resources( - &inner, request, - ) - .await + &inner, + request, + ) + .await }; Box::pin(fut) } @@ -394,14 +424,18 @@ pub mod pod_resources_lister_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } @@ -427,7 +461,8 @@ pub mod pod_resources_lister_server { write!(f, "{:?}", self.0) } } - impl tonic::server::NamedService for PodResourcesListerServer { + impl tonic::server::NamedService + for PodResourcesListerServer { const NAME: &'static str = "v1.PodResourcesLister"; } } diff --git a/agent/src/plugin_manager/v1beta1.rs b/agent/src/plugin_manager/v1beta1.rs index 083007abe..2f6dd0fb0 100644 --- a/agent/src/plugin_manager/v1beta1.rs +++ b/agent/src/plugin_manager/v1beta1.rs @@ -96,7 +96,9 @@ pub struct PreStartContainerResponse {} #[derive(Clone, PartialEq, ::prost::Message)] pub struct PreferredAllocationRequest { #[prost(message, repeated, tag = "1")] - pub container_requests: ::prost::alloc::vec::Vec, + pub container_requests: ::prost::alloc::vec::Vec< + ContainerPreferredAllocationRequest, + >, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -106,7 +108,9 @@ pub struct ContainerPreferredAllocationRequest { pub available_device_i_ds: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, /// List of deviceIDs that must be included in the preferred allocation #[prost(string, repeated, tag = "2")] - pub must_include_device_i_ds: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + pub must_include_device_i_ds: ::prost::alloc::vec::Vec< + ::prost::alloc::string::String, + >, /// Number of devices to include in the preferred allocation #[prost(int32, tag = "3")] pub allocation_size: i32, @@ -117,7 +121,9 @@ pub struct ContainerPreferredAllocationRequest { #[derive(Clone, PartialEq, ::prost::Message)] pub struct PreferredAllocationResponse { #[prost(message, repeated, tag = "1")] - pub container_responses: ::prost::alloc::vec::Vec, + pub container_responses: ::prost::alloc::vec::Vec< + ContainerPreferredAllocationResponse, + >, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -162,8 +168,10 @@ pub struct AllocateResponse { pub struct ContainerAllocateResponse { /// List of environment variable to be set in the container to access one of more devices. #[prost(map = "string, string", tag = "1")] - pub envs: - ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + pub envs: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::string::String, + >, /// Mounts for the container. #[prost(message, repeated, tag = "2")] pub mounts: ::prost::alloc::vec::Vec, @@ -172,8 +180,10 @@ pub struct ContainerAllocateResponse { pub devices: ::prost::alloc::vec::Vec, /// Container annotations to pass to the container runtime #[prost(map = "string, string", tag = "4")] - pub annotations: - ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + pub annotations: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::string::String, + >, } /// Mount specifies a host volume to mount into a container. /// where device library or tools are installed on host and container @@ -210,8 +220,8 @@ pub struct DeviceSpec { /// Generated client implementations. pub mod registration_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; /// Registration is the service advertised by the Kubelet /// Only when Kubelet answers with a success code to a Register Request /// may Device Plugins start their service @@ -261,8 +271,9 @@ pub mod registration_client { >::ResponseBody, >, >, - >>::Error: - Into + Send + Sync, + , + >>::Error: Into + Send + Sync, { RegistrationClient::new(InterceptedService::new(inner, interceptor)) } @@ -301,14 +312,19 @@ pub mod registration_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1beta1.Registration/Register"); + let path = http::uri::PathAndQuery::from_static( + "/v1beta1.Registration/Register", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.Registration", "Register")); @@ -319,8 +335,8 @@ pub mod registration_client { /// Generated client implementations. pub mod device_plugin_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; /// DevicePlugin is the service advertised by Device Plugins #[derive(Debug, Clone)] pub struct DevicePluginClient { @@ -365,8 +381,9 @@ pub mod device_plugin_client { >::ResponseBody, >, >, - >>::Error: - Into + Send + Sync, + , + >>::Error: Into + Send + Sync, { DevicePluginClient::new(InterceptedService::new(inner, interceptor)) } @@ -406,23 +423,28 @@ pub mod device_plugin_client { pub async fn get_device_plugin_options( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1beta1.DevicePlugin/GetDevicePluginOptions", ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new( - "v1beta1.DevicePlugin", - "GetDevicePluginOptions", - )); + req.extensions_mut() + .insert( + GrpcMethod::new("v1beta1.DevicePlugin", "GetDevicePluginOptions"), + ); self.inner.unary(req, path, codec).await } /// ListAndWatch returns a stream of List of Devices @@ -435,14 +457,19 @@ pub mod device_plugin_client { tonic::Response>, tonic::Status, > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/ListAndWatch"); + let path = http::uri::PathAndQuery::from_static( + "/v1beta1.DevicePlugin/ListAndWatch", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "ListAndWatch")); @@ -456,23 +483,28 @@ pub mod device_plugin_client { pub async fn get_preferred_allocation( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1beta1.DevicePlugin/GetPreferredAllocation", ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new( - "v1beta1.DevicePlugin", - "GetPreferredAllocation", - )); + req.extensions_mut() + .insert( + GrpcMethod::new("v1beta1.DevicePlugin", "GetPreferredAllocation"), + ); self.inner.unary(req, path, codec).await } /// Allocate is called during container creation so that the Device @@ -481,15 +513,23 @@ pub mod device_plugin_client { pub async fn allocate( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/Allocate"); + let path = http::uri::PathAndQuery::from_static( + "/v1beta1.DevicePlugin/Allocate", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "Allocate")); @@ -501,17 +541,23 @@ pub mod device_plugin_client { pub async fn pre_start_container( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/PreStartContainer"); + let path = http::uri::PathAndQuery::from_static( + "/v1beta1.DevicePlugin/PreStartContainer", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "PreStartContainer")); @@ -560,7 +606,10 @@ pub mod registration_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -616,16 +665,23 @@ pub mod registration_server { "/v1beta1.Registration/Register" => { #[allow(non_camel_case_types)] struct RegisterSvc(pub Arc); - impl tonic::server::UnaryService for RegisterSvc { + impl< + T: Registration, + > tonic::server::UnaryService + for RegisterSvc { type Response = super::Empty; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::register(&inner, request).await }; + let fut = async move { + ::register(&inner, request).await + }; Box::pin(fut) } } @@ -652,14 +708,18 @@ pub mod registration_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } @@ -701,11 +761,15 @@ pub mod device_plugin_server { async fn get_device_plugin_options( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Server streaming response type for the ListAndWatch method. type ListAndWatchStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, - > + Send + > + + Send + 'static; /// ListAndWatch returns a stream of List of Devices /// Whenever a Device state change or a Device disappears, ListAndWatch @@ -713,7 +777,10 @@ pub mod device_plugin_server { async fn list_and_watch( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// GetPreferredAllocation returns a preferred set of devices to allocate /// from a list of available ones. The resulting preferred allocation is not /// guaranteed to be the allocation ultimately performed by the @@ -722,21 +789,30 @@ pub mod device_plugin_server { async fn get_preferred_allocation( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Allocate is called during container creation so that the Device /// Plugin can run device specific operations and instruct Kubelet /// of the steps to make the Device available in the container async fn allocate( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// PreStartContainer is called, if indicated by Device Plugin during registration phase, /// before each container start. Device plugin can run device specific operations /// such as resetting the device before making devices available to the container async fn pre_start_container( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } /// DevicePlugin is the service advertised by Device Plugins #[derive(Debug)] @@ -762,7 +838,10 @@ pub mod device_plugin_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -818,13 +897,23 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/GetDevicePluginOptions" => { #[allow(non_camel_case_types)] struct GetDevicePluginOptionsSvc(pub Arc); - impl tonic::server::UnaryService for GetDevicePluginOptionsSvc { + impl tonic::server::UnaryService + for GetDevicePluginOptionsSvc { type Response = super::DevicePluginOptions; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::get_device_plugin_options(&inner, request) + ::get_device_plugin_options( + &inner, + request, + ) .await }; Box::pin(fut) @@ -856,12 +945,20 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/ListAndWatch" => { #[allow(non_camel_case_types)] struct ListAndWatchSvc(pub Arc); - impl tonic::server::ServerStreamingService for ListAndWatchSvc { + impl< + T: DevicePlugin, + > tonic::server::ServerStreamingService + for ListAndWatchSvc { type Response = super::ListAndWatchResponse; type ResponseStream = T::ListAndWatchStream; - type Future = - BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::list_and_watch(&inner, request).await @@ -895,19 +992,26 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/GetPreferredAllocation" => { #[allow(non_camel_case_types)] struct GetPreferredAllocationSvc(pub Arc); - impl - tonic::server::UnaryService - for GetPreferredAllocationSvc - { + impl< + T: DevicePlugin, + > tonic::server::UnaryService + for GetPreferredAllocationSvc { type Response = super::PreferredAllocationResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::get_preferred_allocation(&inner, request).await + ::get_preferred_allocation( + &inner, + request, + ) + .await }; Box::pin(fut) } @@ -938,16 +1042,23 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/Allocate" => { #[allow(non_camel_case_types)] struct AllocateSvc(pub Arc); - impl tonic::server::UnaryService for AllocateSvc { + impl< + T: DevicePlugin, + > tonic::server::UnaryService + for AllocateSvc { type Response = super::AllocateResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::allocate(&inner, request).await }; + let fut = async move { + ::allocate(&inner, request).await + }; Box::pin(fut) } } @@ -977,19 +1088,23 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/PreStartContainer" => { #[allow(non_camel_case_types)] struct PreStartContainerSvc(pub Arc); - impl - tonic::server::UnaryService - for PreStartContainerSvc - { + impl< + T: DevicePlugin, + > tonic::server::UnaryService + for PreStartContainerSvc { type Response = super::PreStartContainerResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::pre_start_container(&inner, request).await + ::pre_start_container(&inner, request) + .await }; Box::pin(fut) } @@ -1017,14 +1132,18 @@ pub mod device_plugin_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } From a7908f42bff81f02597bdb5613dd98dfdefb73c8 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 12:27:48 +0100 Subject: [PATCH 06/19] chore: everything else Signed-off-by: Gaurav Gahlot --- Cargo.lock | 688 ++++++++---------- .../udev-video-broker/src/util/camera.rs | 63 +- 2 files changed, 350 insertions(+), 401 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5906f72b8..4a1ed2a6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -229,22 +229,22 @@ dependencies = [ "blake2", "env_logger", "futures", - "hyper", + "hyper 0.14.32", "itertools", - "k8s-openapi 0.20.0", - "kube 0.87.2", + "k8s-openapi", + "kube", "kube-runtime", "lazy_static", "log", "mock_instant", "mockall", "mockall_double", - "prometheus", + "prometheus 0.13.4", "prost", "serde", "serde_derive", "serde_json", - "serde_yaml 0.9.34+deprecated", + "serde_yaml", "simple-mermaid", "tempfile", "thiserror", @@ -289,7 +289,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "serde_yaml 0.9.34+deprecated", + "serde_yaml", "tokio", "tokio-stream", "tonic", @@ -308,7 +308,7 @@ dependencies = [ "prost", "serde", "serde_derive", - "serde_yaml 0.9.34+deprecated", + "serde_yaml", "tempfile", "tokio", "tokio-stream", @@ -329,7 +329,7 @@ dependencies = [ "chrono", "env_logger", "futures-util", - "hyper", + "hyper 0.14.32", "log", "mockall", "serde", @@ -359,7 +359,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "serde_yaml 0.9.34+deprecated", + "serde_yaml", "tokio", "tokio-stream", "tonic", @@ -374,17 +374,17 @@ dependencies = [ "async-trait", "either", "env_logger", - "k8s-openapi 0.20.0", - "kube 0.87.2", + "k8s-openapi", + "kube", "log", "mockall", - "prometheus", + "prometheus 0.13.4", "rand 0.8.5", "schemars", "serde", "serde_derive", "serde_json", - "serde_yaml 0.9.34+deprecated", + "serde_yaml", "tokio", "tonic", "tower", @@ -499,6 +499,18 @@ version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener 5.4.1", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + [[package]] name = "async-channel" version = "1.9.0" @@ -564,7 +576,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix", + "rustix 1.1.2", "slab", "windows-sys 0.61.2", ] @@ -669,8 +681,8 @@ dependencies = [ "bytes", "futures-util", "http 0.2.12", - "http-body", - "hyper", + "http-body 0.4.6", + "hyper 0.14.32", "itoa", "matchit", "memchr", @@ -695,7 +707,7 @@ dependencies = [ "bytes", "futures-util", "http 0.2.12", - "http-body", + "http-body 0.4.6", "mime", "rustversion", "tower-layer", @@ -719,12 +731,6 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" -[[package]] -name = "base64" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" - [[package]] name = "base64" version = "0.21.7" @@ -880,7 +886,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -914,13 +920,12 @@ dependencies = [ "chrono", "env_logger", "futures", - "k8s-openapi 0.20.0", - "kube 0.87.2", - "kube-runtime", + "k8s-openapi", + "kube", "lazy_static", "log", "mockall", - "prometheus", + "prometheus 0.13.4", "serde_json", "tokio", ] @@ -946,6 +951,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -996,38 +1011,14 @@ dependencies = [ "subtle", ] -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core 0.14.4", - "darling_macro 0.14.4", -] - [[package]] name = "darling" version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ - "darling_core 0.20.11", - "darling_macro 0.20.11", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 1.0.109", + "darling_core", + "darling_macro", ] [[package]] @@ -1040,28 +1031,17 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.110", ] -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core 0.14.4", - "quote", - "syn 1.0.109", -] - [[package]] name = "darling_macro" version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ - "darling_core 0.20.11", + "darling_core", "quote", "syn 2.0.110", ] @@ -1143,27 +1123,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "displaydoc" version = "0.2.5" @@ -1630,10 +1589,27 @@ dependencies = [ ] [[package]] -name = "http-range-header" -version = "0.3.1" +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.3.1", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http 1.3.1", + "http-body 1.0.1", + "pin-project-lite", +] [[package]] name = "httparse" @@ -1659,7 +1635,7 @@ dependencies = [ "futures-util", "h2", "http 0.2.12", - "http-body", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -1672,37 +1648,42 @@ dependencies = [ ] [[package]] -name = "hyper-openssl" -version = "0.9.2" +name = "hyper" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ee5d7a8f718585d1c3c61dfde28ef5b0bb14734b4db13f5ada856cdc6c612b" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" dependencies = [ - "http 0.2.12", - "hyper", - "linked_hash_set", - "once_cell", - "openssl", - "openssl-sys", - "parking_lot 0.12.5", + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "http 1.3.1", + "http-body 1.0.1", + "httparse", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", "tokio", - "tokio-openssl", - "tower-layer", + "want", ] [[package]] name = "hyper-rustls" -version = "0.24.2" +version = "0.27.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" dependencies = [ - "futures-util", - "http 0.2.12", - "hyper", + "http 1.3.1", + "hyper 1.8.1", + "hyper-util", "log", - "rustls", + "rustls 0.23.35", "rustls-native-certs", + "rustls-pki-types", "tokio", - "tokio-rustls", + "tokio-rustls 0.26.4", + "tower-service", ] [[package]] @@ -1711,12 +1692,46 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.32", "pin-project-lite", "tokio", "tokio-io-timeout", ] +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper 1.8.1", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http 1.3.1", + "http-body 1.0.1", + "hyper 1.8.1", + "libc", + "pin-project-lite", + "socket2 0.6.1", + "tokio", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.64" @@ -1979,10 +1994,12 @@ dependencies = [ [[package]] name = "jsonpath-rust" -version = "0.3.5" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06cc127b7c3d270be504572364f9569761a180b981919dd0d87693a7f5fb7829" +checksum = "19d8fe85bd70ff715f31ce8c739194b423d79811a19602115d611a3ec85d6200" dependencies = [ + "lazy_static", + "once_cell", "pest", "pest_derive", "regex", @@ -1990,40 +2007,13 @@ dependencies = [ "thiserror", ] -[[package]] -name = "jsonpath_lib" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaa63191d68230cccb81c5aa23abd53ed64d83337cacbb25a7b8c7979523774f" -dependencies = [ - "log", - "serde", - "serde_json", -] - [[package]] name = "k8s-openapi" -version = "0.17.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1985030683a2bac402cbda61222195de80d3f66b4c87ab56e5fea379bd98c3" +checksum = "19501afb943ae5806548bc3ebd7f3374153ca057a38f480ef30adfde5ef09755" dependencies = [ - "base64 0.20.0", - "bytes", - "chrono", - "schemars", - "serde", - "serde-value", - "serde_json", -] - -[[package]] -name = "k8s-openapi" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc3606fd16aca7989db2f84bb25684d0270c6d6fa1dbcd0025af7b4130523a6" -dependencies = [ - "base64 0.21.7", - "bytes", + "base64 0.22.1", "chrono", "schemars", "serde", @@ -2033,128 +2023,65 @@ dependencies = [ [[package]] name = "kube" -version = "0.80.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414d80c69906a91e8ecf4ae16d0fb504e19aa6b099135d35d85298b4e4be3ed3" -dependencies = [ - "k8s-openapi 0.17.0", - "kube-client 0.80.0", - "kube-core 0.80.0", - "kube-derive 0.80.0", -] - -[[package]] -name = "kube" -version = "0.87.2" +version = "0.91.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3499c8d60c763246c7a213f51caac1e9033f46026904cb89bc8951ae8601f26e" +checksum = "264461a7ebf4fb0fcf23e4c7e4f9387c5696ee61d003de207d9b5a895ff37bfa" dependencies = [ - "k8s-openapi 0.20.0", - "kube-client 0.87.2", - "kube-core 0.87.2", - "kube-derive 0.87.2", -] - -[[package]] -name = "kube-client" -version = "0.80.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dc5ae0b9148b4e2ebb0dabda06a0cd65b1eed2f41d792d49787841a68050283" -dependencies = [ - "base64 0.20.0", - "bytes", - "chrono", - "dirs-next", - "either", - "futures", - "http 0.2.12", - "http-body", - "hyper", - "hyper-openssl", - "hyper-timeout", - "jsonpath_lib", - "k8s-openapi 0.17.0", - "kube-core 0.80.0", - "openssl", - "pem 1.1.1", - "pin-project", - "secrecy", - "serde", - "serde_json", - "serde_yaml 0.8.26", - "thiserror", - "tokio", - "tokio-util", - "tower", - "tower-http 0.3.5", - "tracing", + "k8s-openapi", + "kube-client", + "kube-core", + "kube-derive", + "kube-runtime", ] [[package]] name = "kube-client" -version = "0.87.2" +version = "0.91.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "033450dfa0762130565890dadf2f8835faedf749376ca13345bcd8ecd6b5f29f" +checksum = "47164ad6c47398ee4bdf90509c7b44026229721cb1377eb4623a1ec2a00a85e9" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "bytes", "chrono", "either", "futures", "home", - "http 0.2.12", - "http-body", - "hyper", + "http 1.3.1", + "http-body 1.0.1", + "http-body-util", + "hyper 1.8.1", "hyper-rustls", - "hyper-timeout", + "hyper-timeout 0.5.2", + "hyper-util", "jsonpath-rust", - "k8s-openapi 0.20.0", - "kube-core 0.87.2", - "pem 3.0.6", - "pin-project", - "rustls", - "rustls-pemfile", + "k8s-openapi", + "kube-core", + "pem", + "rustls 0.23.35", + "rustls-pemfile 2.2.0", "secrecy", "serde", "serde_json", - "serde_yaml 0.9.34+deprecated", + "serde_yaml", "thiserror", "tokio", "tokio-util", "tower", - "tower-http 0.4.4", + "tower-http", "tracing", ] [[package]] name = "kube-core" -version = "0.80.0" +version = "0.91.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98331c6f1354893f7c50da069e43a3fd1c84e55bbedc7765d9db22ec3291d07d" +checksum = "2797d3044a238825432129cd9537e12c2a6dacbbb5352381af5ea55e1505ed4f" dependencies = [ "chrono", "form_urlencoded", - "http 0.2.12", - "k8s-openapi 0.17.0", - "once_cell", - "schemars", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "kube-core" -version = "0.87.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5bba93d054786eba7994d03ce522f368ef7d48c88a1826faa28478d85fb63ae" -dependencies = [ - "chrono", - "form_urlencoded", - "http 0.2.12", + "http 1.3.1", "json-patch", - "k8s-openapi 0.20.0", - "once_cell", + "k8s-openapi", "schemars", "serde", "serde_json", @@ -2163,24 +2090,11 @@ dependencies = [ [[package]] name = "kube-derive" -version = "0.80.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4be6ff26b9a34ce831d341e8b33bc78986a33c1be88f5bf9ca84e92e98b1dfb" -dependencies = [ - "darling 0.14.4", - "proc-macro2", - "quote", - "serde_json", - "syn 1.0.109", -] - -[[package]] -name = "kube-derive" -version = "0.87.2" +version = "0.91.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e98dd5e5767c7b894c1f0e41fd628b145f808e981feb8b08ed66455d47f1a4" +checksum = "fcf837edaa0c478f85e9a3cddb17fa80d58a57c1afa722b3a9e55753ea162f41" dependencies = [ - "darling 0.20.11", + "darling", "proc-macro2", "quote", "serde_json", @@ -2189,19 +2103,21 @@ dependencies = [ [[package]] name = "kube-runtime" -version = "0.87.2" +version = "0.91.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d8893eb18fbf6bb6c80ef6ee7dd11ec32b1dc3c034c988ac1b3a84d46a230ae" +checksum = "e463e89a1fb222c65a5469b568803153d1bf13d084a8dd42b659e6cca66edc6e" dependencies = [ "ahash", + "async-broadcast", + "async-stream", "async-trait", "backoff", "derivative", "futures", "hashbrown 0.14.5", "json-patch", - "k8s-openapi 0.20.0", - "kube-client 0.87.2", + "k8s-openapi", + "kube-client", "parking_lot 0.12.5", "pin-project", "serde", @@ -2240,16 +2156,6 @@ version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" -[[package]] -name = "libredox" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" -dependencies = [ - "bitflags 2.10.0", - "libc", -] - [[package]] name = "libudev-sys" version = "0.1.4" @@ -2261,19 +2167,10 @@ dependencies = [ ] [[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - -[[package]] -name = "linked_hash_set" -version = "0.1.6" +name = "linux-raw-sys" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "984fb35d06508d1e69fc91050cceba9c0b748f983e6739fa2c7a9237154c52c8" -dependencies = [ - "linked-hash-map", -] +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "linux-raw-sys" @@ -2519,7 +2416,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "serde_yaml 0.9.34+deprecated", + "serde_yaml", "tokio", "tokio-util", "url 1.7.2", @@ -2656,15 +2553,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - [[package]] name = "pem" version = "3.0.6" @@ -2805,7 +2693,7 @@ dependencies = [ "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix", + "rustix 1.1.2", "windows-sys 0.61.2", ] @@ -2907,6 +2795,29 @@ dependencies = [ "libc", ] +[[package]] +name = "procfs" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "731e0d9356b0c25f16f33b5be79b1c57b562f141ebfcdb0ad8ac2c13a24293b4" +dependencies = [ + "bitflags 2.10.0", + "hex", + "lazy_static", + "procfs-core", + "rustix 0.38.44", +] + +[[package]] +name = "procfs-core" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3554923a69f4ce04c4a754260c338f505ce22642d3830e049a399fc2059a29" +dependencies = [ + "bitflags 2.10.0", + "hex", +] + [[package]] name = "prometheus" version = "0.12.0" @@ -2919,7 +2830,24 @@ dependencies = [ "libc", "memchr", "parking_lot 0.11.2", - "procfs", + "procfs 0.9.1", + "protobuf", + "thiserror", +] + +[[package]] +name = "prometheus" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d33c28a30771f7f96db69893f78b857f7450d7e0237e9c8fc6427a81bae7ed1" +dependencies = [ + "cfg-if", + "fnv", + "lazy_static", + "libc", + "memchr", + "parking_lot 0.12.5", + "procfs 0.16.0", "protobuf", "thiserror", ] @@ -3081,17 +3009,6 @@ dependencies = [ "bitflags 2.10.0", ] -[[package]] -name = "redox_users" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" -dependencies = [ - "getrandom 0.2.16", - "libredox", - "thiserror", -] - [[package]] name = "regex" version = "1.12.2" @@ -3140,8 +3057,8 @@ dependencies = [ "futures-util", "h2", "http 0.2.12", - "http-body", - "hyper", + "http-body 0.4.6", + "hyper 0.14.32", "ipnet", "js-sys", "log", @@ -3187,6 +3104,19 @@ dependencies = [ "libc", ] +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.10.0", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.52.0", +] + [[package]] name = "rustix" version = "1.1.2" @@ -3196,7 +3126,7 @@ dependencies = [ "bitflags 2.10.0", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.11.0", "windows-sys 0.61.2", ] @@ -3208,18 +3138,33 @@ checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.23.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "533f54bc6a7d4f647e46ad909549eda97bf5afc1585190ef692b4286b198bd8f" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki 0.103.8", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" -version = "0.6.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +checksum = "9980d917ebb0c0536119ba501e90834767bffc3d60641457fd84a1f3fd337923" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pki-types", "schannel", "security-framework", ] @@ -3233,6 +3178,24 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "708c0f9d5f54ba0272468c1d306a52c495b31fa155e91bc25371e6df7996908c" +dependencies = [ + "zeroize", +] + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -3243,6 +3206,17 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.103.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.22" @@ -3322,12 +3296,12 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.11.1" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" dependencies = [ "bitflags 2.10.0", - "core-foundation", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -3400,7 +3374,6 @@ version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ - "indexmap 2.12.0", "itoa", "memchr", "ryu", @@ -3420,18 +3393,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_yaml" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" -dependencies = [ - "indexmap 1.9.3", - "ryu", - "serde", - "yaml-rust", -] - [[package]] name = "serde_yaml" version = "0.9.34+deprecated" @@ -3553,12 +3514,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strsim" version = "0.11.1" @@ -3638,7 +3593,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys", ] @@ -3661,7 +3616,7 @@ dependencies = [ "fastrand", "getrandom 0.3.4", "once_cell", - "rustix", + "rustix 1.1.2", "windows-sys 0.61.2", ] @@ -3802,7 +3757,17 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.12", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls 0.23.35", "tokio", ] @@ -3857,16 +3822,16 @@ dependencies = [ "bytes", "h2", "http 0.2.12", - "http-body", - "hyper", - "hyper-timeout", + "http-body 0.4.6", + "hyper 0.14.32", + "hyper-timeout 0.4.1", "percent-encoding 2.3.2", "pin-project", "prost", - "rustls", - "rustls-pemfile", + "rustls 0.21.12", + "rustls-pemfile 1.0.4", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tokio-stream", "tower", "tower-layer", @@ -3909,38 +3874,16 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" -dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", - "bytes", - "futures-core", - "futures-util", - "http 0.2.12", - "http-body", - "http-range-header", - "pin-project-lite", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "base64 0.21.7", "bitflags 2.10.0", "bytes", - "futures-core", - "futures-util", - "http 0.2.12", - "http-body", - "http-range-header", + "http 1.3.1", + "http-body 1.0.1", + "http-body-util", "mime", "pin-project-lite", "tower-layer", @@ -4064,7 +4007,7 @@ dependencies = [ "env_logger", "lazy_static", "log", - "prometheus", + "prometheus 0.12.0", "prost", "regex", "rscam", @@ -4223,7 +4166,7 @@ dependencies = [ "futures-util", "headers", "http 0.2.12", - "hyper", + "hyper 0.14.32", "log", "mime", "mime_guess", @@ -4332,8 +4275,8 @@ dependencies = [ "actix-web", "akri-shared", "clap", - "k8s-openapi 0.17.0", - "kube 0.80.0", + "k8s-openapi", + "kube", "openapi", "openssl", "serde_json", @@ -4670,15 +4613,6 @@ version = "0.8.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f" -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "yaserde" version = "0.7.1" diff --git a/samples/brokers/udev-video-broker/src/util/camera.rs b/samples/brokers/udev-video-broker/src/util/camera.rs index 437b09cd8..4bd208251 100644 --- a/samples/brokers/udev-video-broker/src/util/camera.rs +++ b/samples/brokers/udev-video-broker/src/util/camera.rs @@ -13,8 +13,8 @@ pub struct NotifyResponse { /// Generated client implementations. pub mod camera_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct CameraClient { inner: tonic::client::Grpc, @@ -58,8 +58,9 @@ pub mod camera_client { >::ResponseBody, >, >, - >>::Error: - Into + Send + Sync, + , + >>::Error: Into + Send + Sync, { CameraClient::new(InterceptedService::new(inner, interceptor)) } @@ -98,17 +99,19 @@ pub mod camera_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/camera.Camera/GetFrame"); let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("camera.Camera", "GetFrame")); + req.extensions_mut().insert(GrpcMethod::new("camera.Camera", "GetFrame")); self.inner.unary(req, path, codec).await } } @@ -148,7 +151,10 @@ pub mod camera_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -204,16 +210,21 @@ pub mod camera_server { "/camera.Camera/GetFrame" => { #[allow(non_camel_case_types)] struct GetFrameSvc(pub Arc); - impl tonic::server::UnaryService for GetFrameSvc { + impl tonic::server::UnaryService + for GetFrameSvc { type Response = super::NotifyResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::get_frame(&inner, request).await }; + let fut = async move { + ::get_frame(&inner, request).await + }; Box::pin(fut) } } @@ -240,14 +251,18 @@ pub mod camera_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } From ba04a21b0ab478fbad40f9f8c8d46ed15d2c311f Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 12:34:16 +0100 Subject: [PATCH 07/19] chore: update version (patch) Signed-off-by: Gaurav Gahlot --- Cargo.lock | 294 +++++++++++++++++++++---------------- Cargo.toml | 2 +- deployment/helm/Chart.yaml | 4 +- version.txt | 2 +- 4 files changed, 168 insertions(+), 134 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a1ed2a6c..c3c0aafda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -153,9 +153,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.12.0" +version = "4.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2233f53f6cb18ae038ce1f0713ca0c72ca0c4b71fe9aaeb59924ce2c89c6dd85" +checksum = "1654a77ba142e37f049637a3e5685f864514af11fcbc51cb51eb6596afe5b8d6" dependencies = [ "actix-codec", "actix-http", @@ -204,7 +204,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -215,7 +215,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "agent" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-debug-echo", "akri-discovery-utils", @@ -279,7 +279,7 @@ dependencies = [ [[package]] name = "akri-debug-echo" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-discovery-utils", "akri-shared", @@ -297,7 +297,7 @@ dependencies = [ [[package]] name = "akri-discovery-utils" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-shared", "anyhow", @@ -319,7 +319,7 @@ dependencies = [ [[package]] name = "akri-onvif" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-discovery-utils", "anyhow", @@ -348,7 +348,7 @@ dependencies = [ [[package]] name = "akri-opcua" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-discovery-utils", "anyhow", @@ -368,7 +368,7 @@ dependencies = [ [[package]] name = "akri-shared" -version = "0.13.18" +version = "0.13.19" dependencies = [ "anyhow", "async-trait", @@ -393,7 +393,7 @@ dependencies = [ [[package]] name = "akri-udev" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-discovery-utils", "anyhow", @@ -637,7 +637,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -654,7 +654,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -838,9 +838,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.46" +version = "1.2.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36" +checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215" dependencies = [ "find-msvc-tools", "jobserver", @@ -912,7 +912,7 @@ dependencies = [ [[package]] name = "controller" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-shared", "anyhow", @@ -930,6 +930,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "convert_case" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "cookie" version = "0.16.2" @@ -1032,7 +1041,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1043,7 +1052,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1054,7 +1063,7 @@ checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" [[package]] name = "debug-echo-discovery-handler" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-debug-echo", "akri-discovery-utils", @@ -1085,22 +1094,24 @@ dependencies = [ [[package]] name = "derive_more" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" +checksum = "10b768e943bed7bf2cab53df09f4bc34bfd217cdb57d971e769874c9a6710618" dependencies = [ "derive_more-impl", ] [[package]] name = "derive_more-impl" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" +checksum = "6d286bfdaf75e988b4a78e013ecd79c581e06399ab53fbacd2d916c2f904f30b" dependencies = [ + "convert_case", "proc-macro2", "quote", - "syn 2.0.110", + "rustc_version", + "syn 2.0.111", "unicode-xid", ] @@ -1131,7 +1142,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1366,7 +1377,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1466,7 +1477,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.12.0", + "indexmap 2.12.1", "slab", "tokio", "tokio-util", @@ -1491,9 +1502,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" [[package]] name = "headers" @@ -1568,12 +1579,11 @@ dependencies = [ [[package]] name = "http" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" dependencies = [ "bytes", - "fnv", "itoa", ] @@ -1595,7 +1605,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.3.1", + "http 1.4.0", ] [[package]] @@ -1606,7 +1616,7 @@ checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", "futures-core", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "pin-project-lite", ] @@ -1657,7 +1667,7 @@ dependencies = [ "bytes", "futures-channel", "futures-core", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "httparse", "itoa", @@ -1674,7 +1684,7 @@ version = "0.27.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" dependencies = [ - "http 1.3.1", + "http 1.4.0", "hyper 1.8.1", "hyper-util", "log", @@ -1721,7 +1731,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "hyper 1.8.1", "libc", @@ -1804,9 +1814,9 @@ checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" [[package]] name = "icu_properties" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" dependencies = [ "icu_collections", "icu_locale_core", @@ -1818,9 +1828,9 @@ dependencies = [ [[package]] name = "icu_properties_data" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" [[package]] name = "icu_provider" @@ -1893,12 +1903,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.16.1", ] [[package]] @@ -1958,7 +1968,7 @@ checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1973,9 +1983,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" dependencies = [ "once_cell", "wasm-bindgen", @@ -2046,7 +2056,7 @@ dependencies = [ "either", "futures", "home", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", "hyper 1.8.1", @@ -2079,7 +2089,7 @@ checksum = "2797d3044a238825432129cd9537e12c2a6dacbbb5352381af5ea55e1505ed4f" dependencies = [ "chrono", "form_urlencoded", - "http 1.3.1", + "http 1.4.0", "json-patch", "k8s-openapi", "schemars", @@ -2098,7 +2108,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2152,9 +2162,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.177" +version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" [[package]] name = "libudev-sys" @@ -2212,9 +2222,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" dependencies = [ "value-bag", ] @@ -2265,9 +2275,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" dependencies = [ "libc", "log", @@ -2308,7 +2318,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2320,7 +2330,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2376,7 +2386,7 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "onvif-discovery-handler" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-discovery-utils", "akri-onvif", @@ -2420,12 +2430,12 @@ dependencies = [ "tokio", "tokio-util", "url 1.7.2", - "uuid 1.18.1", + "uuid 1.19.0", ] [[package]] name = "opcua-discovery-handler" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-discovery-utils", "akri-opcua", @@ -2469,7 +2479,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2583,9 +2593,9 @@ checksum = "f658886ed52e196e850cfbbfddab9eaa7f6d90dd0929e264c31e5cec07e09e57" [[package]] name = "pest" -version = "2.8.3" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989e7521a040efde50c3ab6bbadafbe15ab6dc042686926be59ac35d74607df4" +checksum = "cbcfd20a6d4eeba40179f05735784ad32bdaef05ce8e8af05f180d45bb3e7e22" dependencies = [ "memchr", "ucd-trie", @@ -2593,9 +2603,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.8.3" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187da9a3030dbafabbbfb20cb323b976dc7b7ce91fcd84f2f74d6e31d378e2de" +checksum = "51f72981ade67b1ca6adc26ec221be9f463f2b5839c7508998daa17c23d94d7f" dependencies = [ "pest", "pest_generator", @@ -2603,22 +2613,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.3" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b401d98f5757ebe97a26085998d6c0eecec4995cad6ab7fc30ffdf4b052843" +checksum = "dee9efd8cdb50d719a80088b76f81aec7c41ed6d522ee750178f83883d271625" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] name = "pest_meta" -version = "2.8.3" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f27a2cfee9f9039c4d86faa5af122a0ac3851441a34865b8a043b46be0065a" +checksum = "bf1d70880e76bdc13ba52eafa6239ce793d85c8e43896507e43dd8984ff05b82" dependencies = [ "pest", "sha2", @@ -2631,7 +2641,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.12.0", + "indexmap 2.12.1", ] [[package]] @@ -2651,7 +2661,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2769,7 +2779,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2879,7 +2889,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.110", + "syn 2.0.111", "tempfile", ] @@ -2893,7 +2903,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3104,6 +3114,15 @@ dependencies = [ "libc", ] +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.38.44" @@ -3114,7 +3133,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.15", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3259,7 +3278,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3317,6 +3336,12 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + [[package]] name = "serde" version = "1.0.228" @@ -3354,7 +3379,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3365,7 +3390,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3399,7 +3424,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.12.0", + "indexmap 2.12.1", "itoa", "ryu", "serde", @@ -3451,18 +3476,18 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.6" +version = "1.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad" dependencies = [ "libc", ] [[package]] name = "simd-adler32" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" [[package]] name = "simple-mermaid" @@ -3560,9 +3585,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.110" +version = "2.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" dependencies = [ "proc-macro2", "quote", @@ -3583,7 +3608,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3643,7 +3668,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3737,7 +3762,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3849,7 +3874,7 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3881,7 +3906,7 @@ dependencies = [ "base64 0.21.7", "bitflags 2.10.0", "bytes", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", "mime", @@ -3905,9 +3930,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" dependencies = [ "log", "pin-project-lite", @@ -3917,20 +3942,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] name = "tracing-core" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" dependencies = [ "once_cell", ] @@ -3950,7 +3975,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.3.1", + "http 1.4.0", "httparse", "log", "rand 0.8.5", @@ -3990,7 +4015,7 @@ dependencies = [ [[package]] name = "udev-discovery-handler" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-discovery-utils", "akri-udev", @@ -4001,7 +4026,7 @@ dependencies = [ [[package]] name = "udev-video-broker" -version = "0.13.18" +version = "0.13.19" dependencies = [ "akri-shared", "env_logger", @@ -4119,9 +4144,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.18.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" +checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" dependencies = [ "getrandom 0.3.4", "js-sys", @@ -4130,9 +4155,9 @@ dependencies = [ [[package]] name = "value-bag" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943ce29a8a743eb10d6082545d861b24f9d1b160b7d741e0f2cdf726bec909c5" +checksum = "7ba6f5989077681266825251a52748b8c1d8a4ad098cc37e440103d0ea717fc0" [[package]] name = "vcpkg" @@ -4201,9 +4226,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" dependencies = [ "cfg-if", "once_cell", @@ -4214,9 +4239,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.55" +version = "0.4.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "551f88106c6d5e7ccc7cd9a16f312dd3b5d36ea8b4954304657d5dfba115d4a0" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" dependencies = [ "cfg-if", "js-sys", @@ -4227,9 +4252,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4237,31 +4262,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" dependencies = [ "unicode-ident", ] [[package]] name = "web-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a1f95c0d03a47f4ae1f7a64643a6bb97465d9b740f0fa8f90ea33915c99a9a1" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" dependencies = [ "js-sys", "wasm-bindgen", @@ -4269,7 +4294,7 @@ dependencies = [ [[package]] name = "webhook-configuration" -version = "0.13.18" +version = "0.13.19" dependencies = [ "actix-rt", "actix-web", @@ -4325,7 +4350,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4336,7 +4361,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4381,6 +4406,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.60.2" @@ -4656,28 +4690,28 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.27" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.27" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4697,7 +4731,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "synstructure", ] @@ -4737,7 +4771,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f162fcb01..78815d7d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.13.18" +version = "0.13.19" edition = "2021" license = "Apache-2.0" homepage = "https://docs.akri.sh/" diff --git a/deployment/helm/Chart.yaml b/deployment/helm/Chart.yaml index 1fdc3512f..e4aacabb8 100644 --- a/deployment/helm/Chart.yaml +++ b/deployment/helm/Chart.yaml @@ -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.13.18 +version: 0.13.19 # 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.13.18 +appVersion: 0.13.19 diff --git a/version.txt b/version.txt index 2274d48d2..62dc2ab89 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.13.18 +0.13.19 From 9253e68c416bdf932805586edacbbc9e4f006424 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 12:45:27 +0100 Subject: [PATCH 08/19] style: cargo fmt fixes Signed-off-by: Gaurav Gahlot --- agent/src/plugin_manager/v1.rs | 131 +++---- agent/src/plugin_manager/v1beta1.rs | 361 ++++++------------ discovery-utils/src/discovery/v0.rs | 176 ++++----- .../udev-video-broker/src/util/camera.rs | 63 ++- 4 files changed, 258 insertions(+), 473 deletions(-) diff --git a/agent/src/plugin_manager/v1.rs b/agent/src/plugin_manager/v1.rs index c255210b7..f4cfc2df8 100644 --- a/agent/src/plugin_manager/v1.rs +++ b/agent/src/plugin_manager/v1.rs @@ -87,8 +87,8 @@ pub struct NumaNode { /// Generated client implementations. pub mod pod_resources_lister_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; /// PodResourcesLister is a service provided by the kubelet that provides information about the /// node resources consumed by pods and containers on the node #[derive(Debug, Clone)] @@ -134,9 +134,8 @@ pub mod pod_resources_lister_client { >::ResponseBody, >, >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { PodResourcesListerClient::new(InterceptedService::new(inner, interceptor)) } @@ -174,23 +173,16 @@ pub mod pod_resources_lister_client { pub async fn list( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1.PodResourcesLister/List", - ); + let path = http::uri::PathAndQuery::from_static("/v1.PodResourcesLister/List"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1.PodResourcesLister", "List")); @@ -199,28 +191,23 @@ pub mod pod_resources_lister_client { pub async fn get_allocatable_resources( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1.PodResourcesLister/GetAllocatableResources", ); let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new("v1.PodResourcesLister", "GetAllocatableResources"), - ); + req.extensions_mut().insert(GrpcMethod::new( + "v1.PodResourcesLister", + "GetAllocatableResources", + )); self.inner.unary(req, path, codec).await } } @@ -235,17 +222,11 @@ pub mod pod_resources_lister_server { async fn list( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_allocatable_resources( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; } /// PodResourcesLister is a service provided by the kubelet that provides information about the /// node resources consumed by pods and containers on the node @@ -272,10 +253,7 @@ pub mod pod_resources_lister_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -331,15 +309,11 @@ pub mod pod_resources_lister_server { "/v1.PodResourcesLister/List" => { #[allow(non_camel_case_types)] struct ListSvc(pub Arc); - impl< - T: PodResourcesLister, - > tonic::server::UnaryService - for ListSvc { + impl + tonic::server::UnaryService for ListSvc + { type Response = super::ListPodResourcesResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, @@ -377,15 +351,12 @@ pub mod pod_resources_lister_server { "/v1.PodResourcesLister/GetAllocatableResources" => { #[allow(non_camel_case_types)] struct GetAllocatableResourcesSvc(pub Arc); - impl< - T: PodResourcesLister, - > tonic::server::UnaryService - for GetAllocatableResourcesSvc { + impl + tonic::server::UnaryService + for GetAllocatableResourcesSvc + { type Response = super::AllocatableResourcesResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, @@ -393,10 +364,9 @@ pub mod pod_resources_lister_server { let inner = Arc::clone(&self.0); let fut = async move { ::get_allocatable_resources( - &inner, - request, - ) - .await + &inner, request, + ) + .await }; Box::pin(fut) } @@ -424,18 +394,14 @@ pub mod pod_resources_lister_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } @@ -461,8 +427,7 @@ pub mod pod_resources_lister_server { write!(f, "{:?}", self.0) } } - impl tonic::server::NamedService - for PodResourcesListerServer { + impl tonic::server::NamedService for PodResourcesListerServer { const NAME: &'static str = "v1.PodResourcesLister"; } } diff --git a/agent/src/plugin_manager/v1beta1.rs b/agent/src/plugin_manager/v1beta1.rs index 2f6dd0fb0..083007abe 100644 --- a/agent/src/plugin_manager/v1beta1.rs +++ b/agent/src/plugin_manager/v1beta1.rs @@ -96,9 +96,7 @@ pub struct PreStartContainerResponse {} #[derive(Clone, PartialEq, ::prost::Message)] pub struct PreferredAllocationRequest { #[prost(message, repeated, tag = "1")] - pub container_requests: ::prost::alloc::vec::Vec< - ContainerPreferredAllocationRequest, - >, + pub container_requests: ::prost::alloc::vec::Vec, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -108,9 +106,7 @@ pub struct ContainerPreferredAllocationRequest { pub available_device_i_ds: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, /// List of deviceIDs that must be included in the preferred allocation #[prost(string, repeated, tag = "2")] - pub must_include_device_i_ds: ::prost::alloc::vec::Vec< - ::prost::alloc::string::String, - >, + pub must_include_device_i_ds: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, /// Number of devices to include in the preferred allocation #[prost(int32, tag = "3")] pub allocation_size: i32, @@ -121,9 +117,7 @@ pub struct ContainerPreferredAllocationRequest { #[derive(Clone, PartialEq, ::prost::Message)] pub struct PreferredAllocationResponse { #[prost(message, repeated, tag = "1")] - pub container_responses: ::prost::alloc::vec::Vec< - ContainerPreferredAllocationResponse, - >, + pub container_responses: ::prost::alloc::vec::Vec, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -168,10 +162,8 @@ pub struct AllocateResponse { pub struct ContainerAllocateResponse { /// List of environment variable to be set in the container to access one of more devices. #[prost(map = "string, string", tag = "1")] - pub envs: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub envs: + ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, /// Mounts for the container. #[prost(message, repeated, tag = "2")] pub mounts: ::prost::alloc::vec::Vec, @@ -180,10 +172,8 @@ pub struct ContainerAllocateResponse { pub devices: ::prost::alloc::vec::Vec, /// Container annotations to pass to the container runtime #[prost(map = "string, string", tag = "4")] - pub annotations: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub annotations: + ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, } /// Mount specifies a host volume to mount into a container. /// where device library or tools are installed on host and container @@ -220,8 +210,8 @@ pub struct DeviceSpec { /// Generated client implementations. pub mod registration_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; /// Registration is the service advertised by the Kubelet /// Only when Kubelet answers with a success code to a Register Request /// may Device Plugins start their service @@ -271,9 +261,8 @@ pub mod registration_client { >::ResponseBody, >, >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { RegistrationClient::new(InterceptedService::new(inner, interceptor)) } @@ -312,19 +301,14 @@ pub mod registration_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1beta1.Registration/Register", - ); + let path = http::uri::PathAndQuery::from_static("/v1beta1.Registration/Register"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.Registration", "Register")); @@ -335,8 +319,8 @@ pub mod registration_client { /// Generated client implementations. pub mod device_plugin_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; /// DevicePlugin is the service advertised by Device Plugins #[derive(Debug, Clone)] pub struct DevicePluginClient { @@ -381,9 +365,8 @@ pub mod device_plugin_client { >::ResponseBody, >, >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { DevicePluginClient::new(InterceptedService::new(inner, interceptor)) } @@ -423,28 +406,23 @@ pub mod device_plugin_client { pub async fn get_device_plugin_options( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1beta1.DevicePlugin/GetDevicePluginOptions", ); let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new("v1beta1.DevicePlugin", "GetDevicePluginOptions"), - ); + req.extensions_mut().insert(GrpcMethod::new( + "v1beta1.DevicePlugin", + "GetDevicePluginOptions", + )); self.inner.unary(req, path, codec).await } /// ListAndWatch returns a stream of List of Devices @@ -457,19 +435,14 @@ pub mod device_plugin_client { tonic::Response>, tonic::Status, > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1beta1.DevicePlugin/ListAndWatch", - ); + let path = http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/ListAndWatch"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "ListAndWatch")); @@ -483,28 +456,23 @@ pub mod device_plugin_client { pub async fn get_preferred_allocation( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1beta1.DevicePlugin/GetPreferredAllocation", ); let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new("v1beta1.DevicePlugin", "GetPreferredAllocation"), - ); + req.extensions_mut().insert(GrpcMethod::new( + "v1beta1.DevicePlugin", + "GetPreferredAllocation", + )); self.inner.unary(req, path, codec).await } /// Allocate is called during container creation so that the Device @@ -513,23 +481,15 @@ pub mod device_plugin_client { pub async fn allocate( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1beta1.DevicePlugin/Allocate", - ); + let path = http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/Allocate"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "Allocate")); @@ -541,23 +501,17 @@ pub mod device_plugin_client { pub async fn pre_start_container( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1beta1.DevicePlugin/PreStartContainer", - ); + let path = + http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/PreStartContainer"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "PreStartContainer")); @@ -606,10 +560,7 @@ pub mod registration_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -665,23 +616,16 @@ pub mod registration_server { "/v1beta1.Registration/Register" => { #[allow(non_camel_case_types)] struct RegisterSvc(pub Arc); - impl< - T: Registration, - > tonic::server::UnaryService - for RegisterSvc { + impl tonic::server::UnaryService for RegisterSvc { type Response = super::Empty; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::register(&inner, request).await - }; + let fut = + async move { ::register(&inner, request).await }; Box::pin(fut) } } @@ -708,18 +652,14 @@ pub mod registration_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } @@ -761,15 +701,11 @@ pub mod device_plugin_server { async fn get_device_plugin_options( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the ListAndWatch method. type ListAndWatchStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, - > - + Send + > + Send + 'static; /// ListAndWatch returns a stream of List of Devices /// Whenever a Device state change or a Device disappears, ListAndWatch @@ -777,10 +713,7 @@ pub mod device_plugin_server { async fn list_and_watch( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// GetPreferredAllocation returns a preferred set of devices to allocate /// from a list of available ones. The resulting preferred allocation is not /// guaranteed to be the allocation ultimately performed by the @@ -789,30 +722,21 @@ pub mod device_plugin_server { async fn get_preferred_allocation( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// Allocate is called during container creation so that the Device /// Plugin can run device specific operations and instruct Kubelet /// of the steps to make the Device available in the container async fn allocate( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// PreStartContainer is called, if indicated by Device Plugin during registration phase, /// before each container start. Device plugin can run device specific operations /// such as resetting the device before making devices available to the container async fn pre_start_container( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; } /// DevicePlugin is the service advertised by Device Plugins #[derive(Debug)] @@ -838,10 +762,7 @@ pub mod device_plugin_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -897,23 +818,13 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/GetDevicePluginOptions" => { #[allow(non_camel_case_types)] struct GetDevicePluginOptionsSvc(pub Arc); - impl tonic::server::UnaryService - for GetDevicePluginOptionsSvc { + impl tonic::server::UnaryService for GetDevicePluginOptionsSvc { type Response = super::DevicePluginOptions; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::get_device_plugin_options( - &inner, - request, - ) + ::get_device_plugin_options(&inner, request) .await }; Box::pin(fut) @@ -945,20 +856,12 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/ListAndWatch" => { #[allow(non_camel_case_types)] struct ListAndWatchSvc(pub Arc); - impl< - T: DevicePlugin, - > tonic::server::ServerStreamingService - for ListAndWatchSvc { + impl tonic::server::ServerStreamingService for ListAndWatchSvc { type Response = super::ListAndWatchResponse; type ResponseStream = T::ListAndWatchStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = + BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::list_and_watch(&inner, request).await @@ -992,26 +895,19 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/GetPreferredAllocation" => { #[allow(non_camel_case_types)] struct GetPreferredAllocationSvc(pub Arc); - impl< - T: DevicePlugin, - > tonic::server::UnaryService - for GetPreferredAllocationSvc { + impl + tonic::server::UnaryService + for GetPreferredAllocationSvc + { type Response = super::PreferredAllocationResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::get_preferred_allocation( - &inner, - request, - ) - .await + ::get_preferred_allocation(&inner, request).await }; Box::pin(fut) } @@ -1042,23 +938,16 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/Allocate" => { #[allow(non_camel_case_types)] struct AllocateSvc(pub Arc); - impl< - T: DevicePlugin, - > tonic::server::UnaryService - for AllocateSvc { + impl tonic::server::UnaryService for AllocateSvc { type Response = super::AllocateResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::allocate(&inner, request).await - }; + let fut = + async move { ::allocate(&inner, request).await }; Box::pin(fut) } } @@ -1088,23 +977,19 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/PreStartContainer" => { #[allow(non_camel_case_types)] struct PreStartContainerSvc(pub Arc); - impl< - T: DevicePlugin, - > tonic::server::UnaryService - for PreStartContainerSvc { + impl + tonic::server::UnaryService + for PreStartContainerSvc + { type Response = super::PreStartContainerResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::pre_start_container(&inner, request) - .await + ::pre_start_container(&inner, request).await }; Box::pin(fut) } @@ -1132,18 +1017,14 @@ pub mod device_plugin_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } diff --git a/discovery-utils/src/discovery/v0.rs b/discovery-utils/src/discovery/v0.rs index a20490c38..08781a68e 100644 --- a/discovery-utils/src/discovery/v0.rs +++ b/discovery-utils/src/discovery/v0.rs @@ -9,7 +9,10 @@ pub struct RegisterDiscoveryHandlerRequest { /// Endpoint for the registering `DiscoveryHandler` #[prost(string, tag = "2")] pub endpoint: ::prost::alloc::string::String, - #[prost(enumeration = "register_discovery_handler_request::EndpointType", tag = "3")] + #[prost( + enumeration = "register_discovery_handler_request::EndpointType", + tag = "3" + )] pub endpoint_type: i32, /// Specifies whether this device could be used by multiple nodes (e.g. an IP camera) /// or can only be ever be discovered by a single node (e.g. a local USB device) @@ -19,17 +22,7 @@ pub struct RegisterDiscoveryHandlerRequest { /// Nested message and enum types in `RegisterDiscoveryHandlerRequest`. pub mod register_discovery_handler_request { /// Specifies the type of endpoint. - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum EndpointType { Uds = 0, @@ -75,10 +68,7 @@ pub struct DiscoverRequest { /// list of Key-value pairs containing additional information /// for the 'DiscoveryHandler' to discover devices #[prost(map = "string, message", tag = "2")] - pub discovery_properties: ::std::collections::HashMap< - ::prost::alloc::string::String, - ByteData, - >, + pub discovery_properties: ::std::collections::HashMap<::prost::alloc::string::String, ByteData>, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -97,10 +87,8 @@ pub struct Device { /// and set as environment variables in the device's broker Pods. May be information /// about where to find the device such as an RTSP URL or a device node (e.g. `/dev/video1`) #[prost(map = "string, string", tag = "2")] - pub properties: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub properties: + ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, /// Optionally specify mounts for Pods that request this device as a resource #[prost(message, repeated, tag = "3")] pub mounts: ::prost::alloc::vec::Vec, @@ -145,8 +133,8 @@ pub struct DeviceSpec { /// Generated client implementations. pub mod registration_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; /// Registration is the service advertised by the Akri Agent. /// Any `DiscoveryHandler` can register with the Akri Agent. #[derive(Debug, Clone)] @@ -192,9 +180,8 @@ pub mod registration_client { >::ResponseBody, >, >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { RegistrationClient::new(InterceptedService::new(inner, interceptor)) } @@ -233,22 +220,20 @@ pub mod registration_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v0.Registration/RegisterDiscoveryHandler", - ); + let path = + http::uri::PathAndQuery::from_static("/v0.Registration/RegisterDiscoveryHandler"); let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("v0.Registration", "RegisterDiscoveryHandler")); + req.extensions_mut().insert(GrpcMethod::new( + "v0.Registration", + "RegisterDiscoveryHandler", + )); self.inner.unary(req, path, codec).await } } @@ -256,8 +241,8 @@ pub mod registration_client { /// Generated client implementations. pub mod discovery_handler_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; #[derive(Debug, Clone)] pub struct DiscoveryHandlerClient { inner: tonic::client::Grpc, @@ -301,9 +286,8 @@ pub mod discovery_handler_client { >::ResponseBody, >, >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { DiscoveryHandlerClient::new(InterceptedService::new(inner, interceptor)) } @@ -345,19 +329,14 @@ pub mod discovery_handler_client { tonic::Response>, tonic::Status, > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v0.DiscoveryHandler/Discover", - ); + let path = http::uri::PathAndQuery::from_static("/v0.DiscoveryHandler/Discover"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v0.DiscoveryHandler", "Discover")); @@ -402,10 +381,7 @@ pub mod registration_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -461,27 +437,19 @@ pub mod registration_server { "/v0.Registration/RegisterDiscoveryHandler" => { #[allow(non_camel_case_types)] struct RegisterDiscoveryHandlerSvc(pub Arc); - impl< - T: Registration, - > tonic::server::UnaryService - for RegisterDiscoveryHandlerSvc { + impl + tonic::server::UnaryService + for RegisterDiscoveryHandlerSvc + { type Response = super::Empty; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, - request: tonic::Request< - super::RegisterDiscoveryHandlerRequest, - >, + request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::register_discovery_handler( - &inner, - request, - ) + ::register_discovery_handler(&inner, request) .await }; Box::pin(fut) @@ -510,18 +478,14 @@ pub mod registration_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } @@ -561,8 +525,7 @@ pub mod discovery_handler_server { /// Server streaming response type for the Discover method. type DiscoverStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, - > - + Send + > + Send + 'static; async fn discover( &self, @@ -592,10 +555,7 @@ pub mod discovery_handler_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -651,16 +611,14 @@ pub mod discovery_handler_server { "/v0.DiscoveryHandler/Discover" => { #[allow(non_camel_case_types)] struct DiscoverSvc(pub Arc); - impl< - T: DiscoveryHandler, - > tonic::server::ServerStreamingService - for DiscoverSvc { + impl + tonic::server::ServerStreamingService + for DiscoverSvc + { type Response = super::DiscoverResponse; type ResponseStream = T::DiscoverStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = + BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, @@ -695,18 +653,14 @@ pub mod discovery_handler_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } diff --git a/samples/brokers/udev-video-broker/src/util/camera.rs b/samples/brokers/udev-video-broker/src/util/camera.rs index 4bd208251..437b09cd8 100644 --- a/samples/brokers/udev-video-broker/src/util/camera.rs +++ b/samples/brokers/udev-video-broker/src/util/camera.rs @@ -13,8 +13,8 @@ pub struct NotifyResponse { /// Generated client implementations. pub mod camera_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; #[derive(Debug, Clone)] pub struct CameraClient { inner: tonic::client::Grpc, @@ -58,9 +58,8 @@ pub mod camera_client { >::ResponseBody, >, >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { CameraClient::new(InterceptedService::new(inner, interceptor)) } @@ -99,19 +98,17 @@ pub mod camera_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/camera.Camera/GetFrame"); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("camera.Camera", "GetFrame")); + req.extensions_mut() + .insert(GrpcMethod::new("camera.Camera", "GetFrame")); self.inner.unary(req, path, codec).await } } @@ -151,10 +148,7 @@ pub mod camera_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -210,21 +204,16 @@ pub mod camera_server { "/camera.Camera/GetFrame" => { #[allow(non_camel_case_types)] struct GetFrameSvc(pub Arc); - impl tonic::server::UnaryService - for GetFrameSvc { + impl tonic::server::UnaryService for GetFrameSvc { type Response = super::NotifyResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_frame(&inner, request).await - }; + let fut = + async move { ::get_frame(&inner, request).await }; Box::pin(fut) } } @@ -251,18 +240,14 @@ pub mod camera_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } From 2ec7aed1fc46cf12f631f933fe5042c6114d9796 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 12:53:10 +0100 Subject: [PATCH 09/19] chore: update rust version to 1.85 Signed-off-by: Gaurav Gahlot --- Cargo.toml | 2 +- discovery-handlers/opcua/src/discovery_impl.rs | 6 +++--- discovery-utils/src/discovery/mod.rs | 8 ++++---- shared/src/akri/configuration.rs | 4 ++-- shared/src/akri/instance.rs | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 78815d7d6..b61194092 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,5 +28,5 @@ edition = "2021" license = "Apache-2.0" homepage = "https://docs.akri.sh/" repository = "https://github.com/project-akri/akri" -rust-version = "1.82" +rust-version = "1.85" authors = ["The Akri Team"] diff --git a/discovery-handlers/opcua/src/discovery_impl.rs b/discovery-handlers/opcua/src/discovery_impl.rs index a8d7e808c..6ab36755b 100644 --- a/discovery-handlers/opcua/src/discovery_impl.rs +++ b/discovery-handlers/opcua/src/discovery_impl.rs @@ -57,12 +57,12 @@ fn get_discovery_urls( ) -> Vec { let mut discovery_urls: Vec = Vec::new(); lds_urls.iter().for_each(|url| { - if let Err(e) = test_tcp_connection(url, &tcp_stream) { + match test_tcp_connection(url, &tcp_stream) { Err(e) => { error!( "get_discovery_urls - failed to make tcp connection with url {} with error {:?}", url, e ); - } else { + } _ => { match discovery_handler_client.find_servers(url) { Ok(applications) => { trace!( @@ -89,7 +89,7 @@ fn get_discovery_urls( ); } }; - } + }} }); // Remove duplicates in the case that a server was registered with more than one LDS discovery_urls.dedup(); diff --git a/discovery-utils/src/discovery/mod.rs b/discovery-utils/src/discovery/mod.rs index 3243188ff..b2b32d1b4 100644 --- a/discovery-utils/src/discovery/mod.rs +++ b/discovery-utils/src/discovery/mod.rs @@ -313,17 +313,17 @@ pub mod server { .prefix("discovery-handlers") .tempdir() .unwrap(); - if let Err(e) = internal_run_discovery_server( + match internal_run_discovery_server( discovery_handler, "random", discovery_handler_temp_dir.path().to_str().unwrap(), ) .await - { + { Err(e) => { assert!((*e).to_string().contains("invalid socket address syntax")) - } else { + } _ => { panic!("should be invalid address error") - } + }} } } } diff --git a/shared/src/akri/configuration.rs b/shared/src/akri/configuration.rs index d2dd59532..353cde120 100644 --- a/shared/src/akri/configuration.rs +++ b/shared/src/akri/configuration.rs @@ -151,9 +151,9 @@ pub struct ConfigurationSpec { pub broker_properties: HashMap, } -fn immutable_dh_info(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { +fn immutable_dh_info(r#gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let mut schema: schemars::schema::SchemaObject = - ::json_schema(gen).into(); + ::json_schema(r#gen).into(); schema.extensions.insert( "x-kubernetes-validations".to_owned(), serde_json::from_str(r#"[{"message": "Value is immutable", "rule": "self == oldSelf"}]"#) diff --git a/shared/src/akri/instance.rs b/shared/src/akri/instance.rs index 22a1eb485..255f7edd6 100644 --- a/shared/src/akri/instance.rs +++ b/shared/src/akri/instance.rs @@ -89,8 +89,8 @@ pub struct InstanceSpec { pub device_usage: HashMap, } -fn ssa_nodes_set(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - let mut schema: schemars::schema::SchemaObject = >::json_schema(gen).into(); +fn ssa_nodes_set(r#gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { + let mut schema: schemars::schema::SchemaObject = >::json_schema(r#gen).into(); schema.extensions.insert( "x-kubernetes-list-type".to_owned(), serde_json::Value::String("set".to_owned()), @@ -98,9 +98,9 @@ fn ssa_nodes_set(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema:: schema.into() } -fn ssa_usage_granular(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { +fn ssa_usage_granular(r#gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema { let mut schema: schemars::schema::SchemaObject = - >::json_schema(gen).into(); + >::json_schema(r#gen).into(); schema.extensions.insert( "x-kubernetes-map-type".to_owned(), serde_json::Value::String("granular".to_owned()), From 592f280c1266dc76f789cd9410ee3f8be33a5be7 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 12:55:03 +0100 Subject: [PATCH 10/19] style: more cargo fmt fixes Signed-off-by: Gaurav Gahlot --- .../opcua/src/discovery_impl.rs | 61 ++++++++++--------- discovery-utils/src/discovery/mod.rs | 13 ++-- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/discovery-handlers/opcua/src/discovery_impl.rs b/discovery-handlers/opcua/src/discovery_impl.rs index 6ab36755b..3cc52cc3c 100644 --- a/discovery-handlers/opcua/src/discovery_impl.rs +++ b/discovery-handlers/opcua/src/discovery_impl.rs @@ -56,41 +56,44 @@ fn get_discovery_urls( tcp_stream: impl TcpStream, ) -> Vec { let mut discovery_urls: Vec = Vec::new(); - lds_urls.iter().for_each(|url| { - match test_tcp_connection(url, &tcp_stream) { Err(e) => { - error!( + lds_urls + .iter() + .for_each(|url| match test_tcp_connection(url, &tcp_stream) { + Err(e) => { + error!( "get_discovery_urls - failed to make tcp connection with url {} with error {:?}", url, e ); - } _ => { - match discovery_handler_client.find_servers(url) { - Ok(applications) => { - trace!( - "get_discovery_urls - Server at {} responded with {} Applications", - url, - applications.len() - ); - let mut servers_discovery_urls: Vec = applications - .iter() - .filter_map(|application| { - get_discovery_url_from_application_description( - application, - filter_list.as_ref(), - url, - ) - }) - .collect::>(); - discovery_urls.append(&mut servers_discovery_urls); - } - Err(err) => { - trace!( + } + _ => { + match discovery_handler_client.find_servers(url) { + Ok(applications) => { + trace!( + "get_discovery_urls - Server at {} responded with {} Applications", + url, + applications.len() + ); + let mut servers_discovery_urls: Vec = applications + .iter() + .filter_map(|application| { + get_discovery_url_from_application_description( + application, + filter_list.as_ref(), + url, + ) + }) + .collect::>(); + discovery_urls.append(&mut servers_discovery_urls); + } + Err(err) => { + trace!( "get_discovery_urls - cannot find servers on discovery server. Error {:?}", err ); - } - }; - }} - }); + } + }; + } + }); // Remove duplicates in the case that a server was registered with more than one LDS discovery_urls.dedup(); discovery_urls diff --git a/discovery-utils/src/discovery/mod.rs b/discovery-utils/src/discovery/mod.rs index b2b32d1b4..062d1980a 100644 --- a/discovery-utils/src/discovery/mod.rs +++ b/discovery-utils/src/discovery/mod.rs @@ -319,11 +319,14 @@ pub mod server { discovery_handler_temp_dir.path().to_str().unwrap(), ) .await - { Err(e) => { - assert!((*e).to_string().contains("invalid socket address syntax")) - } _ => { - panic!("should be invalid address error") - }} + { + Err(e) => { + assert!((*e).to_string().contains("invalid socket address syntax")) + } + _ => { + panic!("should be invalid address error") + } + } } } } From 90c07b57ccba5d2ba7ad3cd9e0babb99cb3e83b5 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 13:01:13 +0100 Subject: [PATCH 11/19] chore: update builder to 1.85 Signed-off-by: Gaurav Gahlot --- README.md | 2 +- build/containers/Dockerfile.rust | 2 +- build/setup.sh | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f360dd07e..d05c5db4e 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.82.0-blue.svg)](https://blog.rust-lang.org/2024/10/17/Rust-1.82.0/) +[![Rust Version](https://img.shields.io/badge/rustc-1.85.0-blue.svg)](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0/) [![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/build/containers/Dockerfile.rust b/build/containers/Dockerfile.rust index b80908684..9448895f4 100644 --- a/build/containers/Dockerfile.rust +++ b/build/containers/Dockerfile.rust @@ -1,6 +1,6 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:master AS xx -FROM --platform=$BUILDPLATFORM rust:1.82-slim-bookworm AS build +FROM --platform=$BUILDPLATFORM rust:1.85-slim-bookworm AS build RUN rustup component add rustfmt RUN apt-get update && apt-get install -y clang lld protobuf-compiler pkg-config mmdebstrap wget COPY --from=xx / / diff --git a/build/setup.sh b/build/setup.sh index 0aa29ff80..b4a4c43ab 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.82.0 + sudo curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.85.0 else echo "Install rustup" - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.82.0 + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.85.0 fi else echo "Found rustup" @@ -35,4 +35,4 @@ fi echo "Install rustfmt" rustup component add rustfmt -exit 0 \ No newline at end of file +exit 0 From 1e11aa41bf250e49f9bfd9c61dfbea7773830af5 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 13:13:34 +0100 Subject: [PATCH 12/19] chore: update edition in Cargo.toml Signed-off-by: Gaurav Gahlot --- Cargo.toml | 2 +- agent/src/device_manager/in_memory.rs | 2 +- .../discovery_handler_registry.rs | 158 ++++++++++-------- .../discovery_property_solver.rs | 8 +- .../embedded_handler.rs | 16 +- .../registration_socket.rs | 77 +++++---- agent/src/main.rs | 2 +- .../device_plugin_instance_controller.rs | 54 +++--- .../plugin_manager/device_plugin_runner.rs | 7 +- agent/src/plugin_manager/v1.rs | 8 +- agent/src/plugin_manager/v1beta1.rs | 16 +- .../discovery_configuration_controller.rs | 4 +- agent/src/util/metrics.rs | 2 +- controller/src/main.rs | 2 +- controller/src/util/instance_action.rs | 108 ++++++------ controller/src/util/node_watcher.rs | 79 +++++---- controller/src/util/pod_watcher.rs | 135 ++++++++------- controller/src/util/shared_test_utils.rs | 19 +-- .../debug-echo-discovery-handler/src/main.rs | 6 +- .../onvif-discovery-handler/src/main.rs | 4 +- .../opcua-discovery-handler/src/main.rs | 4 +- .../udev-discovery-handler/src/main.rs | 4 +- .../debug-echo/src/discovery_handler.rs | 14 +- .../onvif/src/discovery_handler.rs | 107 +++++++----- .../onvif/src/discovery_impl.rs | 49 +++--- .../onvif/src/discovery_utils.rs | 124 ++++++++------ .../opcua/src/discovery_handler.rs | 8 +- .../opcua/src/discovery_impl.rs | 18 +- .../udev/src/discovery_handler.rs | 12 +- discovery-handlers/udev/src/discovery_impl.rs | 20 ++- discovery-utils/src/discovery/mod.rs | 14 +- discovery-utils/src/discovery/v0.rs | 16 +- discovery-utils/src/registration_client.rs | 4 +- samples/brokers/udev-video-broker/src/main.rs | 2 +- .../udev-video-broker/src/util/camera.rs | 8 +- .../src/util/camera_capturer.rs | 9 +- .../src/util/camera_service.rs | 2 +- shared/src/akri/instance.rs | 2 +- shared/src/k8s/api.rs | 2 +- shared/src/k8s/job.rs | 45 ++--- shared/src/k8s/mod.rs | 8 +- shared/src/k8s/pod.rs | 45 ++--- shared/src/k8s/service.rs | 43 ++--- webhooks/validating/configuration/src/main.rs | 4 +- 44 files changed, 704 insertions(+), 569 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b61194092..d88c28215 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ resolver = "2" [workspace.package] version = "0.13.19" -edition = "2021" +edition = "2024" license = "Apache-2.0" homepage = "https://docs.akri.sh/" repository = "https://github.com/project-akri/akri" diff --git a/agent/src/device_manager/in_memory.rs b/agent/src/device_manager/in_memory.rs index 54611c4e3..5da87d051 100644 --- a/agent/src/device_manager/in_memory.rs +++ b/agent/src/device_manager/in_memory.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use super::{cdi, DeviceManager}; +use super::{DeviceManager, cdi}; use tokio::sync::watch; pub struct InMemoryManager { diff --git a/agent/src/discovery_handler_manager/discovery_handler_registry.rs b/agent/src/discovery_handler_manager/discovery_handler_registry.rs index 49be7ee18..20a76c676 100644 --- a/agent/src/discovery_handler_manager/discovery_handler_registry.rs +++ b/agent/src/discovery_handler_manager/discovery_handler_registry.rs @@ -24,22 +24,22 @@ use akri_discovery_utils::discovery::v0::{ByteData, Device, DiscoverRequest}; use akri_shared::akri::configuration::{Configuration, DiscoveryProperty}; use akri_shared::akri::instance::Instance; -use akri_shared::akri::instance::InstanceSpec; use akri_shared::akri::AKRI_PREFIX; +use akri_shared::akri::instance::InstanceSpec; use async_trait::async_trait; -use blake2::digest::{Update, VariableOutput}; use blake2::VarBlake2b; +use blake2::digest::{Update, VariableOutput}; +use futures::FutureExt; use futures::future::select_all; use futures::future::try_join_all; -use futures::FutureExt; use itertools::Itertools; use kube::core::ObjectMeta; use kube_runtime::reflector::ObjectRef; use tokio::select; +use tokio::sync::RwLock; use tokio::sync::mpsc; use tokio::sync::watch; -use tokio::sync::RwLock; -use tokio::sync::{broadcast, Mutex, Notify}; +use tokio::sync::{Mutex, Notify, broadcast}; use super::discovery_property_solver::PropertySolver; use super::{DiscoveryError, DiscoveryManagerKubeInterface}; @@ -781,14 +781,16 @@ mod tests { }); endpoint.expect_is_closed().return_const(true); dh_reg.register_endpoint(Arc::new(endpoint)).await; - assert!(dh_reg - .handlers - .read() - .await - .get("mock_handler") - .unwrap() - .get("mock_handler_local") - .is_some()); + assert!( + dh_reg + .handlers + .read() + .await + .get("mock_handler") + .unwrap() + .get("mock_handler_local") + .is_some() + ); let mut endpoint = MockDiscoveryHandlerEndpoint::new(); let (close_2, closed) = tokio::sync::oneshot::channel::<()>(); @@ -804,33 +806,39 @@ mod tests { endpoint.expect_is_closed().once().return_const(false); endpoint.expect_is_closed().once().return_const(true); dh_reg.register_endpoint(Arc::new(endpoint)).await; - assert!(dh_reg - .handlers - .read() - .await - .get("mock_handler") - .unwrap() - .get("mock_handler_local_2") - .is_some()); + assert!( + dh_reg + .handlers + .read() + .await + .get("mock_handler") + .unwrap() + .get("mock_handler_local_2") + .is_some() + ); close_1.send(()).unwrap(); tokio::time::sleep(Duration::from_millis(500)).await; - assert!(dh_reg - .handlers - .read() - .await - .get("mock_handler") - .unwrap() - .get("mock_handler_local") - .is_none()); - assert!(dh_reg - .handlers - .read() - .await - .get("mock_handler") - .unwrap() - .get("mock_handler_local_2") - .is_some()); + assert!( + dh_reg + .handlers + .read() + .await + .get("mock_handler") + .unwrap() + .get("mock_handler_local") + .is_none() + ); + assert!( + dh_reg + .handlers + .read() + .await + .get("mock_handler") + .unwrap() + .get("mock_handler_local_2") + .is_some() + ); close_2.send(()).unwrap(); tokio::time::sleep(Duration::from_millis(500)).await; @@ -864,18 +872,22 @@ mod tests { assert!(dh_reg.get_request("my-config").await.is_some()); assert!(dh_reg.get_request("my-other-config").await.is_none()); - assert!(tokio::time::timeout( - Duration::from_millis(500), - request.termination_notifier.notified() - ) - .await - .is_err()); + assert!( + tokio::time::timeout( + Duration::from_millis(500), + request.termination_notifier.notified() + ) + .await + .is_err() + ); let notif = request.termination_notifier.notified(); dh_reg.terminate_request("my-config").await; - assert!(tokio::time::timeout(Duration::from_millis(500), notif) - .await - .is_ok()); + assert!( + tokio::time::timeout(Duration::from_millis(500), notif) + .await + .is_ok() + ); } #[tokio::test] @@ -885,21 +897,23 @@ mod tests { let kube_client = Arc::new(MockDiscoveryManagerKubeInterface::new()); let dh_reg = DHRegistryImpl::new(kube_client.clone(), cdi_notifier, configuration_notifier); - assert!(dh_reg - .new_request( - "my-config", - "mock_handler", - "discovery details", - &[], - HashMap::from([]), - "namespace" - ) - .await - .is_err_and(|e| { - matches!(e, - DiscoveryError::NoHandler(s) if s == *"mock_handler" + assert!( + dh_reg + .new_request( + "my-config", + "mock_handler", + "discovery details", + &[], + HashMap::from([]), + "namespace" ) - })); + .await + .is_err_and(|e| { + matches!(e, + DiscoveryError::NoHandler(s) if s == *"mock_handler" + ) + }) + ); let dev_senders = Arc::new(std::sync::Mutex::new(vec![])); @@ -938,17 +952,19 @@ mod tests { }); dh_reg.register_endpoint(Arc::new(endpoint)).await; - assert!(dh_reg - .new_request( - "my-config", - "mock_handler", - "discovery details", - &[], - HashMap::from([]), - "namespace" - ) - .await - .is_ok()); + assert!( + dh_reg + .new_request( + "my-config", + "mock_handler", + "discovery details", + &[], + HashMap::from([]), + "namespace" + ) + .await + .is_ok() + ); assert!(cdi_rec.borrow_and_update().is_empty()); assert_eq!(config_rec.try_recv(), Err(mpsc::error::TryRecvError::Empty)); diff --git a/agent/src/discovery_handler_manager/discovery_property_solver.rs b/agent/src/discovery_handler_manager/discovery_property_solver.rs index 6c06dd7cb..d6f5c6b56 100644 --- a/agent/src/discovery_handler_manager/discovery_property_solver.rs +++ b/agent/src/discovery_handler_manager/discovery_property_solver.rs @@ -223,9 +223,11 @@ mod tests { .return_once(|_| Box::new(mock_secret_api)); // solve_value_from_secret should return error if key in secret not found - assert!(solve_value_from_secret(&selector, &mock_kube_client) - .await - .is_err()); + assert!( + solve_value_from_secret(&selector, &mock_kube_client) + .await + .is_err() + ); } #[tokio::test] diff --git a/agent/src/discovery_handler_manager/embedded_handler.rs b/agent/src/discovery_handler_manager/embedded_handler.rs index 6d0320892..f74325420 100644 --- a/agent/src/discovery_handler_manager/embedded_handler.rs +++ b/agent/src/discovery_handler_manager/embedded_handler.rs @@ -1,13 +1,13 @@ use std::sync::Arc; use akri_discovery_utils::discovery::{ - v0::{discovery_handler_server::DiscoveryHandler, DiscoverRequest, DiscoverResponse}, DiscoverStream, + v0::{DiscoverRequest, DiscoverResponse, discovery_handler_server::DiscoveryHandler}, }; use akri_shared::os::env_var::{ActualEnvVarQuery, EnvVarQuery}; use async_trait::async_trait; use tokio::{select, sync::watch}; -use tokio_stream::{wrappers::ReceiverStream, StreamExt}; +use tokio_stream::{StreamExt, wrappers::ReceiverStream}; use tonic::IntoRequest; /// Label of environment variable that, when set, enables the embedded debug echo discovery handler @@ -15,10 +15,10 @@ use tonic::IntoRequest; pub const ENABLE_DEBUG_ECHO_LABEL: &str = "ENABLE_DEBUG_ECHO"; use super::{ + DiscoveryError, discovery_handler_registry::{ DiscoveredDevice, DiscoveryHandlerEndpoint, DiscoveryHandlerRegistry, }, - DiscoveryError, }; struct EmbeddedHandlerEndpoint { @@ -78,11 +78,17 @@ impl DiscoveryHandlerEndpoint for EmbeddedHandlerEndpoint { Err(e) => { match e.code() { tonic::Code::InvalidArgument => { - warn!("NetworkEndpoint::query - invalid arguments provided to DiscoveryHandler"); + warn!( + "NetworkEndpoint::query - invalid arguments provided to DiscoveryHandler" + ); return Err(DiscoveryError::InvalidDiscoveryDetails); } _ => { - error!("NetworkEndpoint::query - could not connect to DiscoveryHandler at endpoint {} with error {}", self.get_uid(), e); + error!( + "NetworkEndpoint::query - could not connect to DiscoveryHandler at endpoint {} with error {}", + self.get_uid(), + e + ); // We do not consider the DH as unavailable here, as this can be a temporary error return Err(DiscoveryError::UnavailableDiscoveryHandler(self.get_uid())); } diff --git a/agent/src/discovery_handler_manager/registration_socket.rs b/agent/src/discovery_handler_manager/registration_socket.rs index 1bc67aadd..d21a073bc 100644 --- a/agent/src/discovery_handler_manager/registration_socket.rs +++ b/agent/src/discovery_handler_manager/registration_socket.rs @@ -1,24 +1,24 @@ use std::{convert::TryFrom, pin::Pin, sync::Arc}; use akri_discovery_utils::discovery::v0::{ + DiscoverRequest, DiscoverResponse, Empty, RegisterDiscoveryHandlerRequest, discovery_handler_client::DiscoveryHandlerClient, register_discovery_handler_request::EndpointType, registration_server::Registration, - DiscoverRequest, DiscoverResponse, Empty, RegisterDiscoveryHandlerRequest, }; use akri_shared::uds::unix_stream; use async_trait::async_trait; use futures::{Stream, StreamExt, TryFutureExt}; use tokio::{select, sync::watch}; use tokio_stream::StreamExt as _; -use tonic::{transport::Channel, Request, Response, Status}; +use tonic::{Request, Response, Status, transport::Channel}; use crate::util::stopper::Stopper; use super::{ + DiscoveryError, discovery_handler_registry::{ DiscoveredDevice, DiscoveryHandlerEndpoint, DiscoveryHandlerRegistry, }, - DiscoveryError, }; struct NetworkEndpoint { @@ -122,11 +122,17 @@ impl DiscoveryHandlerEndpoint for NetworkEndpoint { Err(e) => { match e.code() { tonic::Code::InvalidArgument => { - warn!("NetworkEndpoint::query - invalid arguments provided to DiscoveryHandler"); + warn!( + "NetworkEndpoint::query - invalid arguments provided to DiscoveryHandler" + ); return Err(DiscoveryError::InvalidDiscoveryDetails); } _ => { - error!("NetworkEndpoint::query - could not connect to DiscoveryHandler at endpoint {} with error {}", self.get_uid(), e); + error!( + "NetworkEndpoint::query - could not connect to DiscoveryHandler at endpoint {} with error {}", + self.get_uid(), + e + ); // We do not consider the DH as unavailable here, as this can be a temporary error return Err(DiscoveryError::UnavailableDiscoveryHandler( self.get_uid(), @@ -137,7 +143,10 @@ impl DiscoveryHandlerEndpoint for NetworkEndpoint { } } Err(e) => { - error!("NetworkEndpoint::query - failed to connect to {} discovery handler over network with error {}", self.name, e); + error!( + "NetworkEndpoint::query - failed to connect to {} discovery handler over network with error {}", + self.name, e + ); // We failed to connect to Discovery Handler, consider it offline now self.stopped.stop(); return Err(DiscoveryError::UnavailableDiscoveryHandler(self.get_uid())); @@ -259,15 +268,17 @@ mod tests { sender, stream.boxed(), )); - assert!(st_sender - .send(Ok(DiscoverResponse { - devices: vec![Device { - id: "bar".to_string(), - ..Default::default() - }] - })) - .await - .is_ok()); + assert!( + st_sender + .send(Ok(DiscoverResponse { + devices: vec![Device { + id: "bar".to_string(), + ..Default::default() + }] + })) + .await + .is_ok() + ); assert!( tokio::time::timeout(Duration::from_millis(500), receiver.changed()) .await @@ -286,9 +297,11 @@ mod tests { ); drop(receiver); - assert!(tokio::time::timeout(Duration::from_millis(500), task) - .await - .is_ok()); + assert!( + tokio::time::timeout(Duration::from_millis(500), task) + .await + .is_ok() + ); } #[tokio::test] @@ -309,15 +322,17 @@ mod tests { sender, stream.boxed(), )); - assert!(st_sender - .send(Ok(DiscoverResponse { - devices: vec![Device { - id: "bar".to_string(), - ..Default::default() - }] - })) - .await - .is_ok()); + assert!( + st_sender + .send(Ok(DiscoverResponse { + devices: vec![Device { + id: "bar".to_string(), + ..Default::default() + }] + })) + .await + .is_ok() + ); assert!( tokio::time::timeout(Duration::from_millis(500), receiver.changed()) .await @@ -333,8 +348,10 @@ mod tests { ); stopper.stop(); - assert!(tokio::time::timeout(Duration::from_millis(500), task) - .await - .is_ok()); + assert!( + tokio::time::timeout(Duration::from_millis(500), task) + .await + .is_ok() + ); } } diff --git a/agent/src/main.rs b/agent/src/main.rs index 3416d0af6..8e54bf9ad 100644 --- a/agent/src/main.rs +++ b/agent/src/main.rs @@ -8,7 +8,7 @@ mod discovery_handler_manager; mod plugin_manager; mod util; -use akri_shared::akri::{metrics::run_metrics_server, API_NAMESPACE}; +use akri_shared::akri::{API_NAMESPACE, metrics::run_metrics_server}; use log::{info, trace}; use std::{ collections::HashMap, diff --git a/agent/src/plugin_manager/device_plugin_instance_controller.rs b/agent/src/plugin_manager/device_plugin_instance_controller.rs index 4b220eb8d..928b48850 100644 --- a/agent/src/plugin_manager/device_plugin_instance_controller.rs +++ b/agent/src/plugin_manager/device_plugin_instance_controller.rs @@ -11,20 +11,20 @@ use itertools::Itertools; use kube::api::{Patch, PatchParams}; use kube::core::{NotUsed, Object, ObjectMeta, TypeMeta}; use kube::{Resource, ResourceExt}; +use kube_runtime::Controller; use kube_runtime::controller::Action; use kube_runtime::reflector::Store; -use kube_runtime::Controller; use thiserror::Error; -use tokio::sync::{watch, Mutex, RwLock}; +use tokio::sync::{Mutex, RwLock, watch}; use tokio::task::JoinHandle; use tonic::Request; -use crate::device_manager::{cdi, DeviceManager}; +use crate::device_manager::{DeviceManager, cdi}; use crate::plugin_manager::v1beta1::ContainerAllocateResponse; use crate::util::stopper::Stopper; use super::device_plugin_runner::{ - serve_and_register_plugin, DeviceUsageStream, InternalDevicePlugin, + DeviceUsageStream, InternalDevicePlugin, serve_and_register_plugin, }; use super::v1beta1::{AllocateRequest, AllocateResponse, ListAndWatchResponse}; @@ -1033,10 +1033,12 @@ mod tests { ) .unwrap(); - assert!(plugin - .update_slots(&HashMap::from([("slot-1".to_owned(), "node-a".to_owned())])) - .await - .is_ok(),); + assert!( + plugin + .update_slots(&HashMap::from([("slot-1".to_owned(), "node-a".to_owned())])) + .await + .is_ok(), + ); assert_eq!( plugin.slots_status.lock().await.borrow()[1], @@ -1413,22 +1415,26 @@ mod tests { stopper: stopper.clone(), }); - assert!(instance_plugin - .allocate(Request::new(AllocateRequest { - container_requests: vec![ContainerAllocateRequest { - devices_i_ds: vec!["instance-a-0".to_owned()], - }] - })) - .await - .is_err()); - assert!(instance_plugin - .allocate(Request::new(AllocateRequest { - container_requests: vec![ContainerAllocateRequest { - devices_i_ds: vec!["instance-a-3".to_owned()], - }] - })) - .await - .is_ok()); + assert!( + instance_plugin + .allocate(Request::new(AllocateRequest { + container_requests: vec![ContainerAllocateRequest { + devices_i_ds: vec!["instance-a-0".to_owned()], + }] + })) + .await + .is_err() + ); + assert!( + instance_plugin + .allocate(Request::new(AllocateRequest { + container_requests: vec![ContainerAllocateRequest { + devices_i_ds: vec!["instance-a-3".to_owned()], + }] + })) + .await + .is_ok() + ); } #[tokio::test] diff --git a/agent/src/plugin_manager/device_plugin_runner.rs b/agent/src/plugin_manager/device_plugin_runner.rs index f374447e8..38f5957fa 100644 --- a/agent/src/plugin_manager/device_plugin_runner.rs +++ b/agent/src/plugin_manager/device_plugin_runner.rs @@ -7,8 +7,8 @@ use thiserror::Error; use tokio::net::{UnixListener, UnixStream}; use tokio_stream::wrappers::WatchStream; use tonic::{ - transport::{Endpoint, Server, Uri}, Request, + transport::{Endpoint, Server, Uri}, }; use tower::service_fn; @@ -22,9 +22,10 @@ pub const DEVICE_PLUGIN_PATH: &str = "/var/lib/kubelet/device-plugins"; pub const KUBELET_SOCKET: &str = "/var/lib/kubelet/device-plugins/kubelet.sock"; use super::v1beta1::{ + AllocateRequest, AllocateResponse, DevicePluginOptions, Empty, ListAndWatchResponse, + RegisterRequest, device_plugin_server::{DevicePlugin, DevicePluginServer}, - registration_client, AllocateRequest, AllocateResponse, DevicePluginOptions, Empty, - ListAndWatchResponse, RegisterRequest, + registration_client, }; #[async_trait] diff --git a/agent/src/plugin_manager/v1.rs b/agent/src/plugin_manager/v1.rs index f4cfc2df8..c93bf05dc 100644 --- a/agent/src/plugin_manager/v1.rs +++ b/agent/src/plugin_manager/v1.rs @@ -129,11 +129,11 @@ pub mod pod_resources_lister_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, >>::Error: Into + Send + Sync, { diff --git a/agent/src/plugin_manager/v1beta1.rs b/agent/src/plugin_manager/v1beta1.rs index 083007abe..e728044e6 100644 --- a/agent/src/plugin_manager/v1beta1.rs +++ b/agent/src/plugin_manager/v1beta1.rs @@ -256,11 +256,11 @@ pub mod registration_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, >>::Error: Into + Send + Sync, { @@ -360,11 +360,11 @@ pub mod device_plugin_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, >>::Error: Into + Send + Sync, { diff --git a/agent/src/util/discovery_configuration_controller.rs b/agent/src/util/discovery_configuration_controller.rs index 780fdb80b..1232a1c99 100644 --- a/agent/src/util/discovery_configuration_controller.rs +++ b/agent/src/util/discovery_configuration_controller.rs @@ -15,15 +15,15 @@ use futures::StreamExt; use tokio::sync::mpsc; use crate::discovery_handler_manager::{ - discovery_handler_registry::DiscoveryHandlerRegistry, DiscoveryError, + DiscoveryError, discovery_handler_registry::DiscoveryHandlerRegistry, }; use kube::api::ObjectMeta; use kube::{Resource, ResourceExt}; use kube_runtime::{ + Controller, controller::Action, reflector::{ObjectRef, Store}, - Controller, }; use thiserror::Error; diff --git a/agent/src/util/metrics.rs b/agent/src/util/metrics.rs index 4f43a22d9..a112da562 100644 --- a/agent/src/util/metrics.rs +++ b/agent/src/util/metrics.rs @@ -1,5 +1,5 @@ use lazy_static::lazy_static; -use prometheus::{opts, register_int_counter_vec, HistogramVec, IntCounterVec, IntGaugeVec}; +use prometheus::{HistogramVec, IntCounterVec, IntGaugeVec, opts, register_int_counter_vec}; // Discovery request response time bucket (in seconds) const DISCOVERY_RESPONSE_TIME_BUCKETS: &[f64; 9] = diff --git a/controller/src/main.rs b/controller/src/main.rs index 82d6d0c35..a10dcfa4d 100644 --- a/controller/src/main.rs +++ b/controller/src/main.rs @@ -2,7 +2,7 @@ extern crate lazy_static; mod util; -use akri_shared::akri::{metrics::run_metrics_server, API_NAMESPACE}; +use akri_shared::akri::{API_NAMESPACE, metrics::run_metrics_server}; use async_std::sync::Mutex; use prometheus::IntGaugeVec; use std::sync::Arc; diff --git a/controller/src/util/instance_action.rs b/controller/src/util/instance_action.rs index 32ed134a8..087675035 100644 --- a/controller/src/util/instance_action.rs +++ b/controller/src/util/instance_action.rs @@ -1,11 +1,10 @@ use super::super::BROKER_POD_COUNT_METRIC; use super::{pod_action::PodAction, pod_action::PodActionInfo}; use akri_shared::{ - akri::{configuration::BrokerSpec, instance::Instance, AKRI_PREFIX}, + akri::{AKRI_PREFIX, configuration::BrokerSpec, instance::Instance}, k8s::{ - self, job, pod, + self, KubeInterface, OwnershipInfo, OwnershipType, job, pod, pod::{AKRI_INSTANCE_LABEL_NAME, AKRI_TARGET_NODE_LABEL_NAME}, - KubeInterface, OwnershipInfo, OwnershipType, }, }; use async_std::sync::Mutex; @@ -13,8 +12,8 @@ use futures::{StreamExt, TryStreamExt}; use k8s_openapi::api::batch::v1::JobSpec; use k8s_openapi::api::core::v1::{Pod, PodSpec}; use kube::api::Api; -use kube::runtime::watcher::{watcher, Config, Event}; use kube::runtime::WatchStreamExt; +use kube::runtime::watcher::{Config, Event, watcher}; use log::{error, info, trace}; use std::collections::HashMap; use std::sync::Arc; @@ -54,8 +53,8 @@ pub enum InstanceAction { } /// This invokes an internal method that watches for Instance events -pub async fn handle_existing_instances( -) -> Result<(), Box> { +pub async fn handle_existing_instances() +-> Result<(), Box> { internal_handle_existing_instances(&k8s::KubeImpl::new().await?).await } @@ -262,10 +261,7 @@ async fn handle_deletion_work( trace!( "handle_deletion_work - pod::create_broker_app_name({:?}, {:?}, {:?}, {:?})", - &instance_name, - context_node_name, - instance_shared, - "pod" + &instance_name, context_node_name, instance_shared, "pod" ); let pod_app_name = pod::create_broker_app_name( instance_name, @@ -275,8 +271,7 @@ async fn handle_deletion_work( ); trace!( "handle_deletion_work - pod::remove_pod name={:?}, namespace={:?}", - &pod_app_name, - &context_namespace + &pod_app_name, &context_namespace ); kube_interface .remove_pod(&pod_app_name, context_namespace) @@ -303,16 +298,18 @@ mod handle_deletion_work_tests { action: PodAction::NoAction, }; - assert!(handle_deletion_work( - "instance_name", - "configuration_name", - true, - "node_to_delete_pod", - &context, - &MockKubeInterface::new(), - ) - .await - .is_err()); + assert!( + handle_deletion_work( + "instance_name", + "configuration_name", + true, + "node_to_delete_pod", + &context, + &MockKubeInterface::new(), + ) + .await + .is_err() + ); } #[tokio::test] @@ -325,16 +322,18 @@ mod handle_deletion_work_tests { action: PodAction::NoAction, }; - assert!(handle_deletion_work( - "instance_name", - "configuration_name", - true, - "node_to_delete_pod", - &context, - &MockKubeInterface::new(), - ) - .await - .is_err()); + assert!( + handle_deletion_work( + "instance_name", + "configuration_name", + true, + "node_to_delete_pod", + &context, + &MockKubeInterface::new(), + ) + .await + .is_err() + ); } } @@ -411,9 +410,9 @@ pub async fn handle_instance_change( // Furthermore, Akri Agent is still modifying the Instances. This should not happen because 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 - ); + "handle_instance_change - no configuration found for {:?} yet instance {:?} exists - check that device plugin is running properly", + &instance.spec.configuration_name, &instance.metadata.name + ); } return Ok(()); } @@ -557,8 +556,7 @@ pub async fn handle_instance_change_pod( trace!( "handle_instance_change - find all pods that have {}={}", - AKRI_INSTANCE_LABEL_NAME, - instance_name + AKRI_INSTANCE_LABEL_NAME, instance_name ); let instance_pods = kube_interface .find_pods_with_label(&format!("{}={}", AKRI_INSTANCE_LABEL_NAME, instance_name)) @@ -645,11 +643,11 @@ mod handle_instance_tests { use super::*; use akri_shared::{ akri::instance::Instance, - k8s::{pod::AKRI_INSTANCE_LABEL_NAME, MockKubeInterface}, + k8s::{MockKubeInterface, pod::AKRI_INSTANCE_LABEL_NAME}, os::file, }; - use chrono::prelude::*; use chrono::Utc; + use chrono::prelude::*; use mockall::predicate::*; fn configure_find_pods_with_phase( @@ -909,21 +907,25 @@ mod handle_instance_tests { async fn test_handle_watcher_restart() { let _ = env_logger::builder().is_test(true).try_init(); let mut first_event = true; - assert!(handle_instance( - Event::Restarted(Vec::new()), - &MockKubeInterface::new(), - &mut first_event - ) - .await - .is_ok()); + assert!( + handle_instance( + Event::Restarted(Vec::new()), + &MockKubeInterface::new(), + &mut first_event + ) + .await + .is_ok() + ); first_event = false; - assert!(handle_instance( - Event::Restarted(Vec::new()), - &MockKubeInterface::new(), - &mut first_event - ) - .await - .is_err()); + assert!( + handle_instance( + Event::Restarted(Vec::new()), + &MockKubeInterface::new(), + &mut first_event + ) + .await + .is_err() + ); } #[tokio::test] diff --git a/controller/src/util/node_watcher.rs b/controller/src/util/node_watcher.rs index 47435d924..0da9135f5 100644 --- a/controller/src/util/node_watcher.rs +++ b/controller/src/util/node_watcher.rs @@ -2,7 +2,7 @@ use akri_shared::{ akri::{ instance::device_usage::NodeUsage, instance::{Instance, InstanceSpec}, - retry::{random_delay, MAX_INSTANCE_UPDATE_TRIES}, + retry::{MAX_INSTANCE_UPDATE_TRIES, random_delay}, }, k8s, k8s::KubeInterface, @@ -10,8 +10,8 @@ use akri_shared::{ use futures::{StreamExt, TryStreamExt}; use k8s_openapi::api::core::v1::{Node, NodeStatus}; use kube::api::Api; -use kube::runtime::watcher::{watcher, Config, Event}; use kube::runtime::WatchStreamExt; +use kube::runtime::watcher::{Config, Event, watcher}; use log::{error, info, trace}; use std::collections::HashMap; use std::str::FromStr; @@ -327,9 +327,7 @@ impl NodeWatcher { trace!( "handle_node_disappearance - kube_interface.update_instance name: {}, namespace: {}, {:?}", - &instance_name, - &instance_namespace, - &modified_instance + &instance_name, &instance_namespace, &modified_instance ); kube_interface @@ -385,23 +383,27 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let mut pod_watcher = NodeWatcher::new(); let mut first_event = true; - assert!(pod_watcher - .handle_node( - Event::Restarted(Vec::new()), - &MockKubeInterface::new(), - &mut first_event - ) - .await - .is_ok()); + assert!( + pod_watcher + .handle_node( + Event::Restarted(Vec::new()), + &MockKubeInterface::new(), + &mut first_event + ) + .await + .is_ok() + ); first_event = false; - assert!(pod_watcher - .handle_node( - Event::Restarted(Vec::new()), - &MockKubeInterface::new(), - &mut first_event - ) - .await - .is_err()); + assert!( + pod_watcher + .handle_node( + Event::Restarted(Vec::new()), + &MockKubeInterface::new(), + &mut first_event + ) + .await + .is_err() + ); } #[tokio::test] @@ -598,10 +600,12 @@ mod tests { }); let node_watcher = NodeWatcher::new(); - assert!(node_watcher - .handle_node_disappearance("foo-a", &mock) - .await - .is_err()); + assert!( + node_watcher + .handle_node_disappearance("foo-a", &mock) + .await + .is_err() + ); } #[tokio::test] @@ -636,16 +640,18 @@ mod tests { .returning(move |_, _, _| Ok(())); let node_watcher = NodeWatcher::new(); - assert!(node_watcher - .try_remove_nodes_from_instance( - "node-b", - "config-a", - "config-a-namespace", - &kube_object_instance, - &mock, - ) - .await - .is_ok()); + assert!( + node_watcher + .try_remove_nodes_from_instance( + "node-b", + "config-a", + "config-a-namespace", + &kube_object_instance, + &mock, + ) + .await + .is_ok() + ); } #[test] @@ -662,8 +668,7 @@ mod tests { for (node_file, result) in tests.iter() { trace!( "Testing {} should reflect node is ready={}", - node_file, - result + node_file, result ); let node_json = file::read_file_to_string(node_file); diff --git a/controller/src/util/pod_watcher.rs b/controller/src/util/pod_watcher.rs index af79f9907..90ed2a4b8 100644 --- a/controller/src/util/pod_watcher.rs +++ b/controller/src/util/pod_watcher.rs @@ -1,20 +1,21 @@ use akri_shared::{ akri::{ configuration::Configuration, - retry::{random_delay, MAX_INSTANCE_UPDATE_TRIES}, + retry::{MAX_INSTANCE_UPDATE_TRIES, random_delay}, }, k8s, k8s::{ + KubeInterface, OwnershipInfo, OwnershipType, pod::{AKRI_CONFIGURATION_LABEL_NAME, AKRI_INSTANCE_LABEL_NAME}, - service, KubeInterface, OwnershipInfo, OwnershipType, + service, }, }; use async_std::sync::Mutex; use futures::{StreamExt, TryStreamExt}; use k8s_openapi::api::core::v1::{Pod, ServiceSpec}; use kube::api::Api; -use kube::runtime::watcher::{watcher, Config, Event}; use kube::runtime::WatchStreamExt; +use kube::runtime::watcher::{Config, Event, watcher}; use log::{error, info, trace}; use std::{collections::HashMap, sync::Arc}; @@ -542,8 +543,7 @@ impl BrokerPodWatcher { ) -> anyhow::Result<()> { trace!( "create_or_update_service - instance={:?} with ownership:{:?}", - instance_name, - &ownership + instance_name, &ownership ); let mut create_new_service = true; @@ -562,7 +562,10 @@ impl BrokerPodWatcher { &svc_name ); service::update_ownership(&mut existing_svc, ownership.clone(), true)?; - trace!("create_or_update_service - calling service::update_service name:{} namespace: {}", &svc_name, &svc_namespace); + trace!( + "create_or_update_service - calling service::update_service name:{} namespace: {}", + &svc_name, &svc_namespace + ); kube_interface .update_service(&existing_svc, &svc_name, &svc_namespace) .await?; @@ -789,23 +792,27 @@ mod tests { let _ = env_logger::builder().is_test(true).try_init(); let mut pod_watcher = BrokerPodWatcher::new(); let mut first_event = true; - assert!(pod_watcher - .handle_pod( - Event::Restarted(Vec::new()), - &MockKubeInterface::new(), - &mut first_event - ) - .await - .is_ok()); + assert!( + pod_watcher + .handle_pod( + Event::Restarted(Vec::new()), + &MockKubeInterface::new(), + &mut first_event + ) + .await + .is_ok() + ); first_event = false; - assert!(pod_watcher - .handle_pod( - Event::Restarted(Vec::new()), - &MockKubeInterface::new(), - &mut first_event - ) - .await - .is_err()); + assert!( + pod_watcher + .handle_pod( + Event::Restarted(Vec::new()), + &MockKubeInterface::new(), + &mut first_event + ) + .await + .is_err() + ); } #[tokio::test] @@ -1348,9 +1355,11 @@ mod tests { let orig_pod = pod_list.items.first().unwrap(); let pod_watcher = BrokerPodWatcher::new(); - assert!(pod_watcher - .get_instance_and_configuration_from_pod(orig_pod) - .is_ok()); + assert!( + pod_watcher + .get_instance_and_configuration_from_pod(orig_pod) + .is_ok() + ); let mut instanceless_pod = orig_pod.clone(); instanceless_pod @@ -1359,9 +1368,11 @@ mod tests { .as_mut() .unwrap() .remove(AKRI_INSTANCE_LABEL_NAME); - assert!(pod_watcher - .get_instance_and_configuration_from_pod(&instanceless_pod) - .is_err()); + assert!( + pod_watcher + .get_instance_and_configuration_from_pod(&instanceless_pod) + .is_err() + ); let mut configurationless_pod = orig_pod.clone(); configurationless_pod @@ -1370,9 +1381,11 @@ mod tests { .as_mut() .unwrap() .remove(AKRI_CONFIGURATION_LABEL_NAME); - assert!(pod_watcher - .get_instance_and_configuration_from_pod(&configurationless_pod) - .is_err()); + assert!( + pod_watcher + .get_instance_and_configuration_from_pod(&configurationless_pod) + .is_err() + ); } #[tokio::test] @@ -1444,20 +1457,22 @@ mod tests { "object_uid".to_string(), ); - assert!(pod_watcher - .create_or_update_service( - "config-a-b494b6", - "config-a", - "config-a-namespace", - AKRI_INSTANCE_LABEL_NAME, - "config-a-b494b6", - ownership, - &config.spec.instance_service_spec.unwrap().clone(), - true, - &mock - ) - .await - .is_err()); + assert!( + pod_watcher + .create_or_update_service( + "config-a-b494b6", + "config-a", + "config-a-namespace", + AKRI_INSTANCE_LABEL_NAME, + "config-a-b494b6", + ownership, + &config.spec.instance_service_spec.unwrap().clone(), + true, + &mock + ) + .await + .is_err() + ); } #[tokio::test] @@ -1528,20 +1543,22 @@ mod tests { "object_uid".to_string(), ); - assert!(pod_watcher - .create_or_update_service( - "config-a-b494b6", - "config-a", - "config-a-namespace", - AKRI_INSTANCE_LABEL_NAME, - "config-a-b494b6", - ownership, - &config.spec.instance_service_spec.unwrap().clone(), - true, - &mock - ) - .await - .is_err()); + assert!( + pod_watcher + .create_or_update_service( + "config-a-b494b6", + "config-a", + "config-a-namespace", + AKRI_INSTANCE_LABEL_NAME, + "config-a-b494b6", + ownership, + &config.spec.instance_service_spec.unwrap().clone(), + true, + &mock + ) + .await + .is_err() + ); } #[derive(Clone)] diff --git a/controller/src/util/shared_test_utils.rs b/controller/src/util/shared_test_utils.rs index 09ac39735..a3c926f40 100644 --- a/controller/src/util/shared_test_utils.rs +++ b/controller/src/util/shared_test_utils.rs @@ -88,9 +88,7 @@ pub mod config_for_tests { ) { trace!( "mock.expect_update_instance name:{} namespace:{} error:{}", - instance_name, - instance_namespace, - result_error + instance_name, instance_namespace, result_error ); mock.expect_update_instance() .times(1) @@ -160,10 +158,7 @@ pub mod config_for_tests { ) { trace!( "mock.expect_create_service name:{}, namespace:{}, [{}={}]", - &svc_name, - &namespace, - &label_id, - &label_value + &svc_name, &namespace, &label_id, &label_value ); mock.expect_create_service() .withf(move |svc_to_create, ns| { @@ -188,8 +183,7 @@ pub mod config_for_tests { ) { trace!( "mock.expect_remove_service svc_name:{}, svc_namespace={}", - svc_name, - svc_namespace + svc_name, svc_namespace ); mock.expect_remove_service() .times(1) @@ -207,9 +201,7 @@ pub mod config_for_tests { ) { trace!( "mock.expect_update_service name:{} namespace:{} error:{}", - svc_name, - svc_namespace, - result_error, + svc_name, svc_namespace, result_error, ); mock.expect_update_service() .times(1) @@ -283,8 +275,7 @@ pub mod config_for_tests { ) { trace!( "mock.expect_remove_pod pod_name:{} pod_namespace:{}", - pod_name, - pod_namespace + pod_name, pod_namespace ); mock.expect_remove_pod() .times(1) diff --git a/discovery-handler-modules/debug-echo-discovery-handler/src/main.rs b/discovery-handler-modules/debug-echo-discovery-handler/src/main.rs index 1a58ef943..b4ecc40c6 100644 --- a/discovery-handler-modules/debug-echo-discovery-handler/src/main.rs +++ b/discovery-handler-modules/debug-echo-discovery-handler/src/main.rs @@ -1,9 +1,9 @@ use akri_debug_echo::{ - discovery_handler::DiscoveryHandlerImpl, DEBUG_ECHO_INSTANCES_SHARED_LABEL, - DISCOVERY_HANDLER_NAME, + DEBUG_ECHO_INSTANCES_SHARED_LABEL, DISCOVERY_HANDLER_NAME, + discovery_handler::DiscoveryHandlerImpl, }; use akri_discovery_utils::discovery::discovery_handler::{ - run_discovery_handler, REGISTER_AGAIN_CHANNEL_CAPACITY, + REGISTER_AGAIN_CHANNEL_CAPACITY, run_discovery_handler, }; use log::info; #[tokio::main] diff --git a/discovery-handler-modules/onvif-discovery-handler/src/main.rs b/discovery-handler-modules/onvif-discovery-handler/src/main.rs index 2def2feba..475588fbf 100644 --- a/discovery-handler-modules/onvif-discovery-handler/src/main.rs +++ b/discovery-handler-modules/onvif-discovery-handler/src/main.rs @@ -1,7 +1,7 @@ use akri_discovery_utils::discovery::discovery_handler::{ - run_discovery_handler, REGISTER_AGAIN_CHANNEL_CAPACITY, + REGISTER_AGAIN_CHANNEL_CAPACITY, run_discovery_handler, }; -use akri_onvif::{discovery_handler::DiscoveryHandlerImpl, DISCOVERY_HANDLER_NAME, SHARED}; +use akri_onvif::{DISCOVERY_HANDLER_NAME, SHARED, discovery_handler::DiscoveryHandlerImpl}; use log::info; #[tokio::main] async fn main() -> Result<(), Box> { diff --git a/discovery-handler-modules/opcua-discovery-handler/src/main.rs b/discovery-handler-modules/opcua-discovery-handler/src/main.rs index 25360df6f..110515610 100644 --- a/discovery-handler-modules/opcua-discovery-handler/src/main.rs +++ b/discovery-handler-modules/opcua-discovery-handler/src/main.rs @@ -1,7 +1,7 @@ use akri_discovery_utils::discovery::discovery_handler::{ - run_discovery_handler, REGISTER_AGAIN_CHANNEL_CAPACITY, + REGISTER_AGAIN_CHANNEL_CAPACITY, run_discovery_handler, }; -use akri_opcua::{discovery_handler::DiscoveryHandlerImpl, DISCOVERY_HANDLER_NAME, SHARED}; +use akri_opcua::{DISCOVERY_HANDLER_NAME, SHARED, discovery_handler::DiscoveryHandlerImpl}; use log::info; #[tokio::main] async fn main() -> Result<(), Box> { diff --git a/discovery-handler-modules/udev-discovery-handler/src/main.rs b/discovery-handler-modules/udev-discovery-handler/src/main.rs index ccd4b9a76..51600cfd0 100644 --- a/discovery-handler-modules/udev-discovery-handler/src/main.rs +++ b/discovery-handler-modules/udev-discovery-handler/src/main.rs @@ -1,7 +1,7 @@ use akri_discovery_utils::discovery::discovery_handler::{ - run_discovery_handler, REGISTER_AGAIN_CHANNEL_CAPACITY, + REGISTER_AGAIN_CHANNEL_CAPACITY, run_discovery_handler, }; -use akri_udev::{discovery_handler::DiscoveryHandlerImpl, DISCOVERY_HANDLER_NAME, SHARED}; +use akri_udev::{DISCOVERY_HANDLER_NAME, SHARED, discovery_handler::DiscoveryHandlerImpl}; use log::info; #[tokio::main] async fn main() -> Result<(), Box> { diff --git a/discovery-handlers/debug-echo/src/discovery_handler.rs b/discovery-handlers/debug-echo/src/discovery_handler.rs index 4e016054b..5389bc0b0 100644 --- a/discovery-handlers/debug-echo/src/discovery_handler.rs +++ b/discovery-handlers/debug-echo/src/discovery_handler.rs @@ -1,7 +1,7 @@ use akri_discovery_utils::discovery::{ - discovery_handler::{deserialize_discovery_details, DISCOVERED_DEVICES_CHANNEL_CAPACITY}, - v0::{discovery_handler_server::DiscoveryHandler, Device, DiscoverRequest, DiscoverResponse}, DiscoverStream, + discovery_handler::{DISCOVERED_DEVICES_CHANNEL_CAPACITY, deserialize_discovery_details}, + v0::{Device, DiscoverRequest, DiscoverResponse, discovery_handler_server::DiscoveryHandler}, }; use async_trait::async_trait; use log::{error, info, trace}; @@ -94,7 +94,10 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { })) .await { - error!("discover - for debugEcho failed to send discovery response with error {}", e); + error!( + "discover - for debugEcho failed to send discovery response with error {}", + e + ); if let Some(sender) = register_sender { sender.send(()).await.unwrap(); } @@ -126,7 +129,10 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { .await { // TODO: consider re-registering here - error!("discover - for debugEcho failed to send discovery response with error {}", e); + error!( + "discover - for debugEcho failed to send discovery response with error {}", + e + ); if let Some(sender) = register_sender { sender.send(()).await.unwrap(); } diff --git a/discovery-handlers/onvif/src/discovery_handler.rs b/discovery-handlers/onvif/src/discovery_handler.rs index 468422c9b..fb14a7726 100644 --- a/discovery-handlers/onvif/src/discovery_handler.rs +++ b/discovery-handlers/onvif/src/discovery_handler.rs @@ -1,17 +1,16 @@ use super::credential_store::CredentialStore; use super::discovery_impl::util; use super::discovery_utils::{ - OnvifQuery, OnvifQueryImpl, ONVIF_DEVICE_IP_ADDRESS_LABEL_ID, - ONVIF_DEVICE_MAC_ADDRESS_LABEL_ID, ONVIF_DEVICE_SERVICE_URL_LABEL_ID, - ONVIF_DEVICE_UUID_LABEL_ID, + ONVIF_DEVICE_IP_ADDRESS_LABEL_ID, ONVIF_DEVICE_MAC_ADDRESS_LABEL_ID, + ONVIF_DEVICE_SERVICE_URL_LABEL_ID, ONVIF_DEVICE_UUID_LABEL_ID, OnvifQuery, OnvifQueryImpl, }; use akri_discovery_utils::{ discovery::{ - discovery_handler::{deserialize_discovery_details, DISCOVERED_DEVICES_CHANNEL_CAPACITY}, + DiscoverStream, + discovery_handler::{DISCOVERED_DEVICES_CHANNEL_CAPACITY, deserialize_discovery_details}, v0::{ - discovery_handler_server::DiscoveryHandler, Device, DiscoverRequest, DiscoverResponse, + Device, DiscoverRequest, DiscoverResponse, discovery_handler_server::DiscoveryHandler, }, - DiscoverStream, }, filtering::FilterList, }; @@ -383,9 +382,11 @@ mod tests { uuids: None, discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -447,9 +448,11 @@ mod tests { uuids: None, discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -476,9 +479,11 @@ mod tests { uuids: None, discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -540,9 +545,11 @@ mod tests { uuids: None, discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -604,9 +611,11 @@ mod tests { uuids: None, discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -668,9 +677,11 @@ mod tests { uuids: None, discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -732,9 +743,11 @@ mod tests { uuids: None, discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -797,9 +810,11 @@ mod tests { uuids: None, discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -854,9 +869,11 @@ mod tests { }), discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -877,9 +894,11 @@ mod tests { }), discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -900,9 +919,11 @@ mod tests { }), discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } #[tokio::test] @@ -1025,8 +1046,10 @@ mod tests { }), discovery_timeout_seconds: 1, }; - assert!(apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) - .await - .is_none()); + assert!( + apply_filters(&onvif_config, mock_uri, mock_uuid, &mock) + .await + .is_none() + ); } } diff --git a/discovery-handlers/onvif/src/discovery_impl.rs b/discovery-handlers/onvif/src/discovery_impl.rs index 3b6666cd2..098cb6f0b 100644 --- a/discovery-handlers/onvif/src/discovery_impl.rs +++ b/discovery-handlers/onvif/src/discovery_impl.rs @@ -179,8 +179,9 @@ pub mod util { /// Get SOAP probe message with a specific message id fn get_expected_probe_message(message_id: &str) -> String { format!( - "{}urn:schemas-xmlsoap-org:ws:2005:04:discoveryhttp://schemas.xmlsoap.org/ws/2005/04/discovery/Probenetwsdl:NetworkVideoTransmitter", - &message_id) + "{}urn:schemas-xmlsoap-org:ws:2005:04:discoveryhttp://schemas.xmlsoap.org/ws/2005/04/discovery/Probenetwsdl:NetworkVideoTransmitter", + &message_id + ) } #[test] @@ -428,11 +429,13 @@ pub mod util { let uris = vec!["uri_one".to_string(), "uri_two".to_string()]; let device_uuid = "device_uuid"; let response = get_expected_probe_match_message(device_uuid, &uris); - assert!(get_scope_filtered_uris_from_discovery_response( - &response, - Some(filter_list).as_ref() - ) - .is_empty()); + assert!( + get_scope_filtered_uris_from_discovery_response( + &response, + Some(filter_list).as_ref() + ) + .is_empty() + ); } #[test] @@ -446,11 +449,13 @@ pub mod util { let uris = vec!["uri_one".to_string(), "uri_two".to_string()]; let device_uuid = "device_uuid"; let response = get_expected_probe_match_message(device_uuid, &uris); - assert!(get_scope_filtered_uris_from_discovery_response( - &response, - Some(filter_list).as_ref() - ) - .is_empty()); + assert!( + get_scope_filtered_uris_from_discovery_response( + &response, + Some(filter_list).as_ref() + ) + .is_empty() + ); } #[test] @@ -488,11 +493,13 @@ pub mod util { let uris = vec!["uri_one".to_string(), "uri_two".to_string()]; let device_uuid = "device_uuid"; let response = get_expected_probe_match_message(device_uuid, &uris); - assert!(get_scope_filtered_uris_from_discovery_response( - &response, - Some(filter_list).as_ref() - ) - .is_empty()); + assert!( + get_scope_filtered_uris_from_discovery_response( + &response, + Some(filter_list).as_ref() + ) + .is_empty() + ); } #[test] @@ -698,8 +705,7 @@ pub mod util { let socket = UdpSocket::bind(local_socket_addr).await?; trace!( "get_discovery_response_socket - joining multicast: {:?} {:?}", - &MULTI_IPV4_ADDR, - &LOCAL_IPV4_ADDR + &MULTI_IPV4_ADDR, &LOCAL_IPV4_ADDR ); socket .join_multicast_v4(MULTI_IPV4_ADDR, LOCAL_IPV4_ADDR) @@ -734,7 +740,10 @@ pub mod util { } Err(e) => match e.kind() { ErrorKind::WouldBlock | ErrorKind::TimedOut => { - trace!("simple_onvif_discover - recv_from error ... continue collecting responses {:?}", e); + trace!( + "simple_onvif_discover - recv_from error ... continue collecting responses {:?}", + e + ); } _ => { error!("simple_onvif_discover - recv_from error: {:?}", e); diff --git a/discovery-handlers/onvif/src/discovery_utils.rs b/discovery-handlers/onvif/src/discovery_utils.rs index 513ac707a..31ed78474 100644 --- a/discovery-handlers/onvif/src/discovery_utils.rs +++ b/discovery-handlers/onvif/src/discovery_utils.rs @@ -7,7 +7,7 @@ use log::trace; #[cfg(test)] use mockall::{automock, predicate::*}; use std::io::{Error, ErrorKind}; -use sxd_document::{parser, Package}; +use sxd_document::{Package, parser}; use sxd_xpath::Value; pub const ONVIF_DEVICE_SERVICE_URL_LABEL_ID: &str = "ONVIF_DEVICE_SERVICE_URL"; @@ -110,7 +110,7 @@ impl OnvifQuery for OnvifQueryImpl { #[async_trait] trait Http { async fn post(&self, url: &str, mime_action: &str, msg: &str) - -> Result; + -> Result; } struct HttpRequest {} @@ -141,9 +141,7 @@ impl Http for HttpRequest { ) -> Result { trace!( "post - url:{}, mime_action:{}, msg:{}", - &url, - &mime_action, - &msg + &url, &mime_action, &msg ); let full_mime = format!( @@ -210,40 +208,69 @@ async fn inner_get_device_ip_and_mac_address( return Err(anyhow::format_err!( "failed to get network interfaces from device: {:?}", e - )) + )); } }; let network_interfaces_doc = network_interfaces_xml.as_document(); let ip_address = match sxd_xpath::evaluate_xpath( - &network_interfaces_doc, - "//*[local-name()='GetNetworkInterfacesResponse']/*[local-name()='NetworkInterfaces']/*[local-name()='IPv4']/*[local-name()='Config']/*/*[local-name()='Address']/text()" - ) { - Ok(Value::String(ip)) => ip, - Ok(Value::Nodeset(ns)) => match ns.into_iter().map(|x| x.string_value()).collect::>().first() { - Some(first) => first.to_string(), - None => return Err(anyhow::format_err!("Failed to get ONVIF ip address: none specified in response")) - }, - Ok(Value::Boolean(_)) | - Ok(Value::Number(_)) => return Err(anyhow::format_err!("Failed to get ONVIF ip address: unexpected type")), - Err(e) => return Err(anyhow::format_err!("Failed to get ONVIF ip address: {}", e)) - }; + &network_interfaces_doc, + "//*[local-name()='GetNetworkInterfacesResponse']/*[local-name()='NetworkInterfaces']/*[local-name()='IPv4']/*[local-name()='Config']/*/*[local-name()='Address']/text()", + ) { + Ok(Value::String(ip)) => ip, + Ok(Value::Nodeset(ns)) => match ns + .into_iter() + .map(|x| x.string_value()) + .collect::>() + .first() + { + Some(first) => first.to_string(), + None => { + return Err(anyhow::format_err!( + "Failed to get ONVIF ip address: none specified in response" + )); + } + }, + Ok(Value::Boolean(_)) | Ok(Value::Number(_)) => { + return Err(anyhow::format_err!( + "Failed to get ONVIF ip address: unexpected type" + )); + } + Err(e) => return Err(anyhow::format_err!("Failed to get ONVIF ip address: {}", e)), + }; trace!( "inner_get_device_ip_and_mac_address - network interfaces (ip address): {:?}", ip_address ); let mac_address = match sxd_xpath::evaluate_xpath( - &network_interfaces_doc, - "//*[local-name()='GetNetworkInterfacesResponse']/*[local-name()='NetworkInterfaces']/*[local-name()='Info']/*[local-name()='HwAddress']/text()" - ) { - Ok(Value::String(mac)) => mac, - Ok(Value::Nodeset(ns)) => match ns.iter().map(|x| x.string_value()).collect::>().first() { - Some(first) => first.to_string(), - None => return Err(anyhow::format_err!("Failed to get ONVIF mac address: none specified in response")) - }, - Ok(Value::Boolean(_)) | - Ok(Value::Number(_)) => return Err(anyhow::format_err!("Failed to get ONVIF mac address: unexpected type")), - Err(e) => return Err(anyhow::format_err!("Failed to get ONVIF mac address: {}", e)) - }; + &network_interfaces_doc, + "//*[local-name()='GetNetworkInterfacesResponse']/*[local-name()='NetworkInterfaces']/*[local-name()='Info']/*[local-name()='HwAddress']/text()", + ) { + Ok(Value::String(mac)) => mac, + Ok(Value::Nodeset(ns)) => match ns + .iter() + .map(|x| x.string_value()) + .collect::>() + .first() + { + Some(first) => first.to_string(), + None => { + return Err(anyhow::format_err!( + "Failed to get ONVIF mac address: none specified in response" + )); + } + }, + Ok(Value::Boolean(_)) | Ok(Value::Number(_)) => { + return Err(anyhow::format_err!( + "Failed to get ONVIF mac address: unexpected type" + )); + } + Err(e) => { + return Err(anyhow::format_err!( + "Failed to get ONVIF mac address: {}", + e + )); + } + }; trace!( "inner_get_device_ip_and_mac_address - network interfaces (mac address): {:?}", mac_address @@ -314,7 +341,7 @@ async fn inner_get_device_service_uri( return Err(anyhow::format_err!( "failed to get services from device: {:?}", e - )) + )); } }; let services_doc = services_xml.as_document(); @@ -329,13 +356,12 @@ async fn inner_get_device_service_uri( return Err(anyhow::format_err!( "failed to get servuce uri from resoinse: {:?}", e - )) + )); } }; trace!( "inner_get_device_service_uri - service ({}) uris: {:?}", - service, - requested_device_service_uri + service, requested_device_service_uri ); Ok(requested_device_service_uri) } @@ -361,7 +387,7 @@ async fn inner_get_device_profiles( return Err(anyhow::format_err!( "failed to get profiles from device: {:?}", e - )) + )); } }; let profiles_doc = profiles_xml.as_document(); @@ -377,7 +403,7 @@ async fn inner_get_device_profiles( Ok(Value::Boolean(_)) | Ok(Value::Number(_)) | Ok(Value::String(_)) => { return Err(anyhow::format_err!( "Failed to get ONVIF profiles: unexpected type" - )) + )); } Err(e) => return Err(anyhow::format_err!("Failed to get ONVIF profiles: {}", e)), }; @@ -401,22 +427,22 @@ async fn inner_get_device_profile_streaming_uri( return Err(anyhow::format_err!( "failed to get streaming uri from device: {:?}", e - )) + )); } }; let stream_uri_doc = stream_uri_xml.as_document(); let stream_uri = match sxd_xpath::evaluate_xpath( &stream_uri_doc, - "//*[local-name()='GetStreamUriResponse']/*[local-name()='MediaUri']/*[local-name()='Uri']/text()" - ) { - Ok(stream) => stream.string(), - Err(e) => { - return Err(anyhow::format_err!( - "failed to get service uri from response: {:?}", - e - )) - } - }; + "//*[local-name()='GetStreamUriResponse']/*[local-name()='MediaUri']/*[local-name()='Uri']/text()", + ) { + Ok(stream) => stream.string(), + Err(e) => { + return Err(anyhow::format_err!( + "failed to get service uri from response: {:?}", + e + )); + } + }; Ok(stream_uri) } @@ -648,7 +674,9 @@ mod tests { // empty response since do not check contents only successful response let empty_response = ""; let response = format!( - "\n{}", empty_response); + "\n{}", + empty_response + ); let url = "test_inner_is_device_responding-url".to_string(); configure_post( &mut mock, diff --git a/discovery-handlers/opcua/src/discovery_handler.rs b/discovery-handlers/opcua/src/discovery_handler.rs index c9b9ddd27..4e6f12aa9 100644 --- a/discovery-handlers/opcua/src/discovery_handler.rs +++ b/discovery-handlers/opcua/src/discovery_handler.rs @@ -1,11 +1,11 @@ -use super::{discovery_impl::do_standard_discovery, OPCUA_DISCOVERY_URL_LABEL}; +use super::{OPCUA_DISCOVERY_URL_LABEL, discovery_impl::do_standard_discovery}; use akri_discovery_utils::{ discovery::{ - discovery_handler::{deserialize_discovery_details, DISCOVERED_DEVICES_CHANNEL_CAPACITY}, + DiscoverStream, + discovery_handler::{DISCOVERED_DEVICES_CHANNEL_CAPACITY, deserialize_discovery_details}, v0::{ - discovery_handler_server::DiscoveryHandler, Device, DiscoverRequest, DiscoverResponse, + Device, DiscoverRequest, DiscoverResponse, discovery_handler_server::DiscoveryHandler, }, - DiscoverStream, }, filtering::FilterList, }; diff --git a/discovery-handlers/opcua/src/discovery_impl.rs b/discovery-handlers/opcua/src/discovery_impl.rs index 3cc52cc3c..f0af20d47 100644 --- a/discovery-handlers/opcua/src/discovery_impl.rs +++ b/discovery-handlers/opcua/src/discovery_impl.rs @@ -1,9 +1,9 @@ use super::wrappers::{ - opcua_client_wrapper::{create_opcua_discovery_client, OpcuaClient}, + opcua_client_wrapper::{OpcuaClient, create_opcua_discovery_client}, tcp_stream_wrapper::{TcpStream, TcpStreamImpl}, }; use ::url::Url; -use akri_discovery_utils::filtering::{should_include, FilterList}; +use akri_discovery_utils::filtering::{FilterList, should_include}; use anyhow::Context; use log::{error, info, trace}; use opcua::client::prelude::*; @@ -429,13 +429,15 @@ mod tests { fn test_get_server_endpoints_invalid_url() { let mut mock_client = MockOpcuaClient::new(); let mock_tcp_stream = MockTcpStream::new(); - assert!(get_discovery_urls( - &mut mock_client, - vec!["tcp://127.0.0.1:4855/".to_string()], - None, - mock_tcp_stream + assert!( + get_discovery_urls( + &mut mock_client, + vec!["tcp://127.0.0.1:4855/".to_string()], + None, + mock_tcp_stream + ) + .is_empty() ) - .is_empty()) } #[test] diff --git a/discovery-handlers/udev/src/discovery_handler.rs b/discovery-handlers/udev/src/discovery_handler.rs index 21e49bd8e..a5b24c542 100644 --- a/discovery-handlers/udev/src/discovery_handler.rs +++ b/discovery-handlers/udev/src/discovery_handler.rs @@ -1,18 +1,18 @@ use super::{ - discovery_impl::{do_parse_and_find, insert_device_with_relatives, DeviceProperties}, + discovery_impl::{DeviceProperties, do_parse_and_find, insert_device_with_relatives}, wrappers::udev_enumerator, }; use akri_discovery_utils::discovery::{ - discovery_handler::{deserialize_discovery_details, DISCOVERED_DEVICES_CHANNEL_CAPACITY}, + DiscoverStream, + discovery_handler::{DISCOVERED_DEVICES_CHANNEL_CAPACITY, deserialize_discovery_details}, v0::{ - discovery_handler_server::DiscoveryHandler, Device, DeviceSpec, DiscoverRequest, - DiscoverResponse, + Device, DeviceSpec, DiscoverRequest, DiscoverResponse, + discovery_handler_server::DiscoveryHandler, }, - DiscoverStream, }; use async_trait::async_trait; use log::{error, info, trace}; -use serde::{de, Deserialize, Deserializer}; +use serde::{Deserialize, Deserializer, de}; use std::collections::{HashMap, HashSet}; use std::time::Duration; use tokio::sync::mpsc; diff --git a/discovery-handlers/udev/src/discovery_impl.rs b/discovery-handlers/udev/src/discovery_impl.rs index e50d2f559..742b3650b 100644 --- a/discovery-handlers/udev/src/discovery_impl.rs +++ b/discovery-handlers/udev/src/discovery_impl.rs @@ -2,14 +2,14 @@ use std::collections::HashSet; use super::wrappers::{ udev_device::{ - get_attribute_value, get_devnode, get_devpath, get_driver, get_parent, get_property_value, - get_subsystem, get_sysname, DeviceExt, + DeviceExt, get_attribute_value, get_devnode, get_devpath, get_driver, get_parent, + get_property_value, get_subsystem, get_sysname, }, udev_enumerator::Enumerator, }; use log::{error, info, trace}; -use pest::iterators::Pair; use pest::Parser; +use pest::iterators::Pair; use regex::Regex; const TAGS: &str = "TAGS"; @@ -97,8 +97,12 @@ fn parse_udev_rule(udev_rule_string: &str) -> Result, anyhow::Er value: value.to_string(), }); } else { - return Err(anyhow::format_err!("parse_udev_rule - unsupported action operation for rule with field [{}], operation [{:?}], and value[{}]", - inner_field.into_inner().as_str(), operation_rule, value)); + return Err(anyhow::format_err!( + "parse_udev_rule - unsupported action operation for rule with field [{}], operation [{:?}], and value[{}]", + inner_field.into_inner().as_str(), + operation_rule, + value + )); } } Ok(udev_filters) @@ -524,7 +528,7 @@ fn get_device_relatives<'a>( for relative in possible_relatives { match relative { parent if device_path.starts_with(relative.as_str()) => { - return (Some(parent.clone()), vec![]) + return (Some(parent.clone()), vec![]); } child if relative.starts_with(device_path) => childrens.push(child.clone()), _ => (), @@ -555,13 +559,13 @@ pub fn insert_device_with_relatives( #[cfg(test)] mod discovery_tests { - use super::super::wrappers::udev_enumerator::{create_enumerator, MockEnumerator}; + use super::super::wrappers::udev_enumerator::{MockEnumerator, create_enumerator}; use super::*; use std::{ collections::HashMap, ffi::OsStr, fs::File, - io::{prelude::*, BufReader}, + io::{BufReader, prelude::*}, path::Path, }; #[derive(Clone)] diff --git a/discovery-utils/src/discovery/mod.rs b/discovery-utils/src/discovery/mod.rs index 062d1980a..69d880464 100644 --- a/discovery-utils/src/discovery/mod.rs +++ b/discovery-utils/src/discovery/mod.rs @@ -12,8 +12,8 @@ pub mod discovery_handler { use super::{ server::run_discovery_server, v0::{ - discovery_handler_server::DiscoveryHandler, - register_discovery_handler_request::EndpointType, RegisterDiscoveryHandlerRequest, + RegisterDiscoveryHandlerRequest, discovery_handler_server::DiscoveryHandler, + register_discovery_handler_request::EndpointType, }, }; use log::trace; @@ -97,7 +97,7 @@ pub mod discovery_handler { #[cfg(any(feature = "mock-discovery-handler", test))] pub mod mock_discovery_handler { use super::v0::{ - discovery_handler_server::DiscoveryHandler, Device, DiscoverRequest, DiscoverResponse, + Device, DiscoverRequest, DiscoverResponse, discovery_handler_server::DiscoveryHandler, }; use akri_shared::uds::unix_stream; use async_trait::async_trait; @@ -257,10 +257,10 @@ pub mod server { pub mod tests { use super::super::{ mock_discovery_handler::{ - get_mock_discovery_handler_dir_and_endpoint, run_mock_discovery_handler, - MockDiscoveryHandler, + MockDiscoveryHandler, get_mock_discovery_handler_dir_and_endpoint, + run_mock_discovery_handler, }, - v0::{discovery_handler_client::DiscoveryHandlerClient, DiscoverRequest}, + v0::{DiscoverRequest, discovery_handler_client::DiscoveryHandlerClient}, }; use super::*; use std::collections::HashMap; @@ -268,8 +268,8 @@ pub mod server { use tempfile::Builder; use tokio::net::UnixStream; use tonic::{ - transport::{Endpoint, Uri}, Request, + transport::{Endpoint, Uri}, }; #[tokio::test] diff --git a/discovery-utils/src/discovery/v0.rs b/discovery-utils/src/discovery/v0.rs index 08781a68e..e691f1458 100644 --- a/discovery-utils/src/discovery/v0.rs +++ b/discovery-utils/src/discovery/v0.rs @@ -175,11 +175,11 @@ pub mod registration_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, >>::Error: Into + Send + Sync, { @@ -281,11 +281,11 @@ pub mod discovery_handler_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, >>::Error: Into + Send + Sync, { diff --git a/discovery-utils/src/registration_client.rs b/discovery-utils/src/registration_client.rs index 32da1384a..d89d38fa3 100644 --- a/discovery-utils/src/registration_client.rs +++ b/discovery-utils/src/registration_client.rs @@ -1,11 +1,11 @@ use super::discovery::v0::{ - registration_client::RegistrationClient, RegisterDiscoveryHandlerRequest, + RegisterDiscoveryHandlerRequest, registration_client::RegistrationClient, }; use log::{info, trace}; use std::convert::TryFrom; use tonic::{ - transport::{Endpoint, Uri}, Request, + transport::{Endpoint, Uri}, }; pub async fn register_discovery_handler( diff --git a/samples/brokers/udev-video-broker/src/main.rs b/samples/brokers/udev-video-broker/src/main.rs index 9a8dcc3cc..6b9890940 100644 --- a/samples/brokers/udev-video-broker/src/main.rs +++ b/samples/brokers/udev-video-broker/src/main.rs @@ -2,7 +2,7 @@ mod util; #[macro_use] extern crate lazy_static; use akri_shared::{ - akri::{metrics::run_metrics_server, API_NAMESPACE}, + akri::{API_NAMESPACE, metrics::run_metrics_server}, os::env_var::{ActualEnvVarQuery, EnvVarQuery}, }; use log::{info, trace}; diff --git a/samples/brokers/udev-video-broker/src/util/camera.rs b/samples/brokers/udev-video-broker/src/util/camera.rs index 437b09cd8..a1ee7fe5d 100644 --- a/samples/brokers/udev-video-broker/src/util/camera.rs +++ b/samples/brokers/udev-video-broker/src/util/camera.rs @@ -53,11 +53,11 @@ pub mod camera_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, >>::Error: Into + Send + Sync, { diff --git a/samples/brokers/udev-video-broker/src/util/camera_capturer.rs b/samples/brokers/udev-video-broker/src/util/camera_capturer.rs index c9e66871e..75f7defd0 100644 --- a/samples/brokers/udev-video-broker/src/util/camera_capturer.rs +++ b/samples/brokers/udev-video-broker/src/util/camera_capturer.rs @@ -75,8 +75,7 @@ fn get_format(env_var_query: &impl EnvVarQuery, format_options: Vec) -> if !format_options.contains(&DEFAULT_FORMAT.to_string()) { trace!( "get_format - camera does not support {:?} format, using {:?} format", - DEFAULT_FORMAT, - format_options[0] + DEFAULT_FORMAT, format_options[0] ); format_options[0].clone() } else { @@ -106,8 +105,7 @@ fn get_interval(env_var_query: &impl EnvVarQuery, interval_info: rscam::Interval if !interval_options.contains(&interval_to_validate) { trace!( "get_interval - camera does not support {:?} interval, using {:?} interval", - interval_to_validate, - interval_options[0] + interval_to_validate, interval_options[0] ); interval_options[0] } else { @@ -156,8 +154,7 @@ fn get_resolution( if !resolution_options.contains(&resolution_to_validate) { trace!( "get_resolution - camera does not support {:?} resolution, using {:?} resolution", - resolution_to_validate, - resolution_options[0] + resolution_to_validate, resolution_options[0] ); resolution_options[0] } else { diff --git a/samples/brokers/udev-video-broker/src/util/camera_service.rs b/samples/brokers/udev-video-broker/src/util/camera_service.rs index b5ddc3c7d..cd905377c 100644 --- a/samples/brokers/udev-video-broker/src/util/camera_service.rs +++ b/samples/brokers/udev-video-broker/src/util/camera_service.rs @@ -1,8 +1,8 @@ use super::super::FRAME_COUNT_METRIC; use super::camera::{ + NotifyRequest, NotifyResponse, camera_client::CameraClient, camera_server::{Camera, CameraServer}, - NotifyRequest, NotifyResponse, }; use log::{info, trace}; use rscam::Camera as RsCamera; diff --git a/shared/src/akri/instance.rs b/shared/src/akri/instance.rs index 255f7edd6..01a3ec982 100644 --- a/shared/src/akri/instance.rs +++ b/shared/src/akri/instance.rs @@ -1,7 +1,7 @@ use super::{API_NAMESPACE, API_VERSION}; use kube::{ - api::{Api, DeleteParams, ListParams, ObjectList, ObjectMeta, Patch, PatchParams, PostParams}, Client, CustomResource, + api::{Api, DeleteParams, ListParams, ObjectList, ObjectMeta, Patch, PatchParams, PostParams}, }; use k8s_openapi::apimachinery::pkg::apis::meta::v1::OwnerReference; diff --git a/shared/src/k8s/api.rs b/shared/src/k8s/api.rs index 88ec79a0f..b5cb51f7d 100644 --- a/shared/src/k8s/api.rs +++ b/shared/src/k8s/api.rs @@ -3,9 +3,9 @@ use std::fmt::Debug; use async_trait::async_trait; use either::Either; use kube::{ + Error, Resource, ResourceExt, api::{Patch, PatchParams}, core::{ObjectList, ObjectMeta, PartialObjectMetaExt, Status}, - Error, Resource, ResourceExt, }; use mockall::automock; use serde::de::DeserializeOwned; diff --git a/shared/src/k8s/job.rs b/shared/src/k8s/job.rs index bcf5c238a..7f5d0a136 100644 --- a/shared/src/k8s/job.rs +++ b/shared/src/k8s/job.rs @@ -1,10 +1,10 @@ -use super::super::akri::{instance::Instance, API_NAMESPACE}; +use super::super::akri::{API_NAMESPACE, instance::Instance}; use super::{ + ERROR_CONFLICT, ERROR_NOT_FOUND, OwnershipInfo, pod::modify_pod_spec, pod::{ AKRI_CONFIGURATION_LABEL_NAME, AKRI_INSTANCE_LABEL_NAME, APP_LABEL_ID, CONTROLLER_LABEL_ID, }, - OwnershipInfo, ERROR_CONFLICT, ERROR_NOT_FOUND, }; use either::Either; use k8s_openapi::api::batch::v1::{Job, JobSpec}; @@ -56,8 +56,7 @@ pub async fn find_jobs_with_selector( ) -> Result, anyhow::Error> { trace!( "find_jobs_with_selector with label_selector={:?} field_selector={:?}", - &label_selector, - &field_selector + &label_selector, &field_selector ); let jobs: Api = Api::all(kube_client); let job_list_params = ListParams { @@ -489,23 +488,25 @@ mod broker_jobspec_tests { .unwrap() .api_version ); - assert!(job - .metadata - .owner_references - .as_ref() - .unwrap() - .first() - .unwrap() - .controller - .unwrap()); - assert!(job - .metadata - .owner_references - .as_ref() - .unwrap() - .first() - .unwrap() - .block_owner_deletion - .unwrap()); + assert!( + job.metadata + .owner_references + .as_ref() + .unwrap() + .first() + .unwrap() + .controller + .unwrap() + ); + assert!( + job.metadata + .owner_references + .as_ref() + .unwrap() + .first() + .unwrap() + .block_owner_deletion + .unwrap() + ); } } diff --git a/shared/src/k8s/mod.rs b/shared/src/k8s/mod.rs index 9f607be3d..bca384aa4 100644 --- a/shared/src/k8s/mod.rs +++ b/shared/src/k8s/mod.rs @@ -1,10 +1,9 @@ use super::akri::{ - configuration, + API_NAMESPACE, API_VERSION, configuration, configuration::{Configuration, ConfigurationList}, instance, instance::{Instance, InstanceList, InstanceSpec}, - retry::{random_delay, MAX_INSTANCE_UPDATE_TRIES}, - API_NAMESPACE, API_VERSION, + retry::{MAX_INSTANCE_UPDATE_TRIES, random_delay}, }; use async_trait::async_trait; use k8s_openapi::api::batch::v1::Job; @@ -628,7 +627,8 @@ pub async fn try_delete_instance( } log::error!( "try_delete_instance - tried to delete Instance {} but still exists. {} retries left.", - instance_name, MAX_INSTANCE_UPDATE_TRIES - x - 1 + instance_name, + MAX_INSTANCE_UPDATE_TRIES - x - 1 ); if x == MAX_INSTANCE_UPDATE_TRIES - 1 { return Err(e); diff --git a/shared/src/k8s/pod.rs b/shared/src/k8s/pod.rs index a5b109dfc..0cd8865a5 100644 --- a/shared/src/k8s/pod.rs +++ b/shared/src/k8s/pod.rs @@ -1,6 +1,6 @@ use super::{ - super::akri::API_NAMESPACE, OwnershipInfo, ERROR_CONFLICT, ERROR_NOT_FOUND, - NODE_SELECTOR_OP_IN, OBJECT_NAME_FIELD, RESOURCE_REQUIREMENTS_KEY, + super::akri::API_NAMESPACE, ERROR_CONFLICT, ERROR_NOT_FOUND, NODE_SELECTOR_OP_IN, + OBJECT_NAME_FIELD, OwnershipInfo, RESOURCE_REQUIREMENTS_KEY, }; use either::Either; use k8s_openapi::api::core::v1::{ @@ -62,8 +62,7 @@ pub async fn find_pods_with_selector( ) -> Result, anyhow::Error> { trace!( "find_pods_with_selector with label_selector={:?} field_selector={:?}", - &label_selector, - &field_selector + &label_selector, &field_selector ); let pods: Api = Api::all(kube_client); let pod_list_params = ListParams { @@ -694,24 +693,26 @@ mod broker_podspec_tests { .unwrap() .api_version ); - assert!(pod - .metadata - .clone() - .owner_references - .unwrap() - .first() - .unwrap() - .controller - .unwrap()); - assert!(pod - .metadata - .clone() - .owner_references - .unwrap() - .first() - .unwrap() - .block_owner_deletion - .unwrap()); + assert!( + pod.metadata + .clone() + .owner_references + .unwrap() + .first() + .unwrap() + .controller + .unwrap() + ); + assert!( + pod.metadata + .clone() + .owner_references + .unwrap() + .first() + .unwrap() + .block_owner_deletion + .unwrap() + ); // Validate existing and new affinity exist assert_eq!( diff --git a/shared/src/k8s/service.rs b/shared/src/k8s/service.rs index 90f9849a2..c10b23907 100644 --- a/shared/src/k8s/service.rs +++ b/shared/src/k8s/service.rs @@ -1,9 +1,9 @@ use super::{ super::akri::API_NAMESPACE, + ERROR_NOT_FOUND, OwnershipInfo, pod::{ AKRI_CONFIGURATION_LABEL_NAME, AKRI_INSTANCE_LABEL_NAME, APP_LABEL_ID, CONTROLLER_LABEL_ID, }, - OwnershipInfo, ERROR_NOT_FOUND, }; use either::Either; use k8s_openapi::api::core::v1::{Service, ServiceSpec}; @@ -385,8 +385,7 @@ pub async fn update_service( ) -> Result<(), anyhow::Error> { trace!( "update_service enter name:{} namespace: {}", - &name, - &namespace + &name, &namespace ); let svcs: Api = Api::namespaced(kube_client, namespace); @@ -716,24 +715,26 @@ mod svcspec_tests { .unwrap() .api_version ); - assert!(svc - .metadata - .clone() - .owner_references - .unwrap() - .first() - .unwrap() - .controller - .unwrap()); - assert!(svc - .metadata - .clone() - .owner_references - .unwrap() - .first() - .unwrap() - .block_owner_deletion - .unwrap()); + assert!( + svc.metadata + .clone() + .owner_references + .unwrap() + .first() + .unwrap() + .controller + .unwrap() + ); + assert!( + svc.metadata + .clone() + .owner_references + .unwrap() + .first() + .unwrap() + .block_owner_deletion + .unwrap() + ); // Validate the existing selector unchanged assert_eq!( diff --git a/webhooks/validating/configuration/src/main.rs b/webhooks/validating/configuration/src/main.rs index 9ef9ebb22..d1808e572 100644 --- a/webhooks/validating/configuration/src/main.rs +++ b/webhooks/validating/configuration/src/main.rs @@ -1,4 +1,4 @@ -use actix_web::{post, web, App, HttpResponse, HttpServer, Responder}; +use actix_web::{App, HttpResponse, HttpServer, Responder, post, web}; use akri_shared::akri::configuration::Configuration; use clap::Arg; use k8s_openapi::apimachinery::pkg::runtime::RawExtension; @@ -7,7 +7,7 @@ use openapi::models::{ V1AdmissionReview as AdmissionReview, V1Status as Status, }; use openssl::ssl::{SslAcceptor, SslAcceptorBuilder, SslFiletype, SslMethod}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; fn get_builder(key: &str, crt: &str) -> SslAcceptorBuilder { let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap(); From 0e33b4e33d5d0b503801c46b9d2eefd9bf9df756 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 14:40:33 +0100 Subject: [PATCH 13/19] chore: update rust version to 1.88 Signed-off-by: Gaurav Gahlot --- Cargo.toml | 2 +- README.md | 2 +- agent/src/device_manager/in_memory.rs | 2 +- .../discovery_handler_registry.rs | 20 +- .../embedded_handler.rs | 4 +- .../registration_socket.rs | 12 +- agent/src/main.rs | 14 +- .../device_plugin_instance_controller.rs | 20 +- .../plugin_manager/device_plugin_runner.rs | 24 +- .../device_plugin_slot_reclaimer.rs | 7 +- agent/src/plugin_manager/v1.rs | 139 ++++--- agent/src/plugin_manager/v1beta1.rs | 377 ++++++++++++------ build/containers/Dockerfile.rust | 2 +- build/setup.sh | 4 +- controller/src/main.rs | 16 +- controller/src/util/instance_action.rs | 79 ++-- controller/src/util/node_watcher.rs | 21 +- controller/src/util/pod_action.rs | 9 +- controller/src/util/pod_watcher.rs | 49 +-- controller/src/util/shared_test_utils.rs | 31 +- .../debug-echo/src/discovery_handler.rs | 8 +- .../onvif/src/credential_store.rs | 2 +- .../onvif/src/discovery_handler.rs | 16 +- .../onvif/src/discovery_impl.rs | 29 +- .../onvif/src/discovery_utils.rs | 70 ++-- .../onvif/src/username_token.rs | 2 +- .../opcua/src/discovery_handler.rs | 10 +- .../opcua/src/discovery_impl.rs | 36 +- .../udev/src/discovery_handler.rs | 14 +- discovery-handlers/udev/src/discovery_impl.rs | 27 +- discovery-utils/src/discovery/mod.rs | 5 +- discovery-utils/src/discovery/v0.rs | 192 +++++---- samples/brokers/udev-video-broker/src/main.rs | 11 +- .../udev-video-broker/src/util/camera.rs | 71 ++-- .../src/util/camera_capturer.rs | 16 +- .../src/util/camera_service.rs | 12 +- shared/src/akri/configuration.rs | 16 +- shared/src/akri/instance.rs | 42 +- shared/src/akri/metrics.rs | 2 +- shared/src/k8s/api.rs | 4 +- shared/src/k8s/job.rs | 2 +- shared/src/k8s/mod.rs | 11 +- shared/src/k8s/node.rs | 2 +- shared/src/k8s/pod.rs | 8 +- shared/src/k8s/service.rs | 11 +- webhooks/validating/configuration/src/main.rs | 44 +- 46 files changed, 749 insertions(+), 748 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d88c28215..bf8bbd0c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,5 +28,5 @@ edition = "2024" license = "Apache-2.0" homepage = "https://docs.akri.sh/" repository = "https://github.com/project-akri/akri" -rust-version = "1.85" +rust-version = "1.88" authors = ["The Akri Team"] diff --git a/README.md b/README.md index d05c5db4e..15bc5cc8c 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.85.0-blue.svg)](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0/) +[![Rust Version](https://img.shields.io/badge/rustc-1.88.0-blue.svg)](https://blog.rust-lang.org/2025/06/26/Rust-1.88.0/) [![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/src/device_manager/in_memory.rs b/agent/src/device_manager/in_memory.rs index 5da87d051..e2cedfbc1 100644 --- a/agent/src/device_manager/in_memory.rs +++ b/agent/src/device_manager/in_memory.rs @@ -24,7 +24,7 @@ impl DeviceManager for InMemoryManager { let state = self.state.borrow(); let cdi_kind = state.get(kind)?; let mut device = cdi_kind.devices.iter().find(|dev| dev.name == id)?.clone(); - device.name = format!("{}-{}", kind, id); + device.name = format!("{kind}-{id}"); device.annotations.extend( cdi_kind .annotations diff --git a/agent/src/discovery_handler_manager/discovery_handler_registry.rs b/agent/src/discovery_handler_manager/discovery_handler_registry.rs index 20a76c676..0a401584d 100644 --- a/agent/src/discovery_handler_manager/discovery_handler_registry.rs +++ b/agent/src/discovery_handler_manager/discovery_handler_registry.rs @@ -68,7 +68,7 @@ impl DiscoveredDevice { let mut id_to_digest = id_to_digest.to_string(); // For local devices, include node hostname in id_to_digest so instances have unique names if !shared { - id_to_digest = format!("{}{}", id_to_digest, node_name); + id_to_digest = format!("{id_to_digest}{node_name}"); } let mut digest = String::new(); let mut hasher = VarBlake2b::new(3).unwrap(); @@ -76,7 +76,7 @@ impl DiscoveredDevice { hasher.finalize_variable(|var| { digest = var .iter() - .map(|num| format!("{:02x}", num)) + .map(|num| format!("{num:02x}")) .collect::>() .join("") }); @@ -102,7 +102,7 @@ impl From for crate::device_manager::cdi::Device { env: dev .properties .into_iter() - .map(|(k, v)| format!("{}={}", k, v)) + .map(|(k, v)| format!("{k}={v}")) .collect(), device_nodes: dev.device_specs.into_iter().map_into().collect(), mounts: dev.mounts.into_iter().map_into().collect(), @@ -200,7 +200,7 @@ impl DiscoveryHandlerRequest for DHRequestImpl { if extra_device_properties != *current { let edit = extra_device_properties .iter() - .map(|(k, v)| format!("{}={}", k, v)) + .map(|(k, v)| format!("{k}={v}")) .collect(); *current = extra_device_properties; self.notifier @@ -298,7 +298,7 @@ impl DHRequestImpl { .read() .await .iter() - .map(|(k, v)| format!("{}={}", k, v)) + .map(|(k, v)| format!("{k}={v}")) .collect(), ..Default::default() }], @@ -371,7 +371,7 @@ async fn handle_request( cdi_sender: Arc>>>, local_config_sender: mpsc::Sender>, ) { - let cdi_kind = format!("{}/{}", AKRI_PREFIX, key); + let cdi_kind = format!("{AKRI_PREFIX}/{key}"); loop { match req_notifier.changed().await { Ok(_) => { @@ -379,7 +379,7 @@ async fn handle_request( cdi_sender.lock().await.send_modify(|kinds| { kinds.insert(cdi_kind.clone(), kind); }); - trace!("Ask for reconciliation of {}::{}", namespace, key); + trace!("Ask for reconciliation of {namespace}::{key}"); let res = local_config_sender .send(ObjectRef::::new(key).within(namespace)) .await; @@ -391,7 +391,7 @@ async fn handle_request( } } Err(_) => { - trace!("Ask for reconciliation of {}::{}", namespace, key); + trace!("Ask for reconciliation of {namespace}::{key}"); let _ = local_config_sender .send(ObjectRef::::new(key).within(namespace)) .await; @@ -431,8 +431,8 @@ impl DiscoveryHandlerRegistry for DHRegistryImpl { termination_notifier: terminated.clone(), }; let dh_futures = handlers - .iter() - .map(|(_, handler)| dh_req.query(handler.clone())); + .values() + .map(|handler| dh_req.query(handler.clone())); let dh_streams: Vec>>> = try_join_all(dh_futures).await?; dh_req.endpoints = RwLock::new(dh_streams); diff --git a/agent/src/discovery_handler_manager/embedded_handler.rs b/agent/src/discovery_handler_manager/embedded_handler.rs index f74325420..dc29ba0e1 100644 --- a/agent/src/discovery_handler_manager/embedded_handler.rs +++ b/agent/src/discovery_handler_manager/embedded_handler.rs @@ -42,11 +42,11 @@ impl EmbeddedHandlerEndpoint { msg = stream.try_next() => match msg { Ok(Some(msg)) => msg, Ok(None) => { - error!("Discovery Handler {} closed the stream unexpectedly", uid); + error!("Discovery Handler {uid} closed the stream unexpectedly"); return }, Err(e) => { - error!("Received error on gRPC stream for {}: {}", uid, e); + error!("Received error on gRPC stream for {uid}: {e}"); return }, }, diff --git a/agent/src/discovery_handler_manager/registration_socket.rs b/agent/src/discovery_handler_manager/registration_socket.rs index d21a073bc..05305412b 100644 --- a/agent/src/discovery_handler_manager/registration_socket.rs +++ b/agent/src/discovery_handler_manager/registration_socket.rs @@ -76,16 +76,16 @@ impl NetworkEndpoint { msg = stream.try_next() => match msg { Ok(Some(msg)) => msg, Ok(None) => { - error!("Discovery Handler {} closed the stream unexpectedly", uid); + error!("Discovery Handler {uid} closed the stream unexpectedly"); return }, Err(e) => { - error!("Received error on gRPC stream for {}: {}", uid, e); + error!("Received error on gRPC stream for {uid}: {e}"); return }, }, }; - trace!("Received new message from discovery handler: {:?}", msg); + trace!("Received new message from discovery handler: {msg:?}"); let devices = msg .devices .into_iter() @@ -203,8 +203,7 @@ pub async fn run_registration_server( ) -> Result<(), Box> { info!("internal_run_registration_server - entered"); trace!( - "internal_run_registration_server - registration server listening on socket {}", - socket_path + "internal_run_registration_server - registration server listening on socket {socket_path}" ); #[cfg(any(test, feature = "agent-full"))] @@ -234,8 +233,7 @@ pub async fn run_registration_server( .serve_with_incoming(incoming) .await?; trace!( - "internal_run_registration_server - gracefully shutdown ... deleting socket {}", - socket_path + "internal_run_registration_server - gracefully shutdown ... deleting socket {socket_path}" ); std::fs::remove_file(socket_path).unwrap_or(()); Ok(()) diff --git a/agent/src/main.rs b/agent/src/main.rs index 8e54bf9ad..8f1ad6846 100644 --- a/agent/src/main.rs +++ b/agent/src/main.rs @@ -21,17 +21,11 @@ use std::{ #[cfg(unix)] #[tokio::main] async fn main() -> Result<(), Box> { - println!("{} Agent start", API_NAMESPACE); + println!("{API_NAMESPACE} Agent start"); - println!( - "{} KUBERNETES_PORT found ... env_logger::init", - API_NAMESPACE - ); + println!("{API_NAMESPACE} KUBERNETES_PORT found ... env_logger::init"); env_logger::try_init()?; - trace!( - "{} KUBERNETES_PORT found ... env_logger::init finished", - API_NAMESPACE - ); + trace!("{API_NAMESPACE} KUBERNETES_PORT found ... env_logger::init finished"); let mut tasks = Vec::new(); let node_name = env::var("AGENT_NODE_NAME")?; @@ -101,6 +95,6 @@ async fn main() -> Result<(), Box } futures::future::try_join_all(tasks).await?; - info!("{} Agent end", API_NAMESPACE); + info!("{API_NAMESPACE} Agent end"); Ok(()) } diff --git a/agent/src/plugin_manager/device_plugin_instance_controller.rs b/agent/src/plugin_manager/device_plugin_instance_controller.rs index 928b48850..fd3bd077c 100644 --- a/agent/src/plugin_manager/device_plugin_instance_controller.rs +++ b/agent/src/plugin_manager/device_plugin_instance_controller.rs @@ -72,8 +72,8 @@ impl Display for DeviceUsage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { DeviceUsage::Unused => write!(f, ""), - DeviceUsage::Node(node) => write!(f, "{}", node), - DeviceUsage::Configuration { vdev, node } => write!(f, "C:{}:{}", vdev, node), + DeviceUsage::Node(node) => write!(f, "{node}"), + DeviceUsage::Configuration { vdev, node } => write!(f, "C:{vdev}:{node}"), } } } @@ -247,7 +247,7 @@ impl InstanceDevicePlugin { .map_err(|e| match e { kube::Error::Api(ae) => match ae.code { 409 => { - trace!("Conflict on apply {:?}", ae); + trace!("Conflict on apply {ae:?}"); DevicePluginError::SlotInUse } _ => DevicePluginError::Other(ae.into()), @@ -321,7 +321,7 @@ fn instance_device_usage_to_device( .into_iter() .enumerate() .map(|(id, dev)| super::v1beta1::Device { - id: format!("{}-{}", device_name, id), + id: format!("{device_name}-{id}"), health: match dev { DeviceUsage::Unused => "Healthy", DeviceUsage::Configuration { .. } => "Unhealthy", @@ -334,7 +334,7 @@ fn instance_device_usage_to_device( topology: None, }) .collect(); - trace!("Sending devices to kubelet: {:?}", devices); + trace!("Sending devices to kubelet: {devices:?}"); Ok(ListAndWatchResponse { devices }) } @@ -401,7 +401,7 @@ impl InternalDevicePlugin for InstanceDevicePlugin { self.claim_slot(Some(id), DeviceUsage::Node(self.node_name.to_owned())) .await .map_err(|e| { - error!("Unable to claim slot: {:?}", e); + error!("Unable to claim slot: {e:?}"); tonic::Status::unknown("Unable to claim slot") })?; } @@ -419,7 +419,7 @@ fn cdi_device_to_car(device: &cdi::Device) -> ContainerAllocateResponse { let instance_hash = device .name .split('-') - .last() + .next_back() .unwrap_or_default() .to_uppercase(); @@ -440,7 +440,7 @@ fn cdi_device_to_car(device: &cdi::Device) -> ContainerAllocateResponse { let suffixed_envs = envs .clone() - .map(|(k, v)| (format!("{}_{}", k, instance_hash), v)); + .map(|(k, v)| (format!("{k}_{instance_hash}"), v)); ContainerAllocateResponse { envs: envs.chain(suffixed_envs).collect(), @@ -570,7 +570,7 @@ impl ConfigurationDevicePlugin { possible_slot += 1; } slots.insert( - format!("{}-{}", config_name, possible_slot), + format!("{config_name}-{possible_slot}"), ConfigurationSlot::DeviceFree(instance_name.clone()), ); } @@ -793,7 +793,7 @@ impl DevicePluginManager { .enumerate() .filter_map(|(i, u)| match u { DeviceUsage::Node(n) if *n == self.node_name => { - Some(format!("{}{}-{}", DP_SLOT_PREFIX, instance, i)) + Some(format!("{DP_SLOT_PREFIX}{instance}-{i}")) } DeviceUsage::Configuration { vdev, node } if *node == self.node_name => { Some(vdev.to_string()) diff --git a/agent/src/plugin_manager/device_plugin_runner.rs b/agent/src/plugin_manager/device_plugin_runner.rs index 38f5957fa..c2dbf2526 100644 --- a/agent/src/plugin_manager/device_plugin_runner.rs +++ b/agent/src/plugin_manager/device_plugin_runner.rs @@ -104,7 +104,7 @@ impl DevicePlugin for DevicePluginImpl { &self, requests: Request, ) -> Result, tonic::Status> { - trace!("kubelet called allocate {:?}", requests); + trace!("kubelet called allocate {requests:?}"); self.inner.allocate(requests).await } @@ -156,10 +156,7 @@ pub(super) async fn serve_and_register_plugin( .unwrap() .to_string(); - info!( - "serve - creating a device plugin server that will listen at: {}", - socket_path - ); + info!("serve - creating a device plugin server that will listen at: {socket_path}"); tokio::fs::create_dir_all(Path::new(&socket_path[..]).parent().unwrap()) .await .expect("Failed to create dir at socket path"); @@ -183,10 +180,7 @@ pub(super) async fn serve_and_register_plugin( .serve_with_incoming_shutdown(incoming, task_plugin.stopped()) .await .unwrap(); - trace!( - "serve - gracefully shutdown ... deleting socket {}", - socket_to_delete - ); + trace!("serve - gracefully shutdown ... deleting socket {socket_to_delete}"); // Socket may already be deleted in the case of the kubelet restart std::fs::remove_file(socket_to_delete).unwrap_or(()); }); @@ -205,16 +199,13 @@ async fn register_plugin( ) -> anyhow::Result<()> { use anyhow::Context; - let capability_id: String = format!("akri.sh/{}", device_plugin_name); + let capability_id: String = format!("akri.sh/{device_plugin_name}"); akri_shared::uds::unix_stream::try_connect(&socket_path) .await .with_context(|| format!("while trying to connect to {socket_path}"))?; - info!( - "register - entered for Instance {} and socket_name: {}", - capability_id, device_endpoint - ); + info!("register - entered for Instance {capability_id} and socket_name: {device_endpoint}"); let op = DevicePluginOptions { pre_start_required: false, get_preferred_allocation_available: false, @@ -240,10 +231,7 @@ async fn register_plugin( resource_name: capability_id.to_string(), options: Some(op), }); - trace!( - "register - before call to register with the kubelet at socket {}", - KUBELET_SOCKET - ); + trace!("register - before call to register with the kubelet at socket {KUBELET_SOCKET}"); // If fail to register with the kubelet, terminate device plugin registration_client.register(register_request).await?; diff --git a/agent/src/plugin_manager/device_plugin_slot_reclaimer.rs b/agent/src/plugin_manager/device_plugin_slot_reclaimer.rs index 6d5ed39f6..2dcce8190 100644 --- a/agent/src/plugin_manager/device_plugin_slot_reclaimer.rs +++ b/agent/src/plugin_manager/device_plugin_slot_reclaimer.rs @@ -42,10 +42,7 @@ async fn get_used_slots() -> Result, anyhow::Error> { let mut podresources_client = podresources::PodResourcesListerClient::new(channel); let list_request = tonic::Request::new(ListPodResourcesRequest {}); - trace!( - "register - before call to register with the kubelet at socket {}", - KUBELET_SOCKET - ); + trace!("register - before call to register with the kubelet at socket {KUBELET_SOCKET}"); // Get the list of allocated device ids from kubelet let resources = podresources_client @@ -83,7 +80,7 @@ pub async fn start_reclaimer(dp_manager: Arc) { if let Some(at) = stalled_slots.get(slot_to_reclaim) { if reclaim_iteration_start.saturating_duration_since(*at) >= SLOT_GRACE_PERIOD { // Slot is stalled for more than grace period, free it - trace!("freeing slot: {}", slot_to_reclaim); + trace!("freeing slot: {slot_to_reclaim}"); if dp_manager .free_slot(slot_to_reclaim.to_string()) .await diff --git a/agent/src/plugin_manager/v1.rs b/agent/src/plugin_manager/v1.rs index c93bf05dc..c255210b7 100644 --- a/agent/src/plugin_manager/v1.rs +++ b/agent/src/plugin_manager/v1.rs @@ -87,8 +87,8 @@ pub struct NumaNode { /// Generated client implementations. pub mod pod_resources_lister_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; /// PodResourcesLister is a service provided by the kubelet that provides information about the /// node resources consumed by pods and containers on the node #[derive(Debug, Clone)] @@ -129,13 +129,14 @@ pub mod pod_resources_lister_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, + http::Request, + Response = http::Response< + >::ResponseBody, >, - >>::Error: - Into + Send + Sync, + >, + , + >>::Error: Into + Send + Sync, { PodResourcesListerClient::new(InterceptedService::new(inner, interceptor)) } @@ -173,16 +174,23 @@ pub mod pod_resources_lister_client { pub async fn list( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1.PodResourcesLister/List"); + let path = http::uri::PathAndQuery::from_static( + "/v1.PodResourcesLister/List", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1.PodResourcesLister", "List")); @@ -191,23 +199,28 @@ pub mod pod_resources_lister_client { pub async fn get_allocatable_resources( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1.PodResourcesLister/GetAllocatableResources", ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new( - "v1.PodResourcesLister", - "GetAllocatableResources", - )); + req.extensions_mut() + .insert( + GrpcMethod::new("v1.PodResourcesLister", "GetAllocatableResources"), + ); self.inner.unary(req, path, codec).await } } @@ -222,11 +235,17 @@ pub mod pod_resources_lister_server { async fn list( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_allocatable_resources( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } /// PodResourcesLister is a service provided by the kubelet that provides information about the /// node resources consumed by pods and containers on the node @@ -253,7 +272,10 @@ pub mod pod_resources_lister_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -309,11 +331,15 @@ pub mod pod_resources_lister_server { "/v1.PodResourcesLister/List" => { #[allow(non_camel_case_types)] struct ListSvc(pub Arc); - impl - tonic::server::UnaryService for ListSvc - { + impl< + T: PodResourcesLister, + > tonic::server::UnaryService + for ListSvc { type Response = super::ListPodResourcesResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -351,12 +377,15 @@ pub mod pod_resources_lister_server { "/v1.PodResourcesLister/GetAllocatableResources" => { #[allow(non_camel_case_types)] struct GetAllocatableResourcesSvc(pub Arc); - impl - tonic::server::UnaryService - for GetAllocatableResourcesSvc - { + impl< + T: PodResourcesLister, + > tonic::server::UnaryService + for GetAllocatableResourcesSvc { type Response = super::AllocatableResourcesResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -364,9 +393,10 @@ pub mod pod_resources_lister_server { let inner = Arc::clone(&self.0); let fut = async move { ::get_allocatable_resources( - &inner, request, - ) - .await + &inner, + request, + ) + .await }; Box::pin(fut) } @@ -394,14 +424,18 @@ pub mod pod_resources_lister_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } @@ -427,7 +461,8 @@ pub mod pod_resources_lister_server { write!(f, "{:?}", self.0) } } - impl tonic::server::NamedService for PodResourcesListerServer { + impl tonic::server::NamedService + for PodResourcesListerServer { const NAME: &'static str = "v1.PodResourcesLister"; } } diff --git a/agent/src/plugin_manager/v1beta1.rs b/agent/src/plugin_manager/v1beta1.rs index e728044e6..2f6dd0fb0 100644 --- a/agent/src/plugin_manager/v1beta1.rs +++ b/agent/src/plugin_manager/v1beta1.rs @@ -96,7 +96,9 @@ pub struct PreStartContainerResponse {} #[derive(Clone, PartialEq, ::prost::Message)] pub struct PreferredAllocationRequest { #[prost(message, repeated, tag = "1")] - pub container_requests: ::prost::alloc::vec::Vec, + pub container_requests: ::prost::alloc::vec::Vec< + ContainerPreferredAllocationRequest, + >, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -106,7 +108,9 @@ pub struct ContainerPreferredAllocationRequest { pub available_device_i_ds: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, /// List of deviceIDs that must be included in the preferred allocation #[prost(string, repeated, tag = "2")] - pub must_include_device_i_ds: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + pub must_include_device_i_ds: ::prost::alloc::vec::Vec< + ::prost::alloc::string::String, + >, /// Number of devices to include in the preferred allocation #[prost(int32, tag = "3")] pub allocation_size: i32, @@ -117,7 +121,9 @@ pub struct ContainerPreferredAllocationRequest { #[derive(Clone, PartialEq, ::prost::Message)] pub struct PreferredAllocationResponse { #[prost(message, repeated, tag = "1")] - pub container_responses: ::prost::alloc::vec::Vec, + pub container_responses: ::prost::alloc::vec::Vec< + ContainerPreferredAllocationResponse, + >, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -162,8 +168,10 @@ pub struct AllocateResponse { pub struct ContainerAllocateResponse { /// List of environment variable to be set in the container to access one of more devices. #[prost(map = "string, string", tag = "1")] - pub envs: - ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + pub envs: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::string::String, + >, /// Mounts for the container. #[prost(message, repeated, tag = "2")] pub mounts: ::prost::alloc::vec::Vec, @@ -172,8 +180,10 @@ pub struct ContainerAllocateResponse { pub devices: ::prost::alloc::vec::Vec, /// Container annotations to pass to the container runtime #[prost(map = "string, string", tag = "4")] - pub annotations: - ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + pub annotations: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::string::String, + >, } /// Mount specifies a host volume to mount into a container. /// where device library or tools are installed on host and container @@ -210,8 +220,8 @@ pub struct DeviceSpec { /// Generated client implementations. pub mod registration_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; /// Registration is the service advertised by the Kubelet /// Only when Kubelet answers with a success code to a Register Request /// may Device Plugins start their service @@ -256,13 +266,14 @@ pub mod registration_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, + http::Request, + Response = http::Response< + >::ResponseBody, >, - >>::Error: - Into + Send + Sync, + >, + , + >>::Error: Into + Send + Sync, { RegistrationClient::new(InterceptedService::new(inner, interceptor)) } @@ -301,14 +312,19 @@ pub mod registration_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1beta1.Registration/Register"); + let path = http::uri::PathAndQuery::from_static( + "/v1beta1.Registration/Register", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.Registration", "Register")); @@ -319,8 +335,8 @@ pub mod registration_client { /// Generated client implementations. pub mod device_plugin_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; /// DevicePlugin is the service advertised by Device Plugins #[derive(Debug, Clone)] pub struct DevicePluginClient { @@ -360,13 +376,14 @@ pub mod device_plugin_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, + http::Request, + Response = http::Response< + >::ResponseBody, >, - >>::Error: - Into + Send + Sync, + >, + , + >>::Error: Into + Send + Sync, { DevicePluginClient::new(InterceptedService::new(inner, interceptor)) } @@ -406,23 +423,28 @@ pub mod device_plugin_client { pub async fn get_device_plugin_options( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1beta1.DevicePlugin/GetDevicePluginOptions", ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new( - "v1beta1.DevicePlugin", - "GetDevicePluginOptions", - )); + req.extensions_mut() + .insert( + GrpcMethod::new("v1beta1.DevicePlugin", "GetDevicePluginOptions"), + ); self.inner.unary(req, path, codec).await } /// ListAndWatch returns a stream of List of Devices @@ -435,14 +457,19 @@ pub mod device_plugin_client { tonic::Response>, tonic::Status, > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/ListAndWatch"); + let path = http::uri::PathAndQuery::from_static( + "/v1beta1.DevicePlugin/ListAndWatch", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "ListAndWatch")); @@ -456,23 +483,28 @@ pub mod device_plugin_client { pub async fn get_preferred_allocation( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1beta1.DevicePlugin/GetPreferredAllocation", ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new( - "v1beta1.DevicePlugin", - "GetPreferredAllocation", - )); + req.extensions_mut() + .insert( + GrpcMethod::new("v1beta1.DevicePlugin", "GetPreferredAllocation"), + ); self.inner.unary(req, path, codec).await } /// Allocate is called during container creation so that the Device @@ -481,15 +513,23 @@ pub mod device_plugin_client { pub async fn allocate( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/Allocate"); + let path = http::uri::PathAndQuery::from_static( + "/v1beta1.DevicePlugin/Allocate", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "Allocate")); @@ -501,17 +541,23 @@ pub mod device_plugin_client { pub async fn pre_start_container( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/PreStartContainer"); + let path = http::uri::PathAndQuery::from_static( + "/v1beta1.DevicePlugin/PreStartContainer", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "PreStartContainer")); @@ -560,7 +606,10 @@ pub mod registration_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -616,16 +665,23 @@ pub mod registration_server { "/v1beta1.Registration/Register" => { #[allow(non_camel_case_types)] struct RegisterSvc(pub Arc); - impl tonic::server::UnaryService for RegisterSvc { + impl< + T: Registration, + > tonic::server::UnaryService + for RegisterSvc { type Response = super::Empty; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::register(&inner, request).await }; + let fut = async move { + ::register(&inner, request).await + }; Box::pin(fut) } } @@ -652,14 +708,18 @@ pub mod registration_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } @@ -701,11 +761,15 @@ pub mod device_plugin_server { async fn get_device_plugin_options( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Server streaming response type for the ListAndWatch method. type ListAndWatchStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, - > + Send + > + + Send + 'static; /// ListAndWatch returns a stream of List of Devices /// Whenever a Device state change or a Device disappears, ListAndWatch @@ -713,7 +777,10 @@ pub mod device_plugin_server { async fn list_and_watch( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// GetPreferredAllocation returns a preferred set of devices to allocate /// from a list of available ones. The resulting preferred allocation is not /// guaranteed to be the allocation ultimately performed by the @@ -722,21 +789,30 @@ pub mod device_plugin_server { async fn get_preferred_allocation( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Allocate is called during container creation so that the Device /// Plugin can run device specific operations and instruct Kubelet /// of the steps to make the Device available in the container async fn allocate( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// PreStartContainer is called, if indicated by Device Plugin during registration phase, /// before each container start. Device plugin can run device specific operations /// such as resetting the device before making devices available to the container async fn pre_start_container( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } /// DevicePlugin is the service advertised by Device Plugins #[derive(Debug)] @@ -762,7 +838,10 @@ pub mod device_plugin_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -818,13 +897,23 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/GetDevicePluginOptions" => { #[allow(non_camel_case_types)] struct GetDevicePluginOptionsSvc(pub Arc); - impl tonic::server::UnaryService for GetDevicePluginOptionsSvc { + impl tonic::server::UnaryService + for GetDevicePluginOptionsSvc { type Response = super::DevicePluginOptions; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::get_device_plugin_options(&inner, request) + ::get_device_plugin_options( + &inner, + request, + ) .await }; Box::pin(fut) @@ -856,12 +945,20 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/ListAndWatch" => { #[allow(non_camel_case_types)] struct ListAndWatchSvc(pub Arc); - impl tonic::server::ServerStreamingService for ListAndWatchSvc { + impl< + T: DevicePlugin, + > tonic::server::ServerStreamingService + for ListAndWatchSvc { type Response = super::ListAndWatchResponse; type ResponseStream = T::ListAndWatchStream; - type Future = - BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::list_and_watch(&inner, request).await @@ -895,19 +992,26 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/GetPreferredAllocation" => { #[allow(non_camel_case_types)] struct GetPreferredAllocationSvc(pub Arc); - impl - tonic::server::UnaryService - for GetPreferredAllocationSvc - { + impl< + T: DevicePlugin, + > tonic::server::UnaryService + for GetPreferredAllocationSvc { type Response = super::PreferredAllocationResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::get_preferred_allocation(&inner, request).await + ::get_preferred_allocation( + &inner, + request, + ) + .await }; Box::pin(fut) } @@ -938,16 +1042,23 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/Allocate" => { #[allow(non_camel_case_types)] struct AllocateSvc(pub Arc); - impl tonic::server::UnaryService for AllocateSvc { + impl< + T: DevicePlugin, + > tonic::server::UnaryService + for AllocateSvc { type Response = super::AllocateResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::allocate(&inner, request).await }; + let fut = async move { + ::allocate(&inner, request).await + }; Box::pin(fut) } } @@ -977,19 +1088,23 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/PreStartContainer" => { #[allow(non_camel_case_types)] struct PreStartContainerSvc(pub Arc); - impl - tonic::server::UnaryService - for PreStartContainerSvc - { + impl< + T: DevicePlugin, + > tonic::server::UnaryService + for PreStartContainerSvc { type Response = super::PreStartContainerResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::pre_start_container(&inner, request).await + ::pre_start_container(&inner, request) + .await }; Box::pin(fut) } @@ -1017,14 +1132,18 @@ pub mod device_plugin_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } diff --git a/build/containers/Dockerfile.rust b/build/containers/Dockerfile.rust index 9448895f4..a4fc42854 100644 --- a/build/containers/Dockerfile.rust +++ b/build/containers/Dockerfile.rust @@ -1,6 +1,6 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:master AS xx -FROM --platform=$BUILDPLATFORM rust:1.85-slim-bookworm AS build +FROM --platform=$BUILDPLATFORM rust:1.88-slim-bookworm AS build RUN rustup component add rustfmt RUN apt-get update && apt-get install -y clang lld protobuf-compiler pkg-config mmdebstrap wget COPY --from=xx / / diff --git a/build/setup.sh b/build/setup.sh index b4a4c43ab..5cae11157 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.85.0 + sudo curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.88.0 else echo "Install rustup" - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.85.0 + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.88.0 fi else echo "Found rustup" diff --git a/controller/src/main.rs b/controller/src/main.rs index a10dcfa4d..998e8998d 100644 --- a/controller/src/main.rs +++ b/controller/src/main.rs @@ -19,19 +19,13 @@ lazy_static! { /// This is the entry point for the controller. #[tokio::main] async fn main() -> Result<(), Box> { - println!("{} Controller start", API_NAMESPACE); + println!("{API_NAMESPACE} Controller start"); - println!( - "{} KUBERNETES_PORT found ... env_logger::init", - API_NAMESPACE - ); + println!("{API_NAMESPACE} KUBERNETES_PORT found ... env_logger::init"); env_logger::try_init()?; - println!( - "{} KUBERNETES_PORT found ... env_logger::init finished", - API_NAMESPACE - ); + println!("{API_NAMESPACE} KUBERNETES_PORT found ... env_logger::init finished"); - log::info!("{} Controller logging started", API_NAMESPACE); + log::info!("{API_NAMESPACE} Controller logging started"); let synchronization = Arc::new(Mutex::new(())); let instance_watch_synchronization = synchronization.clone(); @@ -73,6 +67,6 @@ async fn main() -> Result<(), Box futures::future::try_join_all(tasks).await?; - log::info!("{} Controller end", API_NAMESPACE); + log::info!("{API_NAMESPACE} Controller end"); Ok(()) } diff --git a/controller/src/util/instance_action.rs b/controller/src/util/instance_action.rs index 087675035..c2b5d7c95 100644 --- a/controller/src/util/instance_action.rs +++ b/controller/src/util/instance_action.rs @@ -99,7 +99,7 @@ async fn internal_do_instance_watch( loop { let event = match informer.try_next().await { Err(e) => { - error!("Error during watch: {}", e); + error!("Error during watch: {e}"); continue; } Ok(None) => break, @@ -179,14 +179,10 @@ pub(crate) fn create_pod_context(k8s_pod: &Pod, action: PodAction) -> anyhow::Re .metadata .labels .as_ref() - .ok_or_else(|| anyhow::anyhow!("no labels found for Pod {:?}", pod_name))?; + .ok_or_else(|| anyhow::anyhow!("no labels found for Pod {pod_name:?}"))?; // Early exits above ensure unwrap will not panic let node_to_run_pod_on = labels.get(AKRI_TARGET_NODE_LABEL_NAME).ok_or_else(|| { - anyhow::anyhow!( - "no {} label found for {:?}", - AKRI_TARGET_NODE_LABEL_NAME, - pod_name - ) + anyhow::anyhow!("no {AKRI_TARGET_NODE_LABEL_NAME} label found for {pod_name:?}") })?; Ok(PodContext { @@ -208,10 +204,10 @@ fn determine_action_for_pod( let pod_phase = k8s_pod .status .as_ref() - .ok_or_else(|| anyhow::anyhow!("No pod status found for Pod {:?}", pod_name))? + .ok_or_else(|| anyhow::anyhow!("No pod status found for Pod {pod_name:?}"))? .phase .as_ref() - .ok_or_else(|| anyhow::anyhow!("No pod phase found for Pod {:?}", pod_name))?; + .ok_or_else(|| anyhow::anyhow!("No pod phase found for Pod {pod_name:?}"))?; let mut update_pod_context = create_pod_context(k8s_pod, PodAction::NoAction)?; let node_to_run_pod_on = update_pod_context.node_name.as_ref().unwrap(); @@ -246,16 +242,12 @@ async fn handle_deletion_work( ) -> anyhow::Result<()> { let context_node_name = context.node_name.as_ref().ok_or_else(|| { anyhow::anyhow!( - "handle_deletion_work - Context node_name is missing for {}: {:?}", - node_to_delete_pod, - context + "handle_deletion_work - Context node_name is missing for {node_to_delete_pod}: {context:?}" ) })?; let context_namespace = context.namespace.as_ref().ok_or_else(|| { anyhow::anyhow!( - "handle_deletion_work - Context namespace is missing for {}: {:?}", - node_to_delete_pod, - context + "handle_deletion_work - Context namespace is missing for {node_to_delete_pod}: {context:?}" ) })?; @@ -352,11 +344,8 @@ async fn handle_addition_work( podspec: &PodSpec, kube_interface: &impl KubeInterface, ) -> anyhow::Result<()> { - trace!( - "handle_addition_work - Create new Pod for Node={:?}", - new_node - ); - let capability_id = format!("{}/{}", AKRI_PREFIX, instance_name); + trace!("handle_addition_work - Create new Pod for Node={new_node:?}"); + let capability_id = format!("{AKRI_PREFIX}/{instance_name}"); let new_pod = pod::create_new_pod_from_spec( instance_namespace, instance_name, @@ -372,7 +361,7 @@ async fn handle_addition_work( podspec, )?; - trace!("handle_addition_work - New pod spec={:?}", new_pod); + trace!("handle_addition_work - New pod spec={new_pod:?}"); kube_interface .create_pod(&new_pod, instance_namespace) @@ -393,7 +382,7 @@ pub async fn handle_instance_change( action: &InstanceAction, kube_interface: &impl KubeInterface, ) -> anyhow::Result<()> { - trace!("handle_instance_change - enter {:?}", action); + trace!("handle_instance_change - enter {action:?}"); let instance_name = instance.metadata.name.clone().unwrap(); let instance_namespace = instance.metadata.namespace.as_ref().ok_or_else(|| { @@ -434,7 +423,7 @@ pub async fn handle_instance_change( } }; if let Err(e) = instance_change_result { - error!("Unable to handle Broker action: {:?}", e); + error!("Unable to handle Broker action: {e:?}"); } } Ok(()) @@ -451,14 +440,14 @@ pub async fn handle_instance_change_job( action: &InstanceAction, kube_interface: &impl KubeInterface, ) -> anyhow::Result<()> { - trace!("handle_instance_change_job - enter {:?}", action); + trace!("handle_instance_change_job - enter {action:?}"); // 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(), None, instance.spec.shared, - &format!("{}-job", config_generation), + &format!("{config_generation}-job"), ); let instance_name = instance.metadata.name.as_ref().unwrap(); @@ -471,7 +460,7 @@ pub async fn handle_instance_change_job( match action { InstanceAction::Add => { trace!("handle_instance_change_job - instance added"); - let capability_id = format!("{}/{}", AKRI_PREFIX, instance_name); + let capability_id = format!("{AKRI_PREFIX}/{instance_name}"); let new_job = job::create_new_job_from_spec( instance, OwnershipInfo::new( @@ -491,7 +480,7 @@ pub async fn handle_instance_change_job( trace!("handle_instance_change_job - instance removed"); // Find all jobs with the label let instance_jobs = kube_interface - .find_jobs_with_label(&format!("{}={}", AKRI_INSTANCE_LABEL_NAME, instance_name)) + .find_jobs_with_label(&format!("{AKRI_INSTANCE_LABEL_NAME}={instance_name}")) .await?; let delete_tasks = instance_jobs.into_iter().map(|j| async move { kube_interface @@ -524,7 +513,7 @@ pub async fn handle_instance_change_pod( action: &InstanceAction, kube_interface: &impl KubeInterface, ) -> anyhow::Result<()> { - trace!("handle_instance_change_pod - enter {:?}", action); + trace!("handle_instance_change_pod - enter {action:?}"); let instance_name = instance.metadata.name.clone().unwrap(); @@ -549,17 +538,13 @@ pub async fn handle_instance_change_pod( ) }) .collect(); - trace!( - "handle_instance_change - nodes tracked from instance={:?}", - nodes_to_act_on - ); + trace!("handle_instance_change - nodes tracked from instance={nodes_to_act_on:?}"); trace!( - "handle_instance_change - find all pods that have {}={}", - AKRI_INSTANCE_LABEL_NAME, instance_name + "handle_instance_change - find all pods that have {AKRI_INSTANCE_LABEL_NAME}={instance_name}" ); let instance_pods = kube_interface - .find_pods_with_label(&format!("{}={}", AKRI_INSTANCE_LABEL_NAME, instance_name)) + .find_pods_with_label(&format!("{AKRI_INSTANCE_LABEL_NAME}={instance_name}")) .await?; trace!( "handle_instance_change - found {} pods", @@ -576,8 +561,7 @@ pub async fn handle_instance_change_pod( .try_for_each(|x| determine_action_for_pod(x, action, &mut nodes_to_act_on))?; trace!( - "handle_instance_change - nodes tracked after querying existing pods={:?}", - nodes_to_act_on + "handle_instance_change - nodes tracked after querying existing pods={nodes_to_act_on:?}" ); do_pod_action_for_nodes(nodes_to_act_on, instance, podspec, kube_interface).await?; trace!("handle_instance_change - exit"); @@ -656,10 +640,7 @@ mod handle_instance_tests { result_file: &'static str, specified_phase: &'static str, ) { - trace!( - "mock.expect_find_pods_with_label pod_selector:{}", - pod_selector - ); + trace!("mock.expect_find_pods_with_label pod_selector:{pod_selector}"); mock.expect_find_pods_with_label() .times(1) .withf(move |selector| selector == pod_selector) @@ -667,7 +648,7 @@ mod handle_instance_tests { let pods_json = file::read_file_to_string(result_file); let phase_adjusted_json = pods_json.replace( "\"phase\": \"Running\"", - &format!("\"phase\": \"{}\"", specified_phase), + &format!("\"phase\": \"{specified_phase}\""), ); let pods: PodList = serde_json::from_str(&phase_adjusted_json).unwrap(); Ok(pods) @@ -681,10 +662,7 @@ mod handle_instance_tests { specified_phase: &'static str, start_time: DateTime, ) { - trace!( - "mock.expect_find_pods_with_label pod_selector:{}", - pod_selector - ); + trace!("mock.expect_find_pods_with_label pod_selector:{pod_selector}"); mock.expect_find_pods_with_label() .times(1) .withf(move |selector| selector == pod_selector) @@ -692,7 +670,7 @@ mod handle_instance_tests { let pods_json = file::read_file_to_string(result_file); let phase_adjusted_json = pods_json.replace( "\"phase\": \"Running\"", - &format!("\"phase\": \"{}\"", specified_phase), + &format!("\"phase\": \"{specified_phase}\""), ); let start_time_adjusted_json = phase_adjusted_json.replace( "\"startTime\": \"2020-02-25T20:48:03Z\"", @@ -712,10 +690,7 @@ mod handle_instance_tests { result_file: &'static str, specified_phase: &'static str, ) { - trace!( - "mock.expect_find_pods_with_label pod_selector:{}", - pod_selector - ); + trace!("mock.expect_find_pods_with_label pod_selector:{pod_selector}"); mock.expect_find_pods_with_label() .times(1) .withf(move |selector| selector == pod_selector) @@ -723,7 +698,7 @@ mod handle_instance_tests { let pods_json = file::read_file_to_string(result_file); let phase_adjusted_json = pods_json.replace( "\"phase\": \"Running\"", - &format!("\"phase\": \"{}\"", specified_phase), + &format!("\"phase\": \"{specified_phase}\""), ); let start_time_adjusted_json = phase_adjusted_json.replace("\"startTime\": \"2020-02-25T20:48:03Z\",", ""); diff --git a/controller/src/util/node_watcher.rs b/controller/src/util/node_watcher.rs index 0da9135f5..47767bcd1 100644 --- a/controller/src/util/node_watcher.rs +++ b/controller/src/util/node_watcher.rs @@ -66,7 +66,7 @@ impl NodeWatcher { loop { let event = match informer.try_next().await { Err(e) => { - error!("Error during watch: {}", e); + error!("Error during watch: {e}"); continue; } Ok(None) => break, @@ -107,7 +107,7 @@ impl NodeWatcher { match event { Event::Applied(node) => { let node_name = node.metadata.name.clone().unwrap(); - info!("handle_node - Added or modified: {}", node_name); + info!("handle_node - Added or modified: {node_name}"); if self.is_node_ready(&node) { self.known_nodes.insert(node_name, NodeState::Running); } else if let std::collections::hash_map::Entry::Vacant(e) = @@ -210,10 +210,7 @@ impl NodeWatcher { vanished_node_name: &str, kube_interface: &impl KubeInterface, ) -> anyhow::Result<()> { - trace!( - "handle_node_disappearance - enter vanished_node_name={:?}", - vanished_node_name, - ); + trace!("handle_node_disappearance - enter vanished_node_name={vanished_node_name:?}",); let instances = kube_interface.get_instances().await?; trace!( @@ -223,7 +220,7 @@ impl NodeWatcher { for instance in instances.items { let instance_name = instance.metadata.name.clone().unwrap(); let instance_namespace = instance.metadata.namespace.as_ref().ok_or_else(|| { - anyhow::anyhow!("Namespace not found for instance: {}", instance_name) + anyhow::anyhow!("Namespace not found for instance: {instance_name}") })?; trace!( @@ -570,7 +567,7 @@ mod tests { } }"#; fn listify_node(node_json: &str) -> String { - format!("{}\n{}\n{}", LIST_PREFIX, node_json, LIST_SUFFIX) + format!("{LIST_PREFIX}\n{node_json}\n{LIST_SUFFIX}") } #[tokio::test] @@ -634,8 +631,7 @@ mod tests { } }) .collect::>() - .first() - .is_none() + .is_empty() }) .returning(move |_, _, _| Ok(())); @@ -666,10 +662,7 @@ mod tests { ]; for (node_file, result) in tests.iter() { - trace!( - "Testing {} should reflect node is ready={}", - node_file, result - ); + trace!("Testing {node_file} should reflect node is ready={result}"); let node_json = file::read_file_to_string(node_file); let kube_object_node: Node = serde_json::from_str(&node_json).unwrap(); diff --git a/controller/src/util/pod_action.rs b/controller/src/util/pod_action.rs index d105990fe..70496b7a0 100644 --- a/controller/src/util/pod_action.rs +++ b/controller/src/util/pod_action.rs @@ -79,8 +79,7 @@ impl PodActionInfo { if let Some(start_time) = &self.status_start_time { // If this pod has a start_time in its status, calculate when the grace period would end log::trace!( - "time_choice_for_non_running_pods - checking for time after start_time ({:?})", - start_time + "time_choice_for_non_running_pods - checking for time after start_time ({start_time:?})" ); let time_limit = &start_time .0 @@ -95,8 +94,7 @@ impl PodActionInfo { // If "now" is less than the grace period, the pod deserves more time give_it_more_time = now < *time_limit; log::trace!( - "time_choice_for_non_running_pods - give_it_more_time: ({:?})", - give_it_more_time + "time_choice_for_non_running_pods - give_it_more_time: ({give_it_more_time:?})" ); } else { // If the pod has no start_time, give it more time @@ -106,8 +104,7 @@ impl PodActionInfo { ); give_it_more_time = true; log::trace!( - "time_choice_for_non_running_pods - give_it_more_time: ({:?})", - give_it_more_time + "time_choice_for_non_running_pods - give_it_more_time: ({give_it_more_time:?})" ); } diff --git a/controller/src/util/pod_watcher.rs b/controller/src/util/pod_watcher.rs index 90ed2a4b8..e9fbb596d 100644 --- a/controller/src/util/pod_watcher.rs +++ b/controller/src/util/pod_watcher.rs @@ -140,7 +140,7 @@ impl BrokerPodWatcher { loop { let event = match informer.try_next().await { Err(e) => { - error!("Error during watch: {}", e); + error!("Error during watch: {e}"); continue; } Ok(None) => return Err(anyhow::anyhow!("Watch stream ended")), @@ -176,7 +176,7 @@ impl BrokerPodWatcher { kube_interface: &impl KubeInterface, first_event: &mut bool, ) -> anyhow::Result<()> { - trace!("handle_pod - enter [event: {:?}]", event); + trace!("handle_pod - enter [event: {event:?}]"); match event { Event::Applied(pod) => { info!( @@ -189,7 +189,7 @@ impl BrokerPodWatcher { "Unknown" | "Pending" => { self.known_pods.insert( pod.metadata.name.clone().ok_or_else(|| { - anyhow::format_err!("Pod {:?} does not have name", pod) + anyhow::format_err!("Pod {pod:?} does not have name") })?, PodState::Pending, ); @@ -214,10 +214,7 @@ impl BrokerPodWatcher { } Event::Restarted(pods) => { if *first_event { - info!( - "handle_pod - pod watcher [re]started. Pods are : {:?}", - pods - ); + info!("handle_pod - pod watcher [re]started. Pods are : {pods:?}"); } else { return Err(anyhow::anyhow!( "Pod watcher restarted - throwing error to restart controller" @@ -241,7 +238,7 @@ impl BrokerPodWatcher { .metadata .name .clone() - .ok_or_else(|| anyhow::format_err!("Pod {:?} does not have name", pod))?; + .ok_or_else(|| anyhow::format_err!("Pod {pod:?} does not have name"))?; let last_known_state = self.known_pods.get(&pod_name).unwrap_or(&PodState::Pending); trace!( "handle_running_pod_if_needed - last_known_state: {:?}", @@ -271,7 +268,7 @@ impl BrokerPodWatcher { .metadata .name .clone() - .ok_or_else(|| anyhow::format_err!("Pod {:?} does not have name", pod))?; + .ok_or_else(|| anyhow::format_err!("Pod {pod:?} does not have name"))?; let last_known_state = self.known_pods.get(&pod_name).unwrap_or(&PodState::Pending); trace!( "handle_ended_pod_if_needed - last_known_state: {:?}", @@ -301,7 +298,7 @@ impl BrokerPodWatcher { .metadata .name .clone() - .ok_or_else(|| anyhow::format_err!("Pod {:?} does not have name", pod))?; + .ok_or_else(|| anyhow::format_err!("Pod {pod:?} does not have name"))?; let last_known_state = self.known_pods.get(&pod_name).unwrap_or(&PodState::Pending); trace!( "handle_deleted_pod_if_needed - last_known_state: {:?}", @@ -402,11 +399,8 @@ impl BrokerPodWatcher { }; // Clean up instance service if there are no pods anymore - let selector = format!("{}={}", label, value); - trace!( - "find_pods_and_cleanup_svc_if_unsupported - find_pods_with_label({})", - selector - ); + let selector = format!("{label}={value}"); + trace!("find_pods_and_cleanup_svc_if_unsupported - find_pods_with_label({selector})"); let pods = kube_interface.find_pods_with_label(&selector).await?; trace!( "find_pods_and_cleanup_svc_if_unsupported - found {} pods", @@ -447,10 +441,7 @@ impl BrokerPodWatcher { }, _ => true, }).count(); - trace!( - "cleanup_svc_if_unsupported - num_non_terminating_pods: {}", - num_non_terminating_pods - ); + trace!("cleanup_svc_if_unsupported - num_non_terminating_pods: {num_non_terminating_pods}"); if num_non_terminating_pods == 0 { trace!( @@ -513,7 +504,7 @@ impl BrokerPodWatcher { .metadata .uid .as_ref() - .ok_or_else(|| anyhow::anyhow!("UID not found for instance: {}", instance_name))?; + .ok_or_else(|| anyhow::anyhow!("UID not found for instance: {instance_name}"))?; self.add_instance_and_configuration_services( &instance_name, instance_uid, @@ -548,13 +539,13 @@ impl BrokerPodWatcher { let mut create_new_service = true; if let Ok(existing_svcs) = kube_interface - .find_services(&format!("{}={}", label_name, label_value)) + .find_services(&format!("{label_name}={label_value}")) .await { for existing_svc in existing_svcs { let mut existing_svc = existing_svc.clone(); let svc_name = existing_svc.metadata.name.clone().ok_or_else(|| { - anyhow::format_err!("Service {:?} does not have name", existing_svc) + anyhow::format_err!("Service {existing_svc:?} does not have name") })?; let svc_namespace = existing_svc.metadata.namespace.as_ref().unwrap().clone(); trace!( @@ -583,10 +574,7 @@ impl BrokerPodWatcher { service_spec, is_instance_service, )?; - trace!( - "create_or_update_service - New instance svc spec={:?}", - new_instance_svc - ); + trace!("create_or_update_service - New instance svc spec={new_instance_svc:?}"); kube_interface .create_service(&new_instance_svc, namespace) @@ -606,10 +594,7 @@ impl BrokerPodWatcher { configuration: &Configuration, kube_interface: &impl KubeInterface, ) -> anyhow::Result<()> { - trace!( - "add_instance_and_configuration_services - instance={:?}", - instance_name - ); + trace!("add_instance_and_configuration_services - instance={instance_name:?}"); if let Some(instance_service_spec) = &configuration.spec.instance_service_spec { let ownership = OwnershipInfo::new( OwnershipType::Instance, @@ -645,7 +630,7 @@ impl BrokerPodWatcher { if let Some(configuration_service_spec) = &configuration.spec.configuration_service_spec { let configuration_uid = configuration.metadata.uid.as_ref().ok_or_else(|| { - anyhow::anyhow!("UID not found for configuration: {}", configuration_name) + anyhow::anyhow!("UID not found for configuration: {configuration_name}") })?; let ownership = OwnershipInfo::new( OwnershipType::Configuration, @@ -695,7 +680,7 @@ mod tests { let pods_json = file::read_file_to_string(result_file); let phase_adjusted_json = pods_json.replace( "\"phase\": \"Running\"", - &format!("\"phase\": \"{}\"", specified_phase), + &format!("\"phase\": \"{specified_phase}\""), ); let pods: PodList = serde_json::from_str(&phase_adjusted_json).unwrap(); pods diff --git a/controller/src/util/shared_test_utils.rs b/controller/src/util/shared_test_utils.rs index a3c926f40..8bea2e262 100644 --- a/controller/src/util/shared_test_utils.rs +++ b/controller/src/util/shared_test_utils.rs @@ -22,7 +22,7 @@ pub mod config_for_tests { result_file: &'static str, result_error: bool, ) { - trace!("mock.expect_find_instance instance_name:{}", instance_name); + trace!("mock.expect_find_instance instance_name:{instance_name}"); mock.expect_find_instance() .times(1) .withf(move |name, namespace| name == instance_name && namespace == instance_namespace) @@ -58,7 +58,7 @@ pub mod config_for_tests { } }"#; fn listify_kube_object(node_json: &str) -> String { - format!("{}\n{}\n{}", LIST_PREFIX, node_json, LIST_SUFFIX) + format!("{LIST_PREFIX}\n{node_json}\n{LIST_SUFFIX}") } pub fn configure_get_instances( @@ -87,8 +87,7 @@ pub mod config_for_tests { result_error: bool, ) { trace!( - "mock.expect_update_instance name:{} namespace:{} error:{}", - instance_name, instance_namespace, result_error + "mock.expect_update_instance name:{instance_name} namespace:{instance_namespace} error:{result_error}" ); mock.expect_update_instance() .times(1) @@ -114,7 +113,7 @@ pub mod config_for_tests { result_file: &'static str, result_error: bool, ) { - trace!("mock.expect_find_configuration config_name:{}", config_name); + trace!("mock.expect_find_configuration config_name:{config_name}"); mock.expect_find_configuration() .times(1) .withf(move |name, namespace| name == config_name && namespace == config_namespace) @@ -135,7 +134,7 @@ pub mod config_for_tests { result_file: &'static str, result_error: bool, ) { - trace!("mock.expect_find_services svc_selector:{}", svc_selector); + trace!("mock.expect_find_services svc_selector:{svc_selector}"); mock.expect_find_services() .times(1) .withf(move |selector| selector == svc_selector) @@ -181,10 +180,7 @@ pub mod config_for_tests { svc_name: &'static str, svc_namespace: &'static str, ) { - trace!( - "mock.expect_remove_service svc_name:{}, svc_namespace={}", - svc_name, svc_namespace - ); + trace!("mock.expect_remove_service svc_name:{svc_name}, svc_namespace={svc_namespace}"); mock.expect_remove_service() .times(1) .withf(move |svc_to_remove, namespace| { @@ -200,8 +196,7 @@ pub mod config_for_tests { result_error: bool, ) { trace!( - "mock.expect_update_service name:{} namespace:{} error:{}", - svc_name, svc_namespace, result_error, + "mock.expect_update_service name:{svc_name} namespace:{svc_namespace} error:{result_error}", ); mock.expect_update_service() .times(1) @@ -221,10 +216,7 @@ pub mod config_for_tests { result_file: &'static str, result_error: bool, ) { - trace!( - "mock.expect_find_pods_with_label pod_selector:{}", - pod_selector - ); + trace!("mock.expect_find_pods_with_label pod_selector:{pod_selector}"); mock.expect_find_pods_with_label() .times(1) .withf(move |selector| selector == pod_selector) @@ -247,7 +239,7 @@ pub mod config_for_tests { label_value: &'static str, error: bool, ) { - trace!("mock.expect_create_pod pod_name:{}", pod_name); + trace!("mock.expect_create_pod pod_name:{pod_name}"); mock.expect_create_pod() .times(1) .withf(move |pod_to_create, namespace| { @@ -273,10 +265,7 @@ pub mod config_for_tests { pod_name: &'static str, pod_namespace: &'static str, ) { - trace!( - "mock.expect_remove_pod pod_name:{} pod_namespace:{}", - pod_name, pod_namespace - ); + trace!("mock.expect_remove_pod pod_name:{pod_name} pod_namespace:{pod_namespace}"); mock.expect_remove_pod() .times(1) .withf(move |pod_to_remove, namespace| { diff --git a/discovery-handlers/debug-echo/src/discovery_handler.rs b/discovery-handlers/debug-echo/src/discovery_handler.rs index 5389bc0b0..63fa7cec7 100644 --- a/discovery-handlers/debug-echo/src/discovery_handler.rs +++ b/discovery-handlers/debug-echo/src/discovery_handler.rs @@ -59,7 +59,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { mpsc::channel(DISCOVERED_DEVICES_CHANNEL_CAPACITY); let discovery_handler_config: DebugEchoDiscoveryDetails = deserialize_discovery_details(&discover_request.discovery_details) - .map_err(|e| tonic::Status::new(tonic::Code::InvalidArgument, format!("{}", e)))?; + .map_err(|e| tonic::Status::new(tonic::Code::InvalidArgument, format!("{e}")))?; let descriptions = discovery_handler_config.descriptions; let mut offline = fs::read_to_string(DEBUG_ECHO_AVAILABILITY_CHECK_PATH) .unwrap_or_default() @@ -95,8 +95,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { .await { error!( - "discover - for debugEcho failed to send discovery response with error {}", - e + "discover - for debugEcho failed to send discovery response with error {e}" ); if let Some(sender) = register_sender { sender.send(()).await.unwrap(); @@ -130,8 +129,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { { // TODO: consider re-registering here error!( - "discover - for debugEcho failed to send discovery response with error {}", - e + "discover - for debugEcho failed to send discovery response with error {e}" ); if let Some(sender) = register_sender { sender.send(()).await.unwrap(); diff --git a/discovery-handlers/onvif/src/credential_store.rs b/discovery-handlers/onvif/src/credential_store.rs index 5f44d95c4..923c7b0ce 100644 --- a/discovery-handlers/onvif/src/credential_store.rs +++ b/discovery-handlers/onvif/src/credential_store.rs @@ -251,7 +251,7 @@ mod tests { "[{}]", entries .iter() - .map(|(k, _v)| format!(r#""{}""#, k)) + .map(|(k, _v)| format!(r#""{k}""#)) .collect::>() .join(", ") ); diff --git a/discovery-handlers/onvif/src/discovery_handler.rs b/discovery-handlers/onvif/src/discovery_handler.rs index fb14a7726..ef464d222 100644 --- a/discovery-handlers/onvif/src/discovery_handler.rs +++ b/discovery-handlers/onvif/src/discovery_handler.rs @@ -74,7 +74,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { mpsc::channel(DISCOVERED_DEVICES_CHANNEL_CAPACITY); let discovery_handler_config: OnvifDiscoveryDetails = deserialize_discovery_details(&discover_request.discovery_details) - .map_err(|e| tonic::Status::new(tonic::Code::InvalidArgument, format!("{}", e)))?; + .map_err(|e| tonic::Status::new(tonic::Code::InvalidArgument, format!("{e}")))?; let credential_store = CredentialStore::new(&discover_request.discovery_properties); let onvif_query = OnvifQueryImpl::new(credential_store); tokio::spawn(async move { @@ -135,8 +135,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { .await { error!( - "discover - for ONVIF failed to send discovery response with error {}", - e + "discover - for ONVIF failed to send discovery response with error {e}" ); if let Some(sender) = register_sender { sender.send(()).await.unwrap(); @@ -159,10 +158,7 @@ async fn apply_filters( device_uuid: &str, onvif_query: &impl OnvifQuery, ) -> Option<(String, Device)> { - info!( - "apply_filters - device service url {}, uuid {}", - device_service_uri, device_uuid - ); + info!("apply_filters - device service url {device_service_uri}, uuid {device_uuid}"); // Evaluate device uuid against uuids filter if provided if util::execute_filter( discovery_handler_config.uuids.as_ref(), @@ -176,7 +172,7 @@ async fn apply_filters( .get_device_ip_and_mac_address(device_service_uri, device_uuid) .await .map_err(|e| { - error!("apply_filters - error getting ip and mac address: {}", e); + error!("apply_filters - error getting ip and mac address: {e}"); e }) .ok(); @@ -201,7 +197,7 @@ async fn apply_filters( return None; } - let service_uri_and_uuid_joined = format!("{}-{}", device_service_uri, device_uuid); + let service_uri_and_uuid_joined = format!("{device_service_uri}-{device_uuid}"); let mut properties = HashMap::new(); properties.insert( ONVIF_DEVICE_SERVICE_URL_LABEL_ID.to_string(), @@ -280,7 +276,7 @@ mod tests { ( uri.to_string(), Device { - id: format!("{}-{}", uri, uuid), + id: format!("{uri}-{uuid}"), properties, mounts: Vec::default(), device_specs: Vec::default(), diff --git a/discovery-handlers/onvif/src/discovery_impl.rs b/discovery-handlers/onvif/src/discovery_impl.rs index 098cb6f0b..be3902f01 100644 --- a/discovery-handlers/onvif/src/discovery_impl.rs +++ b/discovery-handlers/onvif/src/discovery_impl.rs @@ -247,10 +247,7 @@ pub mod util { .filter_map(|r| match r { Ok(uri) => Some(uri), Err(e) => { - trace!( - "device not responding to date/time request with error {}", - e - ); + trace!("device not responding to date/time request with error {e}"); None } }) @@ -698,10 +695,7 @@ pub mod util { const MULTI_PORT: u16 = 3702; let multi_socket_addr = SocketAddr::new(IpAddr::V4(MULTI_IPV4_ADDR), MULTI_PORT); - trace!( - "get_discovery_response_socket - binding to: {:?}", - local_socket_addr - ); + trace!("get_discovery_response_socket - binding to: {local_socket_addr:?}"); let socket = UdpSocket::bind(local_socket_addr).await?; trace!( "get_discovery_response_socket - joining multicast: {:?} {:?}", @@ -741,32 +735,25 @@ pub mod util { Err(e) => match e.kind() { ErrorKind::WouldBlock | ErrorKind::TimedOut => { trace!( - "simple_onvif_discover - recv_from error ... continue collecting responses {:?}", - e + "simple_onvif_discover - recv_from error ... continue collecting responses {e:?}" ); } _ => { - error!("simple_onvif_discover - recv_from error: {:?}", e); + error!("simple_onvif_discover - recv_from error: {e:?}"); return Err(anyhow::anyhow!(e)); } }, } } - trace!( - "simple_onvif_discover - uris discovered by udp broadcast {:?}", - broadcast_responses - ); + trace!("simple_onvif_discover - uris discovered by udp broadcast {broadcast_responses:?}"); let filtered_uris = broadcast_responses .into_iter() .flat_map(|r| get_scope_filtered_uris_from_discovery_response(&r, scopes_filters)) .collect::>(); - trace!( - "simple_onvif_discover - uris after filtering by scopes {:?}", - filtered_uris - ); + trace!("simple_onvif_discover - uris after filtering by scopes {filtered_uris:?}"); let devices = get_responsive_uris(filtered_uris, &OnvifQueryImpl::default()).await; - info!("simple_onvif_discover - devices: {:?}", devices); + info!("simple_onvif_discover - devices: {devices:?}"); Ok(devices) } @@ -811,7 +798,7 @@ pub mod util { }); let wait_for_call_millis = timeout.as_secs() * 1000 + 200; - trace!("wait for {} milliseconds", wait_for_call_millis); + trace!("wait for {wait_for_call_millis} milliseconds"); std::thread::sleep(Duration::from_millis(wait_for_call_millis)); // validate that this ends in 2 seconds or less trace!("duration to test: {}", duration.lock().unwrap().as_millis()); diff --git a/discovery-handlers/onvif/src/discovery_utils.rs b/discovery-handlers/onvif/src/discovery_utils.rs index 31ed78474..0f95a91ab 100644 --- a/discovery-handlers/onvif/src/discovery_utils.rs +++ b/discovery-handlers/onvif/src/discovery_utils.rs @@ -122,10 +122,7 @@ impl HttpRequest { Ok(xml_as_tree) => xml_as_tree, Err(e) => return Err(Error::new(ErrorKind::InvalidData, e).into()), }; - trace!( - "handle_request_body - response as xmltree: {:?}", - xml_as_tree - ); + trace!("handle_request_body - response as xmltree: {xml_as_tree:?}"); Ok(xml_as_tree) } } @@ -182,7 +179,7 @@ impl Http for HttpRequest { /// Creates a SOAP mime action fn get_action(wsdl: &str, function: &str) -> String { - format!("action=\"{}/{}\"", wsdl, function) + format!("action=\"{wsdl}/{function}\"") } /// Gets the ip and mac address for a given ONVIF camera @@ -206,8 +203,7 @@ async fn inner_get_device_ip_and_mac_address( Ok(xml) => xml, Err(e) => { return Err(anyhow::format_err!( - "failed to get network interfaces from device: {:?}", - e + "failed to get network interfaces from device: {e:?}" )); } }; @@ -235,12 +231,9 @@ async fn inner_get_device_ip_and_mac_address( "Failed to get ONVIF ip address: unexpected type" )); } - Err(e) => return Err(anyhow::format_err!("Failed to get ONVIF ip address: {}", e)), + Err(e) => return Err(anyhow::format_err!("Failed to get ONVIF ip address: {e}")), }; - trace!( - "inner_get_device_ip_and_mac_address - network interfaces (ip address): {:?}", - ip_address - ); + trace!("inner_get_device_ip_and_mac_address - network interfaces (ip address): {ip_address:?}"); let mac_address = match sxd_xpath::evaluate_xpath( &network_interfaces_doc, "//*[local-name()='GetNetworkInterfacesResponse']/*[local-name()='NetworkInterfaces']/*[local-name()='Info']/*[local-name()='HwAddress']/text()", @@ -265,15 +258,11 @@ async fn inner_get_device_ip_and_mac_address( )); } Err(e) => { - return Err(anyhow::format_err!( - "Failed to get ONVIF mac address: {}", - e - )); + return Err(anyhow::format_err!("Failed to get ONVIF mac address: {e}")); } }; trace!( - "inner_get_device_ip_and_mac_address - network interfaces (mac address): {:?}", - mac_address + "inner_get_device_ip_and_mac_address - network interfaces (mac address): {mac_address:?}" ); Ok((ip_address, mac_address)) } @@ -312,13 +301,12 @@ fn get_network_interfaces_message(username_token: &Option) -> Str xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsdl="http://www.onvif.org/ver10/device/wsdl"> - {} + {security_header} -"#, - security_header +"# ) } @@ -339,29 +327,25 @@ async fn inner_get_device_service_uri( Ok(xml) => xml, Err(e) => { return Err(anyhow::format_err!( - "failed to get services from device: {:?}", - e + "failed to get services from device: {e:?}" )); } }; let services_doc = services_xml.as_document(); let service_xpath_query = format!( - "//*[local-name()='GetServicesResponse']/*[local-name()='Service' and *[local-name()='Namespace']/text() ='{}']/*[local-name()='XAddr']/text()", - service + "//*[local-name()='GetServicesResponse']/*[local-name()='Service' and *[local-name()='Namespace']/text() ='{service}']/*[local-name()='XAddr']/text()" ); let requested_device_service_uri = match sxd_xpath::evaluate_xpath(&services_doc, service_xpath_query.as_str()) { Ok(uri) => uri.string(), Err(e) => { return Err(anyhow::format_err!( - "failed to get servuce uri from resoinse: {:?}", - e + "failed to get servuce uri from resoinse: {e:?}" )); } }; trace!( - "inner_get_device_service_uri - service ({}) uris: {:?}", - service, requested_device_service_uri + "inner_get_device_service_uri - service ({service}) uris: {requested_device_service_uri:?}" ); Ok(requested_device_service_uri) } @@ -385,8 +369,7 @@ async fn inner_get_device_profiles( Ok(xml) => xml, Err(e) => { return Err(anyhow::format_err!( - "failed to get profiles from device: {:?}", - e + "failed to get profiles from device: {e:?}" )); } }; @@ -405,9 +388,9 @@ async fn inner_get_device_profiles( "Failed to get ONVIF profiles: unexpected type" )); } - Err(e) => return Err(anyhow::format_err!("Failed to get ONVIF profiles: {}", e)), + Err(e) => return Err(anyhow::format_err!("Failed to get ONVIF profiles: {e}")), }; - trace!("inner_get_device_profiles - profiles: {:?}", profiles); + trace!("inner_get_device_profiles - profiles: {profiles:?}"); Ok(profiles) } @@ -425,8 +408,7 @@ async fn inner_get_device_profile_streaming_uri( Ok(xml) => xml, Err(e) => { return Err(anyhow::format_err!( - "failed to get streaming uri from device: {:?}", - e + "failed to get streaming uri from device: {e:?}" )); } }; @@ -438,8 +420,7 @@ async fn inner_get_device_profile_streaming_uri( Ok(stream) => stream.string(), Err(e) => { return Err(anyhow::format_err!( - "failed to get service uri from response: {:?}", - e + "failed to get service uri from response: {e:?}" )); } }; @@ -470,11 +451,10 @@ fn get_stream_uri_message(profile: &str) -> String { RTSP - {} + {profile} -;"#, - profile +;"# ) } @@ -509,7 +489,7 @@ mod tests { let inner_mime = mime.to_string(); let inner_msg = msg.to_string(); let inner_output_xml = output_xml.to_string(); - trace!("mock.expect_post url:{}, mime:{}, msg:{}", url, mime, msg); + trace!("mock.expect_post url:{url}, mime:{mime}, msg:{msg}"); mock.expect_post() .times(1) .withf(move |actual_url, actual_mime, actual_msg| { @@ -640,11 +620,10 @@ mod tests { for (i, expected_uri) in expected_result.iter().enumerate().take(3) { let mut mock = MockHttp::new(); - let profile = format!("00{}", i).to_string(); + let profile = format!("00{i}").to_string(); let message = get_stream_uri_message(&profile); let response = format!( - "\nrtsp://192.168.{}.36:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_streamfalsefalsePT10S", - i + "\nrtsp://192.168.{i}.36:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_streamfalsefalsePT10S" ); configure_post( &mut mock, @@ -674,8 +653,7 @@ mod tests { // empty response since do not check contents only successful response let empty_response = ""; let response = format!( - "\n{}", - empty_response + "\n{empty_response}" ); let url = "test_inner_is_device_responding-url".to_string(); configure_post( diff --git a/discovery-handlers/onvif/src/username_token.rs b/discovery-handlers/onvif/src/username_token.rs index 3cbea0538..7ffd2ed13 100644 --- a/discovery-handlers/onvif/src/username_token.rs +++ b/discovery-handlers/onvif/src/username_token.rs @@ -16,7 +16,7 @@ impl UsernameToken { } fn generate_token(username: &str, password: &str, nonce: &str, created: &str) -> UsernameToken { - let concat = format!("{}{}{}", nonce, created, password); + let concat = format!("{nonce}{created}{password}"); let digest = { let mut hasher = sha1::Sha1::new(); hasher.update(concat.as_bytes()); diff --git a/discovery-handlers/opcua/src/discovery_handler.rs b/discovery-handlers/opcua/src/discovery_handler.rs index 4e6f12aa9..0b9cb9bf0 100644 --- a/discovery-handlers/opcua/src/discovery_handler.rs +++ b/discovery-handlers/opcua/src/discovery_handler.rs @@ -84,7 +84,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { mpsc::channel(DISCOVERED_DEVICES_CHANNEL_CAPACITY); let discovery_handler_config: OpcuaDiscoveryDetails = deserialize_discovery_details(&discover_request.discovery_details) - .map_err(|e| tonic::Status::new(tonic::Code::InvalidArgument, format!("{}", e)))?; + .map_err(|e| tonic::Status::new(tonic::Code::InvalidArgument, format!("{e}")))?; let mut previously_discovered_devices: Vec = Vec::new(); tokio::spawn(async move { let discovery_method = discovery_handler_config.opcua_discovery_method.clone(); @@ -116,10 +116,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { .into_iter() .map(|discovery_url| { let mut properties = std::collections::HashMap::new(); - trace!( - "discover - found OPC UA server at DiscoveryURL {}", - discovery_url - ); + trace!("discover - found OPC UA server at DiscoveryURL {discovery_url}"); properties .insert(OPCUA_DISCOVERY_URL_LABEL.to_string(), discovery_url.clone()); Device { @@ -151,8 +148,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { .await { error!( - "discover - for OPC UA failed to send discovery response with error {}", - e + "discover - for OPC UA failed to send discovery response with error {e}" ); if let Some(sender) = register_sender { sender.send(()).await.unwrap(); diff --git a/discovery-handlers/opcua/src/discovery_impl.rs b/discovery-handlers/opcua/src/discovery_impl.rs index f0af20d47..d4561151d 100644 --- a/discovery-handlers/opcua/src/discovery_impl.rs +++ b/discovery-handlers/opcua/src/discovery_impl.rs @@ -31,10 +31,7 @@ pub fn do_standard_discovery( discovery_urls: Vec, filter_list: Option, ) -> Vec { - info!( - "do_standard_discovery - for DiscoveryUrls {:?}", - discovery_urls - ); + info!("do_standard_discovery - for DiscoveryUrls {discovery_urls:?}"); let mut discovery_handler_client = create_opcua_discovery_client(); let tcp_stream = TcpStreamImpl {}; get_discovery_urls( @@ -61,8 +58,7 @@ fn get_discovery_urls( .for_each(|url| match test_tcp_connection(url, &tcp_stream) { Err(e) => { error!( - "get_discovery_urls - failed to make tcp connection with url {} with error {:?}", - url, e + "get_discovery_urls - failed to make tcp connection with url {url} with error {e:?}" ); } _ => { @@ -87,8 +83,7 @@ fn get_discovery_urls( } Err(err) => { trace!( - "get_discovery_urls - cannot find servers on discovery server. Error {:?}", - err + "get_discovery_urls - cannot find servers on discovery server. Error {err:?}" ); } }; @@ -109,7 +104,7 @@ fn test_tcp_connection(url: &str, tcp_stream: &impl TcpStream) -> Result<(), any Duration::from_secs(TCP_CONNECTION_TEST_TIMEOUT_SECS), ) { Ok(_stream) => Ok(()), - Err(e) => Err(anyhow::format_err!("{:?}", e)), + Err(e) => Err(anyhow::format_err!("{e:?}")), } } @@ -137,14 +132,13 @@ fn get_discovery_url_from_application_description( } else if !should_include(filter_list, server.application_name.text.as_ref()) { trace!( "get_discovery_url_from_application - Application {} has been filtered out by application name", - server.application_name.text.to_string() + server.application_name.text ); None } else if let Some(ref server_discovery_urls) = server.discovery_urls { // TODO: could two different DiscoveryUrls be registered as localhost: on different lds's? trace!( - "get_discovery_url_from_application - server has {:?} DiscoveryUrls", - server_discovery_urls + "get_discovery_url_from_application - server has {server_discovery_urls:?} DiscoveryUrls" ); // Pass the tcp DiscoveryURL by default, since it supports application authentication and // is more frequently utilized in OPC UA else pass first one @@ -160,8 +154,7 @@ fn get_discovery_url_from_application_description( Ok(discovery_url) => Some(discovery_url), Err(e) => { trace!( - "get_discovery_url_from_application - failed to resolve discovery url with error {:?}", - e + "get_discovery_url_from_application - failed to resolve discovery url with error {e:?}" ); None } @@ -180,8 +173,7 @@ fn get_socket_addr(url: &str) -> Result { let url = Url::parse(url).map_err(|_| anyhow::format_err!("could not parse url"))?; if url.scheme() != OPC_TCP_SCHEME { return Err(anyhow::format_err!( - "format of OPC UA url {} is not valid", - url + "format of OPC UA url {url} is not valid" )); } let host = url.host_str().unwrap(); @@ -190,7 +182,7 @@ fn get_socket_addr(url: &str) -> Result { .ok_or_else(|| anyhow::format_err!("provided discoveryURL is missing port"))?; // Convert host and port to socket address - let addr_str = format!("{}:{}", host, port); + let addr_str = format!("{host}:{port}"); let addrs = addr_str.to_socket_addrs(); let addr = addrs.unwrap().next().unwrap(); Ok(addr) @@ -206,15 +198,14 @@ fn get_discovery_url_ip( .with_context(|| "could not parse url {discovery_url_str}")?; if discovery_url.scheme() != OPC_TCP_SCHEME { return Err(anyhow::format_err!( - "format of OPC UA url {} is not valid", - discovery_url + "format of OPC UA url {discovery_url} is not valid" )); } let mut path = discovery_url.path().to_string(); let host = discovery_url.host_str().unwrap(); let port = discovery_url.port().unwrap_or(DEFAULT_OPC_UA_SERVER_PORT); - let addr_str = format!("{}:{}", host, port); + let addr_str = format!("{host}:{port}"); // check if the hostname can be resolved to socket address match addr_str.to_socket_addrs() { @@ -224,13 +215,12 @@ fn get_discovery_url_ip( path.remove(0); } let url = if ip_url.path() == "" || ip_url.path() == "/" { - format!("{}{}", ip_url, path) + format!("{ip_url}{path}") } else { ip_url_str.to_string() }; trace!( - "get_discovery_url_ip - cannot resolve the application url from server, using ip address instead of hostname: {}", - url + "get_discovery_url_ip - cannot resolve the application url from server, using ip address instead of hostname: {url}" ); Ok(url) } diff --git a/discovery-handlers/udev/src/discovery_handler.rs b/discovery-handlers/udev/src/discovery_handler.rs index a5b24c542..e1890e906 100644 --- a/discovery-handlers/udev/src/discovery_handler.rs +++ b/discovery-handlers/udev/src/discovery_handler.rs @@ -86,12 +86,12 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { mpsc::channel(DISCOVERED_DEVICES_CHANNEL_CAPACITY); let discovery_handler_config: UdevDiscoveryDetails = deserialize_discovery_details(&discover_request.discovery_details) - .map_err(|e| tonic::Status::new(tonic::Code::InvalidArgument, format!("{}", e)))?; + .map_err(|e| tonic::Status::new(tonic::Code::InvalidArgument, format!("{e}")))?; let mut previously_discovered_devices: Vec = Vec::new(); tokio::spawn(async move { let udev_rules = discovery_handler_config.udev_rules.clone(); loop { - trace!("discover - for udev rules {:?}", udev_rules); + trace!("discover - for udev rules {udev_rules:?}"); // Before each iteration, check if receiver has dropped if discovered_devices_sender.is_closed() { error!("discover - channel closed ... attempting to re-register with Agent"); @@ -112,10 +112,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { } } }); - trace!( - "discover - mapping and returning devices at devpaths {:?}", - devpaths - ); + trace!("discover - mapping and returning devices at devpaths {devpaths:?}"); let discovered_devices = devpaths .into_iter() .map(|(id, paths)| { @@ -124,7 +121,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { for (i, (_, node)) in paths.into_iter().enumerate() { let property_suffix = discovery_handler_config .group_recursive - .then(|| format!("_{}", i)) + .then(|| format!("_{i}")) .unwrap_or_default(); if let Some(devnode) = node { properties.insert( @@ -172,8 +169,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { .await { error!( - "discover - for udev failed to send discovery response with error {}", - e + "discover - for udev failed to send discovery response with error {e}" ); if let Some(sender) = register_sender { sender.send(()).await.unwrap(); diff --git a/discovery-handlers/udev/src/discovery_impl.rs b/discovery-handlers/udev/src/discovery_impl.rs index 742b3650b..e991fa87f 100644 --- a/discovery-handlers/udev/src/discovery_impl.rs +++ b/discovery-handlers/udev/src/discovery_impl.rs @@ -35,10 +35,7 @@ pub fn do_parse_and_find( ) -> Result, anyhow::Error> { let udev_filters = parse_udev_rule(udev_rule_string)?; let devices = find_devices(enumerator, udev_filters)?; - trace!( - "do_parse_and_find - returning discovered devices with devpaths: {:?}", - devices - ); + trace!("do_parse_and_find - returning discovered devices with devpaths: {devices:?}"); Ok(devices) } @@ -51,10 +48,7 @@ pub fn do_parse_and_find( /// will be ignored. /// Udev discovery is only interested in match fields, so all action fields, such as TEST, are ignored fn parse_udev_rule(udev_rule_string: &str) -> Result, anyhow::Error> { - info!( - "parse_udev_rule - enter for udev rule string {}", - udev_rule_string - ); + info!("parse_udev_rule - enter for udev rule string {udev_rule_string}"); let mut udev_filters: Vec = Vec::new(); // So long as parse succeeds, subsequent unwraps will not fails, since they are following the @@ -114,7 +108,7 @@ fn find_devices( udev_filters: Vec, ) -> std::io::Result> { let mut enumerator = enumerator; - trace!("find_devices - enter with udev_filters {:?}", udev_filters); + trace!("find_devices - enter with udev_filters {udev_filters:?}"); // Enumerator scans sys devices for its filters. Only certain filters can be applied to it. // Divide device fields by type of filter than can be applied to Enumerator, if any @@ -171,10 +165,7 @@ fn find_devices( /// This adds equality filters to the Enumerator fn filter_by_match_udev_filters(enumerator: &mut impl Enumerator, udev_filters: Vec<&UdevFilter>) { - trace!( - "enumerator_match_udev_filters - enter with udev_filters {:?}", - udev_filters - ); + trace!("enumerator_match_udev_filters - enter with udev_filters {udev_filters:?}"); for udev_filter in udev_filters { match udev_filter.field.as_rule() { Rule::devpath => { @@ -229,10 +220,7 @@ fn filter_by_nomatch_udev_filters( enumerator: &mut impl Enumerator, udev_filters: Vec<&UdevFilter>, ) { - trace!( - "enumerator_nomatch_udev_filters - enter with udev_filters {:?}", - udev_filters - ); + trace!("enumerator_nomatch_udev_filters - enter with udev_filters {udev_filters:?}"); for udev_filter in udev_filters { match udev_filter.field.as_rule() { Rule::attribute => { @@ -266,10 +254,7 @@ fn filter_by_remaining_udev_filters( devices: Vec, udev_filters: Vec<&UdevFilter>, ) -> Vec { - trace!( - "filter_by_remaining_udev_filters - enter with udev_filters {:?}", - udev_filters - ); + trace!("filter_by_remaining_udev_filters - enter with udev_filters {udev_filters:?}"); let mut mutable_devices = devices; for udev_filter in udev_filters { let value_regex = Regex::new(&udev_filter.value).unwrap(); diff --git a/discovery-utils/src/discovery/mod.rs b/discovery-utils/src/discovery/mod.rs index 69d880464..ef6c4ab24 100644 --- a/discovery-utils/src/discovery/mod.rs +++ b/discovery-utils/src/discovery/mod.rs @@ -41,7 +41,7 @@ pub mod discovery_handler { Ok(pod_ip) => { trace!("run_discovery_handler - registering with Agent with IP endpoint"); use_uds = false; - format!("{}:{}", pod_ip, DISCOVERY_PORT) + format!("{pod_ip}:{DISCOVERY_PORT}") } Err(_) => { trace!("run_discovery_handler - registering with Agent with uds endpoint"); @@ -86,8 +86,7 @@ pub mod discovery_handler { { let discovery_handler_config: T = serde_yaml::from_str(discovery_details).map_err(|e| { anyhow::format_err!( - "Configuration discovery details improperly configured with error {:?}", - e + "Configuration discovery details improperly configured with error {e:?}" ) })?; Ok(discovery_handler_config) diff --git a/discovery-utils/src/discovery/v0.rs b/discovery-utils/src/discovery/v0.rs index e691f1458..a20490c38 100644 --- a/discovery-utils/src/discovery/v0.rs +++ b/discovery-utils/src/discovery/v0.rs @@ -9,10 +9,7 @@ pub struct RegisterDiscoveryHandlerRequest { /// Endpoint for the registering `DiscoveryHandler` #[prost(string, tag = "2")] pub endpoint: ::prost::alloc::string::String, - #[prost( - enumeration = "register_discovery_handler_request::EndpointType", - tag = "3" - )] + #[prost(enumeration = "register_discovery_handler_request::EndpointType", tag = "3")] pub endpoint_type: i32, /// Specifies whether this device could be used by multiple nodes (e.g. an IP camera) /// or can only be ever be discovered by a single node (e.g. a local USB device) @@ -22,7 +19,17 @@ pub struct RegisterDiscoveryHandlerRequest { /// Nested message and enum types in `RegisterDiscoveryHandlerRequest`. pub mod register_discovery_handler_request { /// Specifies the type of endpoint. - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] #[repr(i32)] pub enum EndpointType { Uds = 0, @@ -68,7 +75,10 @@ pub struct DiscoverRequest { /// list of Key-value pairs containing additional information /// for the 'DiscoveryHandler' to discover devices #[prost(map = "string, message", tag = "2")] - pub discovery_properties: ::std::collections::HashMap<::prost::alloc::string::String, ByteData>, + pub discovery_properties: ::std::collections::HashMap< + ::prost::alloc::string::String, + ByteData, + >, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -87,8 +97,10 @@ pub struct Device { /// and set as environment variables in the device's broker Pods. May be information /// about where to find the device such as an RTSP URL or a device node (e.g. `/dev/video1`) #[prost(map = "string, string", tag = "2")] - pub properties: - ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + pub properties: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::string::String, + >, /// Optionally specify mounts for Pods that request this device as a resource #[prost(message, repeated, tag = "3")] pub mounts: ::prost::alloc::vec::Vec, @@ -133,8 +145,8 @@ pub struct DeviceSpec { /// Generated client implementations. pub mod registration_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; /// Registration is the service advertised by the Akri Agent. /// Any `DiscoveryHandler` can register with the Akri Agent. #[derive(Debug, Clone)] @@ -175,13 +187,14 @@ pub mod registration_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, + http::Request, + Response = http::Response< + >::ResponseBody, >, - >>::Error: - Into + Send + Sync, + >, + , + >>::Error: Into + Send + Sync, { RegistrationClient::new(InterceptedService::new(inner, interceptor)) } @@ -220,20 +233,22 @@ pub mod registration_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/v0.Registration/RegisterDiscoveryHandler"); + let path = http::uri::PathAndQuery::from_static( + "/v0.Registration/RegisterDiscoveryHandler", + ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new( - "v0.Registration", - "RegisterDiscoveryHandler", - )); + req.extensions_mut() + .insert(GrpcMethod::new("v0.Registration", "RegisterDiscoveryHandler")); self.inner.unary(req, path, codec).await } } @@ -241,8 +256,8 @@ pub mod registration_client { /// Generated client implementations. pub mod discovery_handler_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct DiscoveryHandlerClient { inner: tonic::client::Grpc, @@ -281,13 +296,14 @@ pub mod discovery_handler_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, + http::Request, + Response = http::Response< + >::ResponseBody, >, - >>::Error: - Into + Send + Sync, + >, + , + >>::Error: Into + Send + Sync, { DiscoveryHandlerClient::new(InterceptedService::new(inner, interceptor)) } @@ -329,14 +345,19 @@ pub mod discovery_handler_client { tonic::Response>, tonic::Status, > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v0.DiscoveryHandler/Discover"); + let path = http::uri::PathAndQuery::from_static( + "/v0.DiscoveryHandler/Discover", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v0.DiscoveryHandler", "Discover")); @@ -381,7 +402,10 @@ pub mod registration_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -437,19 +461,27 @@ pub mod registration_server { "/v0.Registration/RegisterDiscoveryHandler" => { #[allow(non_camel_case_types)] struct RegisterDiscoveryHandlerSvc(pub Arc); - impl - tonic::server::UnaryService - for RegisterDiscoveryHandlerSvc - { + impl< + T: Registration, + > tonic::server::UnaryService + for RegisterDiscoveryHandlerSvc { type Response = super::Empty; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, - request: tonic::Request, + request: tonic::Request< + super::RegisterDiscoveryHandlerRequest, + >, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::register_discovery_handler(&inner, request) + ::register_discovery_handler( + &inner, + request, + ) .await }; Box::pin(fut) @@ -478,14 +510,18 @@ pub mod registration_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } @@ -525,7 +561,8 @@ pub mod discovery_handler_server { /// Server streaming response type for the Discover method. type DiscoverStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, - > + Send + > + + Send + 'static; async fn discover( &self, @@ -555,7 +592,10 @@ pub mod discovery_handler_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -611,14 +651,16 @@ pub mod discovery_handler_server { "/v0.DiscoveryHandler/Discover" => { #[allow(non_camel_case_types)] struct DiscoverSvc(pub Arc); - impl - tonic::server::ServerStreamingService - for DiscoverSvc - { + impl< + T: DiscoveryHandler, + > tonic::server::ServerStreamingService + for DiscoverSvc { type Response = super::DiscoverResponse; type ResponseStream = T::DiscoverStream; - type Future = - BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -653,14 +695,18 @@ pub mod discovery_handler_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } diff --git a/samples/brokers/udev-video-broker/src/main.rs b/samples/brokers/udev-video-broker/src/main.rs index 6b9890940..8dedcfe2d 100644 --- a/samples/brokers/udev-video-broker/src/main.rs +++ b/samples/brokers/udev-video-broker/src/main.rs @@ -22,13 +22,10 @@ pub const UDEV_DEVNODE_LABEL_ID_PATTERN: &str = "UDEV_DEVNODE_[A-F0-9]{6,6}$"; #[tokio::main] async fn main() -> Result<(), Box> { - println!("{} udev_broker ... env_logger::init", API_NAMESPACE); + println!("{API_NAMESPACE} udev_broker ... env_logger::init"); env_logger::try_init().unwrap(); - println!( - "{} udev_broker ... env_logger::init finished", - API_NAMESPACE - ); - info!("{} Udev Broker logging started", API_NAMESPACE); + println!("{API_NAMESPACE} udev_broker ... env_logger::init finished"); + info!("{API_NAMESPACE} Udev Broker logging started"); tokio::spawn(async move { run_metrics_server().await.unwrap(); @@ -73,7 +70,7 @@ fn get_video_devnode(env_var_query: &impl EnvVarQuery) -> String { .first() .expect("devnode not set in environment variable"); - trace!("get_video_devnode - found devnode {}", device_devnode); + trace!("get_video_devnode - found devnode {device_devnode}"); device_devnode.to_string() } diff --git a/samples/brokers/udev-video-broker/src/util/camera.rs b/samples/brokers/udev-video-broker/src/util/camera.rs index a1ee7fe5d..4bd208251 100644 --- a/samples/brokers/udev-video-broker/src/util/camera.rs +++ b/samples/brokers/udev-video-broker/src/util/camera.rs @@ -13,8 +13,8 @@ pub struct NotifyResponse { /// Generated client implementations. pub mod camera_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct CameraClient { inner: tonic::client::Grpc, @@ -53,13 +53,14 @@ pub mod camera_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, + http::Request, + Response = http::Response< + >::ResponseBody, >, - >>::Error: - Into + Send + Sync, + >, + , + >>::Error: Into + Send + Sync, { CameraClient::new(InterceptedService::new(inner, interceptor)) } @@ -98,17 +99,19 @@ pub mod camera_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/camera.Camera/GetFrame"); let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("camera.Camera", "GetFrame")); + req.extensions_mut().insert(GrpcMethod::new("camera.Camera", "GetFrame")); self.inner.unary(req, path, codec).await } } @@ -148,7 +151,10 @@ pub mod camera_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -204,16 +210,21 @@ pub mod camera_server { "/camera.Camera/GetFrame" => { #[allow(non_camel_case_types)] struct GetFrameSvc(pub Arc); - impl tonic::server::UnaryService for GetFrameSvc { + impl tonic::server::UnaryService + for GetFrameSvc { type Response = super::NotifyResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::get_frame(&inner, request).await }; + let fut = async move { + ::get_frame(&inner, request).await + }; Box::pin(fut) } } @@ -240,14 +251,18 @@ pub mod camera_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } diff --git a/samples/brokers/udev-video-broker/src/util/camera_capturer.rs b/samples/brokers/udev-video-broker/src/util/camera_capturer.rs index 75f7defd0..e3e2290e5 100644 --- a/samples/brokers/udev-video-broker/src/util/camera_capturer.rs +++ b/samples/brokers/udev-video-broker/src/util/camera_capturer.rs @@ -63,10 +63,7 @@ fn get_format(env_var_query: &impl EnvVarQuery, format_options: Vec) -> let format_to_find = match env_var_query.get_env_var(FORMAT) { Ok(format) => format, Err(_) => { - trace!( - "get_format - format not set ... trying to use {:?}", - DEFAULT_FORMAT - ); + trace!("get_format - format not set ... trying to use {DEFAULT_FORMAT:?}"); DEFAULT_FORMAT.to_string() } }; @@ -79,11 +76,11 @@ fn get_format(env_var_query: &impl EnvVarQuery, format_options: Vec) -> ); format_options[0].clone() } else { - trace!("get_format - using default {:?} format", DEFAULT_FORMAT); + trace!("get_format - using default {DEFAULT_FORMAT:?} format"); DEFAULT_FORMAT.to_string() } } else { - trace!("get_format - using {:?} format", format_to_find); + trace!("get_format - using {format_to_find:?} format"); format_to_find } } @@ -109,7 +106,7 @@ fn get_interval(env_var_query: &impl EnvVarQuery, interval_info: rscam::Interval ); interval_options[0] } else { - trace!("get_interval - using {:?} interval", interval_to_validate); + trace!("get_interval - using {interval_to_validate:?} interval"); interval_to_validate } } @@ -158,10 +155,7 @@ fn get_resolution( ); resolution_options[0] } else { - trace!( - "get_resolution - using resolution {:?}", - resolution_to_validate - ); + trace!("get_resolution - using resolution {resolution_to_validate:?}"); resolution_to_validate } } diff --git a/samples/brokers/udev-video-broker/src/util/camera_service.rs b/samples/brokers/udev-video-broker/src/util/camera_service.rs index cd905377c..0bb059a6c 100644 --- a/samples/brokers/udev-video-broker/src/util/camera_service.rs +++ b/samples/brokers/udev-video-broker/src/util/camera_service.rs @@ -51,11 +51,11 @@ pub async fn serve(devnode: &str, camera_capturer: RsCamera) -> Result<(), Strin }; let service = CameraServer::new(camera_service); - let addr_str = format!("{}:{}", CAMERA_SERVICE_SERVER_ADDRESS, CAMERA_SERVICE_PORT); + let addr_str = format!("{CAMERA_SERVICE_SERVER_ADDRESS}:{CAMERA_SERVICE_PORT}"); let addr: SocketAddr = match addr_str.parse() { Ok(sock) => sock, Err(e) => { - return Err(format!("Unable to parse socket: {:?}", e)); + return Err(format!("Unable to parse socket: {e:?}")); } }; @@ -87,17 +87,15 @@ pub async fn serve(devnode: &str, camera_capturer: RsCamera) -> Result<(), Strin < start_plus_10) && !connected { - let client_addr_str = format!( - "http://{}:{}", - CAMERA_SERVICE_TEST_LOCALHOST, CAMERA_SERVICE_PORT - ); + let client_addr_str = + format!("http://{CAMERA_SERVICE_TEST_LOCALHOST}:{CAMERA_SERVICE_PORT}"); connected = match CameraClient::connect(client_addr_str).await { Ok(_) => { trace!("Connected to server, stop polling"); true } Err(e) => { - trace!("Unable to connect to server, continue polling: {:?}", e); + trace!("Unable to connect to server, continue polling: {e:?}"); tokio::time::sleep(Duration::from_secs(1)).await; false } diff --git a/shared/src/akri/configuration.rs b/shared/src/akri/configuration.rs index 353cde120..92f0d0879 100644 --- a/shared/src/akri/configuration.rs +++ b/shared/src/akri/configuration.rs @@ -186,14 +186,11 @@ pub async fn get_configurations(kube_client: &Client) -> Result { - log::trace!( - "get_configurations kube_client.request returned kube error: {:?}", - ae - ); + log::trace!("get_configurations kube_client.request returned kube error: {ae:?}"); Err(ae.into()) } Err(e) => { - log::trace!("get_configurations kube_client.request error: {:?}", e); + log::trace!("get_configurations kube_client.request error: {e:?}"); Err(e.into()) } } @@ -225,7 +222,7 @@ pub async fn find_configuration( log::trace!("find_configuration enter"); let configurations_client: Api = Api::namespaced(kube_client.clone(), namespace); - log::trace!("find_configuration getting instance with name {}", name); + log::trace!("find_configuration getting instance with name {name}"); match configurations_client.get(name).await { Ok(configuration_retrieved) => { @@ -234,14 +231,11 @@ pub async fn find_configuration( } Err(e) => match e { kube::Error::Api(ae) => { - log::trace!( - "find_configuration kube_client.request returned kube error: {:?}", - ae - ); + log::trace!("find_configuration kube_client.request returned kube error: {ae:?}"); Err(anyhow::anyhow!(ae)) } _ => { - log::trace!("find_configuration kube_client.request error: {:?}", e); + log::trace!("find_configuration kube_client.request error: {e:?}"); Err(anyhow::anyhow!(e)) } }, diff --git a/shared/src/akri/instance.rs b/shared/src/akri/instance.rs index 01a3ec982..e2762a755 100644 --- a/shared/src/akri/instance.rs +++ b/shared/src/akri/instance.rs @@ -133,14 +133,11 @@ pub async fn get_instances(kube_client: &Client) -> Result { - log::trace!( - "get_instances kube_client.request returned kube error: {:?}", - ae - ); + log::trace!("get_instances kube_client.request returned kube error: {ae:?}"); Err(ae.into()) } Err(e) => { - log::trace!("get_instances kube_client.request error: {:?}", e); + log::trace!("get_instances kube_client.request error: {e:?}"); Err(e.into()) } } @@ -172,7 +169,7 @@ pub async fn find_instance( log::trace!("find_instance enter"); let instances_client: Api = Api::namespaced(kube_client.clone(), namespace); - log::trace!("find_instance getting instance with name {}", name); + log::trace!("find_instance getting instance with name {name}"); match instances_client.get(name).await { Ok(instance_retrieved) => { @@ -181,14 +178,11 @@ pub async fn find_instance( } Err(e) => match e { kube::Error::Api(ae) => { - log::trace!( - "find_instance kube_client.request returned kube error: {:?}", - ae - ); + log::trace!("find_instance kube_client.request returned kube error: {ae:?}"); Err(anyhow::anyhow!(ae)) } _ => { - log::trace!("find_instance kube_client.request error: {:?}", e); + log::trace!("find_instance kube_client.request error: {e:?}"); Err(anyhow::anyhow!(e)) } }, @@ -240,7 +234,7 @@ pub async fn create_instance( instance.metadata = ObjectMeta { name: Some(name.to_string()), owner_references: Some(vec![OwnerReference { - api_version: format!("{}/{}", API_NAMESPACE, API_VERSION), + api_version: format!("{API_NAMESPACE}/{API_VERSION}"), kind: "Configuration".to_string(), controller: Some(true), block_owner_deletion: Some(true), @@ -258,14 +252,11 @@ pub async fn create_instance( Ok(()) } Err(kube::Error::Api(ae)) => { - log::trace!( - "create_instance kube_client.request returned kube error: {:?}", - ae - ); + log::trace!("create_instance kube_client.request returned kube error: {ae:?}"); Err(ae.into()) } Err(e) => { - log::trace!("create_instance kube_client.request error: {:?}", e); + log::trace!("create_instance kube_client.request error: {e:?}"); Err(e.into()) } } @@ -304,14 +295,11 @@ pub async fn delete_instance( Ok(()) } Err(kube::Error::Api(ae)) => { - log::trace!( - "delete_instance kube_client.request returned kube error: {:?}", - ae - ); + log::trace!("delete_instance kube_client.request returned kube error: {ae:?}"); Err(ae.into()) } Err(e) => { - log::trace!("delete_instance kube_client.request error: {:?}", e); + log::trace!("delete_instance kube_client.request error: {e:?}"); Err(e.into()) } } @@ -367,14 +355,11 @@ pub async fn update_instance( Ok(()) } Err(kube::Error::Api(ae)) => { - log::trace!( - "update_instance kube_client.request returned kube error: {:?}", - ae - ); + log::trace!("update_instance kube_client.request returned kube error: {ae:?}"); Err(ae.into()) } Err(e) => { - log::trace!("update_instance kube_client.request error: {:?}", e); + log::trace!("update_instance kube_client.request error: {e:?}"); Err(e.into()) } } @@ -451,8 +436,7 @@ pub mod device_usage { DeviceUsageKind::Free => { if !node_name.is_empty() { return Err(anyhow::anyhow!( - "Invalid input parameter, node name: {} provided for free node usage", - node_name + "Invalid input parameter, node name: {node_name} provided for free node usage" )); }; } diff --git a/shared/src/akri/metrics.rs b/shared/src/akri/metrics.rs index 5d15472a4..4ce9a1578 100644 --- a/shared/src/akri/metrics.rs +++ b/shared/src/akri/metrics.rs @@ -28,7 +28,7 @@ pub async fn run_metrics_server() -> Result<(), Box p.parse::()?, Err(_) => 8080, }; - info!("starting metrics server on port {} at /metrics", port); + info!("starting metrics server on port {port} at /metrics"); let metrics_route = warp::path!("metrics").and_then(metrics_handler); warp::serve(metrics_route).run(([0, 0, 0, 0], port)).await; Ok(()) diff --git a/shared/src/k8s/api.rs b/shared/src/k8s/api.rs index b5cb51f7d..94613fdc8 100644 --- a/shared/src/k8s/api.rs +++ b/shared/src/k8s/api.rs @@ -31,12 +31,12 @@ pub trait Api: Send + Sync { self.set_finalizers( &obj.name_any(), Some(vec![finalizer.to_string()]), - &format!("{}-fin", finalizer), + &format!("{finalizer}-fin"), ) .await } async fn remove_finalizer(&self, obj: &T, finalizer: &str) -> Result<(), Error> { - self.set_finalizers(&obj.name_any(), None, &format!("{}-fin", finalizer)) + self.set_finalizers(&obj.name_any(), None, &format!("{finalizer}-fin")) .await } async fn set_finalizers( diff --git a/shared/src/k8s/job.rs b/shared/src/k8s/job.rs index 7f5d0a136..ddff6e91d 100644 --- a/shared/src/k8s/job.rs +++ b/shared/src/k8s/job.rs @@ -479,7 +479,7 @@ mod broker_jobspec_tests { .kind ); assert_eq!( - format!("{}/{}", API_NAMESPACE, API_VERSION), + format!("{API_NAMESPACE}/{API_VERSION}"), job.metadata .owner_references .as_ref() diff --git a/shared/src/k8s/mod.rs b/shared/src/k8s/mod.rs index bca384aa4..7d64b8bc4 100644 --- a/shared/src/k8s/mod.rs +++ b/shared/src/k8s/mod.rs @@ -54,7 +54,7 @@ impl OwnershipInfo { pub fn get_api_version(&self) -> String { match self.object_type { OwnershipType::Instance | OwnershipType::Configuration => { - format!("{}/{}", API_NAMESPACE, API_VERSION) + format!("{API_NAMESPACE}/{API_VERSION}") } OwnershipType::Pod | OwnershipType::Service => "core/v1".to_string(), } @@ -612,15 +612,14 @@ pub async fn try_delete_instance( .await { Ok(()) => { - log::trace!("try_delete_instance - deleted Instance {}", instance_name); + log::trace!("try_delete_instance - deleted Instance {instance_name}"); break; } Err(e) => { if let Some(ae) = e.downcast_ref::() { if ae.code == ERROR_NOT_FOUND { log::trace!( - "try_delete_instance - discovered Instance {} already deleted", - instance_name + "try_delete_instance - discovered Instance {instance_name} already deleted" ); break; } @@ -702,7 +701,7 @@ pub mod test_ownership { uid.to_string(), ); assert_eq!( - format!("{}/{}", API_NAMESPACE, API_VERSION), + format!("{API_NAMESPACE}/{API_VERSION}"), ownership.get_api_version() ); assert_eq!("Configuration", &ownership.get_kind()); @@ -718,7 +717,7 @@ pub mod test_ownership { let ownership = OwnershipInfo::new(OwnershipType::Instance, name.to_string(), uid.to_string()); assert_eq!( - format!("{}/{}", API_NAMESPACE, API_VERSION), + format!("{API_NAMESPACE}/{API_VERSION}"), ownership.get_api_version() ); assert_eq!("Instance", &ownership.get_kind()); diff --git a/shared/src/k8s/node.rs b/shared/src/k8s/node.rs index 4f7f518fb..75f0acb67 100644 --- a/shared/src/k8s/node.rs +++ b/shared/src/k8s/node.rs @@ -19,7 +19,7 @@ use log::trace; /// # } /// ``` pub async fn find_node(name: &str, kube_client: Client) -> Result { - trace!("find_node with name={}", name); + trace!("find_node with name={name}"); let nodes: Api = Api::all(kube_client); trace!("find_node PRE nodes.get(...).await?"); let result = nodes.get(name).await; diff --git a/shared/src/k8s/pod.rs b/shared/src/k8s/pod.rs index 0cd8865a5..5a672a6e6 100644 --- a/shared/src/k8s/pod.rs +++ b/shared/src/k8s/pod.rs @@ -101,13 +101,13 @@ pub fn create_broker_app_name( // node-specific content. To ensure uniqueness of the Pod/Job we are creating, // prepend the node name here. match node_to_run_broker_on { - Some(n) => format!("{}-{}-{}", n, normalized_instance_name, app_name_suffix), - None => format!("{}-{}", normalized_instance_name, app_name_suffix), + Some(n) => format!("{n}-{normalized_instance_name}-{app_name_suffix}"), + None => format!("{normalized_instance_name}-{app_name_suffix}"), } } else { // If the device capability is NOT shared, the instance name will contain // node-specific content, which guarantees uniqueness. - format!("{}-{}", normalized_instance_name, app_name_suffix) + format!("{normalized_instance_name}-{app_name_suffix}") } } @@ -684,7 +684,7 @@ mod broker_podspec_tests { .kind ); assert_eq!( - &format!("{}/{}", API_NAMESPACE, API_VERSION), + &format!("{API_NAMESPACE}/{API_VERSION}"), &pod.metadata .clone() .owner_references diff --git a/shared/src/k8s/service.rs b/shared/src/k8s/service.rs index c10b23907..7a56fc3a8 100644 --- a/shared/src/k8s/service.rs +++ b/shared/src/k8s/service.rs @@ -72,10 +72,10 @@ pub fn create_service_app_name( if node_specific_svc { // If this is the node specific service, use the insrtance name which // contains node-specific content. - format!("{}-{}", normalized_instance_name, svc_suffix) + format!("{normalized_instance_name}-{svc_suffix}") } else { // If this is NOT the node specific service, use the capability name. - format!("{}-{}", configuration_name, svc_suffix) + format!("{configuration_name}-{svc_suffix}") } } @@ -399,14 +399,11 @@ pub async fn update_service( Ok(()) } Err(kube::Error::Api(ae)) => { - log::trace!( - "update_service kube_client.request returned kube error: {:?}", - ae - ); + log::trace!("update_service kube_client.request returned kube error: {ae:?}"); Err(anyhow::anyhow!(ae)) } Err(e) => { - log::trace!("update_service kube_client.request error: {:?}", e); + log::trace!("update_service kube_client.request error: {e:?}"); Err(anyhow::anyhow!(e)) } } diff --git a/webhooks/validating/configuration/src/main.rs b/webhooks/validating/configuration/src/main.rs index d1808e572..144e53b16 100644 --- a/webhooks/validating/configuration/src/main.rs +++ b/webhooks/validating/configuration/src/main.rs @@ -28,10 +28,9 @@ fn check( serde_json::Value::Object(o) => { for (key, value) in o { if let Err(e) = check(value, &deserialized[key]) { - return Err(None.ok_or(format!( - "input key ({:?}) not equal to parsed: ({:?})", - key, e - ))?); + return Err( + None.ok_or(format!("input key ({key:?}) not equal to parsed: ({e:?})"))? + ); } } Ok(()) @@ -40,8 +39,7 @@ fn check( for (pos, _e) in s.iter().enumerate() { if let Err(e) = check(&s[pos], &deserialized[pos]) { return Err(None.ok_or(format!( - "input index ({:?}) not equal to parsed: ({:?})", - pos, e + "input index ({pos:?}) not equal to parsed: ({e:?})" ))?); } } @@ -50,47 +48,43 @@ fn check( serde_json::Value::String(s) => match deserialized { serde_json::Value::String(ds) => { if s != ds { - Err(None.ok_or(format!("input ({:?}) not equal to parsed ({:?})", s, ds))?) + Err(None.ok_or(format!("input ({s:?}) not equal to parsed ({ds:?})"))?) } else { Ok(()) } } _ => Err(None.ok_or(format!( - "input ({:?}) not equal to parsed ({:?})", - s, deserialized + "input ({s:?}) not equal to parsed ({deserialized:?})" ))?), }, serde_json::Value::Bool(b) => match deserialized { serde_json::Value::Bool(db) => { if b != db { - Err(None.ok_or(format!("input ({:?}) not equal to parsed ({:?})", b, db))?) + Err(None.ok_or(format!("input ({b:?}) not equal to parsed ({db:?})"))?) } else { Ok(()) } } _ => Err(None.ok_or(format!( - "input ({:?}) not equal to parsed ({:?})", - b, deserialized + "input ({b:?}) not equal to parsed ({deserialized:?})" ))?), }, serde_json::Value::Number(n) => match deserialized { serde_json::Value::Number(dn) => { if n != dn { - Err(None.ok_or(format!("input ({:?}) not equal to parsed ({:?})", n, dn))?) + Err(None.ok_or(format!("input ({n:?}) not equal to parsed ({dn:?})"))?) } else { Ok(()) } } _ => Err(None.ok_or(format!( - "input ({:?}) not equal to parsed ({:?})", - n, deserialized + "input ({n:?}) not equal to parsed ({deserialized:?})" ))?), }, serde_json::Value::Null => match deserialized { serde_json::Value::Null => Ok(()), _ => Err(None.ok_or(format!( - "input (Null) not equal to parsed ({:?})", - deserialized + "input (Null) not equal to parsed ({deserialized:?})" ))?), }, } @@ -119,15 +113,9 @@ fn validate_configuration(rqst: &AdmissionRequest) -> AdmissionResponse { serde_json::from_str(y.as_str()).expect("Could not parse as Akri Configuration"); let reserialized = serde_json::to_string(&config).unwrap(); let deserialized: Value = serde_json::from_str(&reserialized).expect("untyped JSON"); - println!( - "validate_configuration - deserialized Configuration: {:?}", - deserialized - ); + println!("validate_configuration - deserialized Configuration: {deserialized:?}"); let val: Value = filter_configuration(raw.clone()); - println!( - "validate_configuration - expected deserialized format: {:?}", - val - ); + println!("validate_configuration - expected deserialized format: {val:?}"); // Do they match? match check(&val, &deserialized) { @@ -234,8 +222,8 @@ async fn main() -> std::io::Result<()> { .get_one::("port") .expect("valid port [0-65535]"); - let endpoint = format!("0.0.0.0:{}", port); - println!("Started Webhook server: {}", endpoint); + let endpoint = format!("0.0.0.0:{port}"); + println!("Started Webhook server: {endpoint}"); let builder = get_builder(key_file, crt_file); HttpServer::new(|| App::new().service(validate)) @@ -610,7 +598,7 @@ mod tests { fn get_invalid_admission_review_with_broker_job_and_pod_spec() -> String { let invalid_setting_both_broker_job_and_pod = - format!("{},\n{}", VALID_BROKER_JOB_SPEC, VALID_BROKER_POD_SPEC); + format!("{VALID_BROKER_JOB_SPEC},\n{VALID_BROKER_POD_SPEC}"); ADMISSION_REVIEW.replace( BROKER_SPEC_INSERTION_KEYWORD, &invalid_setting_both_broker_job_and_pod, From a03353e11865211d2418903d9fa1413cbe737aa7 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 14:43:32 +0100 Subject: [PATCH 14/19] chore(workflows): update toolchain to 1.88 Signed-off-by: Gaurav Gahlot --- .github/workflows/check-rust.yml | 2 +- .github/workflows/run-tarpaulin.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index c50cc91ea..14ee638a1 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.82.0 + toolchain: 1.88.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 d59b74387..ef29f367b 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.82.0 + CARGO_VERSION: 1.88.0 jobs: build: From 9f1e73a1e9c7ae9117833a454c099df59d45269e Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 14:45:34 +0100 Subject: [PATCH 15/19] style: more cargo fmt fixes Signed-off-by: Gaurav Gahlot --- agent/src/plugin_manager/v1.rs | 139 +++---- agent/src/plugin_manager/v1beta1.rs | 377 ++++++------------ discovery-utils/src/discovery/v0.rs | 192 ++++----- .../udev-video-broker/src/util/camera.rs | 71 ++-- 4 files changed, 282 insertions(+), 497 deletions(-) diff --git a/agent/src/plugin_manager/v1.rs b/agent/src/plugin_manager/v1.rs index c255210b7..c93bf05dc 100644 --- a/agent/src/plugin_manager/v1.rs +++ b/agent/src/plugin_manager/v1.rs @@ -87,8 +87,8 @@ pub struct NumaNode { /// Generated client implementations. pub mod pod_resources_lister_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; /// PodResourcesLister is a service provided by the kubelet that provides information about the /// node resources consumed by pods and containers on the node #[derive(Debug, Clone)] @@ -129,14 +129,13 @@ pub mod pod_resources_lister_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { PodResourcesListerClient::new(InterceptedService::new(inner, interceptor)) } @@ -174,23 +173,16 @@ pub mod pod_resources_lister_client { pub async fn list( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1.PodResourcesLister/List", - ); + let path = http::uri::PathAndQuery::from_static("/v1.PodResourcesLister/List"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1.PodResourcesLister", "List")); @@ -199,28 +191,23 @@ pub mod pod_resources_lister_client { pub async fn get_allocatable_resources( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1.PodResourcesLister/GetAllocatableResources", ); let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new("v1.PodResourcesLister", "GetAllocatableResources"), - ); + req.extensions_mut().insert(GrpcMethod::new( + "v1.PodResourcesLister", + "GetAllocatableResources", + )); self.inner.unary(req, path, codec).await } } @@ -235,17 +222,11 @@ pub mod pod_resources_lister_server { async fn list( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_allocatable_resources( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; } /// PodResourcesLister is a service provided by the kubelet that provides information about the /// node resources consumed by pods and containers on the node @@ -272,10 +253,7 @@ pub mod pod_resources_lister_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -331,15 +309,11 @@ pub mod pod_resources_lister_server { "/v1.PodResourcesLister/List" => { #[allow(non_camel_case_types)] struct ListSvc(pub Arc); - impl< - T: PodResourcesLister, - > tonic::server::UnaryService - for ListSvc { + impl + tonic::server::UnaryService for ListSvc + { type Response = super::ListPodResourcesResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, @@ -377,15 +351,12 @@ pub mod pod_resources_lister_server { "/v1.PodResourcesLister/GetAllocatableResources" => { #[allow(non_camel_case_types)] struct GetAllocatableResourcesSvc(pub Arc); - impl< - T: PodResourcesLister, - > tonic::server::UnaryService - for GetAllocatableResourcesSvc { + impl + tonic::server::UnaryService + for GetAllocatableResourcesSvc + { type Response = super::AllocatableResourcesResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, @@ -393,10 +364,9 @@ pub mod pod_resources_lister_server { let inner = Arc::clone(&self.0); let fut = async move { ::get_allocatable_resources( - &inner, - request, - ) - .await + &inner, request, + ) + .await }; Box::pin(fut) } @@ -424,18 +394,14 @@ pub mod pod_resources_lister_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } @@ -461,8 +427,7 @@ pub mod pod_resources_lister_server { write!(f, "{:?}", self.0) } } - impl tonic::server::NamedService - for PodResourcesListerServer { + impl tonic::server::NamedService for PodResourcesListerServer { const NAME: &'static str = "v1.PodResourcesLister"; } } diff --git a/agent/src/plugin_manager/v1beta1.rs b/agent/src/plugin_manager/v1beta1.rs index 2f6dd0fb0..e728044e6 100644 --- a/agent/src/plugin_manager/v1beta1.rs +++ b/agent/src/plugin_manager/v1beta1.rs @@ -96,9 +96,7 @@ pub struct PreStartContainerResponse {} #[derive(Clone, PartialEq, ::prost::Message)] pub struct PreferredAllocationRequest { #[prost(message, repeated, tag = "1")] - pub container_requests: ::prost::alloc::vec::Vec< - ContainerPreferredAllocationRequest, - >, + pub container_requests: ::prost::alloc::vec::Vec, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -108,9 +106,7 @@ pub struct ContainerPreferredAllocationRequest { pub available_device_i_ds: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, /// List of deviceIDs that must be included in the preferred allocation #[prost(string, repeated, tag = "2")] - pub must_include_device_i_ds: ::prost::alloc::vec::Vec< - ::prost::alloc::string::String, - >, + pub must_include_device_i_ds: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, /// Number of devices to include in the preferred allocation #[prost(int32, tag = "3")] pub allocation_size: i32, @@ -121,9 +117,7 @@ pub struct ContainerPreferredAllocationRequest { #[derive(Clone, PartialEq, ::prost::Message)] pub struct PreferredAllocationResponse { #[prost(message, repeated, tag = "1")] - pub container_responses: ::prost::alloc::vec::Vec< - ContainerPreferredAllocationResponse, - >, + pub container_responses: ::prost::alloc::vec::Vec, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -168,10 +162,8 @@ pub struct AllocateResponse { pub struct ContainerAllocateResponse { /// List of environment variable to be set in the container to access one of more devices. #[prost(map = "string, string", tag = "1")] - pub envs: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub envs: + ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, /// Mounts for the container. #[prost(message, repeated, tag = "2")] pub mounts: ::prost::alloc::vec::Vec, @@ -180,10 +172,8 @@ pub struct ContainerAllocateResponse { pub devices: ::prost::alloc::vec::Vec, /// Container annotations to pass to the container runtime #[prost(map = "string, string", tag = "4")] - pub annotations: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub annotations: + ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, } /// Mount specifies a host volume to mount into a container. /// where device library or tools are installed on host and container @@ -220,8 +210,8 @@ pub struct DeviceSpec { /// Generated client implementations. pub mod registration_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; /// Registration is the service advertised by the Kubelet /// Only when Kubelet answers with a success code to a Register Request /// may Device Plugins start their service @@ -266,14 +256,13 @@ pub mod registration_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { RegistrationClient::new(InterceptedService::new(inner, interceptor)) } @@ -312,19 +301,14 @@ pub mod registration_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1beta1.Registration/Register", - ); + let path = http::uri::PathAndQuery::from_static("/v1beta1.Registration/Register"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.Registration", "Register")); @@ -335,8 +319,8 @@ pub mod registration_client { /// Generated client implementations. pub mod device_plugin_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; /// DevicePlugin is the service advertised by Device Plugins #[derive(Debug, Clone)] pub struct DevicePluginClient { @@ -376,14 +360,13 @@ pub mod device_plugin_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { DevicePluginClient::new(InterceptedService::new(inner, interceptor)) } @@ -423,28 +406,23 @@ pub mod device_plugin_client { pub async fn get_device_plugin_options( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1beta1.DevicePlugin/GetDevicePluginOptions", ); let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new("v1beta1.DevicePlugin", "GetDevicePluginOptions"), - ); + req.extensions_mut().insert(GrpcMethod::new( + "v1beta1.DevicePlugin", + "GetDevicePluginOptions", + )); self.inner.unary(req, path, codec).await } /// ListAndWatch returns a stream of List of Devices @@ -457,19 +435,14 @@ pub mod device_plugin_client { tonic::Response>, tonic::Status, > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1beta1.DevicePlugin/ListAndWatch", - ); + let path = http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/ListAndWatch"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "ListAndWatch")); @@ -483,28 +456,23 @@ pub mod device_plugin_client { pub async fn get_preferred_allocation( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( "/v1beta1.DevicePlugin/GetPreferredAllocation", ); let mut req = request.into_request(); - req.extensions_mut() - .insert( - GrpcMethod::new("v1beta1.DevicePlugin", "GetPreferredAllocation"), - ); + req.extensions_mut().insert(GrpcMethod::new( + "v1beta1.DevicePlugin", + "GetPreferredAllocation", + )); self.inner.unary(req, path, codec).await } /// Allocate is called during container creation so that the Device @@ -513,23 +481,15 @@ pub mod device_plugin_client { pub async fn allocate( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1beta1.DevicePlugin/Allocate", - ); + let path = http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/Allocate"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "Allocate")); @@ -541,23 +501,17 @@ pub mod device_plugin_client { pub async fn pre_start_container( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1beta1.DevicePlugin/PreStartContainer", - ); + let path = + http::uri::PathAndQuery::from_static("/v1beta1.DevicePlugin/PreStartContainer"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v1beta1.DevicePlugin", "PreStartContainer")); @@ -606,10 +560,7 @@ pub mod registration_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -665,23 +616,16 @@ pub mod registration_server { "/v1beta1.Registration/Register" => { #[allow(non_camel_case_types)] struct RegisterSvc(pub Arc); - impl< - T: Registration, - > tonic::server::UnaryService - for RegisterSvc { + impl tonic::server::UnaryService for RegisterSvc { type Response = super::Empty; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::register(&inner, request).await - }; + let fut = + async move { ::register(&inner, request).await }; Box::pin(fut) } } @@ -708,18 +652,14 @@ pub mod registration_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } @@ -761,15 +701,11 @@ pub mod device_plugin_server { async fn get_device_plugin_options( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the ListAndWatch method. type ListAndWatchStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, - > - + Send + > + Send + 'static; /// ListAndWatch returns a stream of List of Devices /// Whenever a Device state change or a Device disappears, ListAndWatch @@ -777,10 +713,7 @@ pub mod device_plugin_server { async fn list_and_watch( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// GetPreferredAllocation returns a preferred set of devices to allocate /// from a list of available ones. The resulting preferred allocation is not /// guaranteed to be the allocation ultimately performed by the @@ -789,30 +722,21 @@ pub mod device_plugin_server { async fn get_preferred_allocation( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// Allocate is called during container creation so that the Device /// Plugin can run device specific operations and instruct Kubelet /// of the steps to make the Device available in the container async fn allocate( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// PreStartContainer is called, if indicated by Device Plugin during registration phase, /// before each container start. Device plugin can run device specific operations /// such as resetting the device before making devices available to the container async fn pre_start_container( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; } /// DevicePlugin is the service advertised by Device Plugins #[derive(Debug)] @@ -838,10 +762,7 @@ pub mod device_plugin_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -897,23 +818,13 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/GetDevicePluginOptions" => { #[allow(non_camel_case_types)] struct GetDevicePluginOptionsSvc(pub Arc); - impl tonic::server::UnaryService - for GetDevicePluginOptionsSvc { + impl tonic::server::UnaryService for GetDevicePluginOptionsSvc { type Response = super::DevicePluginOptions; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::get_device_plugin_options( - &inner, - request, - ) + ::get_device_plugin_options(&inner, request) .await }; Box::pin(fut) @@ -945,20 +856,12 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/ListAndWatch" => { #[allow(non_camel_case_types)] struct ListAndWatchSvc(pub Arc); - impl< - T: DevicePlugin, - > tonic::server::ServerStreamingService - for ListAndWatchSvc { + impl tonic::server::ServerStreamingService for ListAndWatchSvc { type Response = super::ListAndWatchResponse; type ResponseStream = T::ListAndWatchStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = + BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { ::list_and_watch(&inner, request).await @@ -992,26 +895,19 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/GetPreferredAllocation" => { #[allow(non_camel_case_types)] struct GetPreferredAllocationSvc(pub Arc); - impl< - T: DevicePlugin, - > tonic::server::UnaryService - for GetPreferredAllocationSvc { + impl + tonic::server::UnaryService + for GetPreferredAllocationSvc + { type Response = super::PreferredAllocationResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::get_preferred_allocation( - &inner, - request, - ) - .await + ::get_preferred_allocation(&inner, request).await }; Box::pin(fut) } @@ -1042,23 +938,16 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/Allocate" => { #[allow(non_camel_case_types)] struct AllocateSvc(pub Arc); - impl< - T: DevicePlugin, - > tonic::server::UnaryService - for AllocateSvc { + impl tonic::server::UnaryService for AllocateSvc { type Response = super::AllocateResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::allocate(&inner, request).await - }; + let fut = + async move { ::allocate(&inner, request).await }; Box::pin(fut) } } @@ -1088,23 +977,19 @@ pub mod device_plugin_server { "/v1beta1.DevicePlugin/PreStartContainer" => { #[allow(non_camel_case_types)] struct PreStartContainerSvc(pub Arc); - impl< - T: DevicePlugin, - > tonic::server::UnaryService - for PreStartContainerSvc { + impl + tonic::server::UnaryService + for PreStartContainerSvc + { type Response = super::PreStartContainerResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::pre_start_container(&inner, request) - .await + ::pre_start_container(&inner, request).await }; Box::pin(fut) } @@ -1132,18 +1017,14 @@ pub mod device_plugin_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } diff --git a/discovery-utils/src/discovery/v0.rs b/discovery-utils/src/discovery/v0.rs index a20490c38..e691f1458 100644 --- a/discovery-utils/src/discovery/v0.rs +++ b/discovery-utils/src/discovery/v0.rs @@ -9,7 +9,10 @@ pub struct RegisterDiscoveryHandlerRequest { /// Endpoint for the registering `DiscoveryHandler` #[prost(string, tag = "2")] pub endpoint: ::prost::alloc::string::String, - #[prost(enumeration = "register_discovery_handler_request::EndpointType", tag = "3")] + #[prost( + enumeration = "register_discovery_handler_request::EndpointType", + tag = "3" + )] pub endpoint_type: i32, /// Specifies whether this device could be used by multiple nodes (e.g. an IP camera) /// or can only be ever be discovered by a single node (e.g. a local USB device) @@ -19,17 +22,7 @@ pub struct RegisterDiscoveryHandlerRequest { /// Nested message and enum types in `RegisterDiscoveryHandlerRequest`. pub mod register_discovery_handler_request { /// Specifies the type of endpoint. - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum EndpointType { Uds = 0, @@ -75,10 +68,7 @@ pub struct DiscoverRequest { /// list of Key-value pairs containing additional information /// for the 'DiscoveryHandler' to discover devices #[prost(map = "string, message", tag = "2")] - pub discovery_properties: ::std::collections::HashMap< - ::prost::alloc::string::String, - ByteData, - >, + pub discovery_properties: ::std::collections::HashMap<::prost::alloc::string::String, ByteData>, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -97,10 +87,8 @@ pub struct Device { /// and set as environment variables in the device's broker Pods. May be information /// about where to find the device such as an RTSP URL or a device node (e.g. `/dev/video1`) #[prost(map = "string, string", tag = "2")] - pub properties: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub properties: + ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, /// Optionally specify mounts for Pods that request this device as a resource #[prost(message, repeated, tag = "3")] pub mounts: ::prost::alloc::vec::Vec, @@ -145,8 +133,8 @@ pub struct DeviceSpec { /// Generated client implementations. pub mod registration_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; /// Registration is the service advertised by the Akri Agent. /// Any `DiscoveryHandler` can register with the Akri Agent. #[derive(Debug, Clone)] @@ -187,14 +175,13 @@ pub mod registration_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { RegistrationClient::new(InterceptedService::new(inner, interceptor)) } @@ -233,22 +220,20 @@ pub mod registration_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v0.Registration/RegisterDiscoveryHandler", - ); + let path = + http::uri::PathAndQuery::from_static("/v0.Registration/RegisterDiscoveryHandler"); let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("v0.Registration", "RegisterDiscoveryHandler")); + req.extensions_mut().insert(GrpcMethod::new( + "v0.Registration", + "RegisterDiscoveryHandler", + )); self.inner.unary(req, path, codec).await } } @@ -256,8 +241,8 @@ pub mod registration_client { /// Generated client implementations. pub mod discovery_handler_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; #[derive(Debug, Clone)] pub struct DiscoveryHandlerClient { inner: tonic::client::Grpc, @@ -296,14 +281,13 @@ pub mod discovery_handler_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { DiscoveryHandlerClient::new(InterceptedService::new(inner, interceptor)) } @@ -345,19 +329,14 @@ pub mod discovery_handler_client { tonic::Response>, tonic::Status, > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v0.DiscoveryHandler/Discover", - ); + let path = http::uri::PathAndQuery::from_static("/v0.DiscoveryHandler/Discover"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v0.DiscoveryHandler", "Discover")); @@ -402,10 +381,7 @@ pub mod registration_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -461,27 +437,19 @@ pub mod registration_server { "/v0.Registration/RegisterDiscoveryHandler" => { #[allow(non_camel_case_types)] struct RegisterDiscoveryHandlerSvc(pub Arc); - impl< - T: Registration, - > tonic::server::UnaryService - for RegisterDiscoveryHandlerSvc { + impl + tonic::server::UnaryService + for RegisterDiscoveryHandlerSvc + { type Response = super::Empty; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, - request: tonic::Request< - super::RegisterDiscoveryHandlerRequest, - >, + request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::register_discovery_handler( - &inner, - request, - ) + ::register_discovery_handler(&inner, request) .await }; Box::pin(fut) @@ -510,18 +478,14 @@ pub mod registration_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } @@ -561,8 +525,7 @@ pub mod discovery_handler_server { /// Server streaming response type for the Discover method. type DiscoverStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, - > - + Send + > + Send + 'static; async fn discover( &self, @@ -592,10 +555,7 @@ pub mod discovery_handler_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -651,16 +611,14 @@ pub mod discovery_handler_server { "/v0.DiscoveryHandler/Discover" => { #[allow(non_camel_case_types)] struct DiscoverSvc(pub Arc); - impl< - T: DiscoveryHandler, - > tonic::server::ServerStreamingService - for DiscoverSvc { + impl + tonic::server::ServerStreamingService + for DiscoverSvc + { type Response = super::DiscoverResponse; type ResponseStream = T::DiscoverStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = + BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, @@ -695,18 +653,14 @@ pub mod discovery_handler_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } diff --git a/samples/brokers/udev-video-broker/src/util/camera.rs b/samples/brokers/udev-video-broker/src/util/camera.rs index 4bd208251..a1ee7fe5d 100644 --- a/samples/brokers/udev-video-broker/src/util/camera.rs +++ b/samples/brokers/udev-video-broker/src/util/camera.rs @@ -13,8 +13,8 @@ pub struct NotifyResponse { /// Generated client implementations. pub mod camera_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; #[derive(Debug, Clone)] pub struct CameraClient { inner: tonic::client::Grpc, @@ -53,14 +53,13 @@ pub mod camera_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { CameraClient::new(InterceptedService::new(inner, interceptor)) } @@ -99,19 +98,17 @@ pub mod camera_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/camera.Camera/GetFrame"); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("camera.Camera", "GetFrame")); + req.extensions_mut() + .insert(GrpcMethod::new("camera.Camera", "GetFrame")); self.inner.unary(req, path, codec).await } } @@ -151,10 +148,7 @@ pub mod camera_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -210,21 +204,16 @@ pub mod camera_server { "/camera.Camera/GetFrame" => { #[allow(non_camel_case_types)] struct GetFrameSvc(pub Arc); - impl tonic::server::UnaryService - for GetFrameSvc { + impl tonic::server::UnaryService for GetFrameSvc { type Response = super::NotifyResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_frame(&inner, request).await - }; + let fut = + async move { ::get_frame(&inner, request).await }; Box::pin(fut) } } @@ -251,18 +240,14 @@ pub mod camera_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } From 5a6875345487f4d1c1f297d4ca7e25c333073f25 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 15:18:49 +0100 Subject: [PATCH 16/19] style: more clippying Signed-off-by: Gaurav Gahlot --- discovery-handlers/udev/src/discovery_handler.rs | 10 ++++++---- .../udev-video-broker/src/util/camera_capturer.rs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/discovery-handlers/udev/src/discovery_handler.rs b/discovery-handlers/udev/src/discovery_handler.rs index e1890e906..be630a204 100644 --- a/discovery-handlers/udev/src/discovery_handler.rs +++ b/discovery-handlers/udev/src/discovery_handler.rs @@ -119,10 +119,12 @@ impl DiscoveryHandler for DiscoveryHandlerImpl { let mut properties = HashMap::new(); let mut device_specs = Vec::new(); for (i, (_, node)) in paths.into_iter().enumerate() { - let property_suffix = discovery_handler_config - .group_recursive - .then(|| format!("_{i}")) - .unwrap_or_default(); + let property_suffix = if discovery_handler_config.group_recursive { + format!("_{i}") + } else { + Default::default() + }; + if let Some(devnode) = node { properties.insert( super::UDEV_DEVNODE_LABEL_ID.to_string() + &property_suffix, diff --git a/samples/brokers/udev-video-broker/src/util/camera_capturer.rs b/samples/brokers/udev-video-broker/src/util/camera_capturer.rs index e3e2290e5..43a7469bd 100644 --- a/samples/brokers/udev-video-broker/src/util/camera_capturer.rs +++ b/samples/brokers/udev-video-broker/src/util/camera_capturer.rs @@ -40,7 +40,7 @@ pub fn build_and_start_camera_capturer(devnode: &str) -> RsCamera { }) .collect(); let format_string = get_format(&env_var_query, format_options); - let format = format_string[..].as_bytes(); + let format = &format_string.as_bytes(); let resolution_info = camera_capturer.resolutions(format).unwrap(); let resolution = get_resolution(&env_var_query, resolution_info); let interval_info = camera_capturer.intervals(format, resolution).unwrap(); From e2fdbfdc4adfec017b12950d10aa69880faa6582 Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 16:00:10 +0100 Subject: [PATCH 17/19] chore: update yaserde to 0.11.2 Signed-off-by: Gaurav Gahlot --- Cargo.lock | 23 +-- discovery-handlers/onvif/Cargo.toml | 4 +- discovery-utils/src/discovery/v0.rs | 192 +++++++++++------- .../udev-video-broker/src/util/camera.rs | 71 ++++--- 4 files changed, 171 insertions(+), 119 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c3c0aafda..3e88be4a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "actix-codec" @@ -1530,15 +1530,6 @@ dependencies = [ "http 0.2.12", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.5.0" @@ -2879,7 +2870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", - "heck 0.5.0", + "heck", "itertools", "log", "multimap", @@ -4649,9 +4640,9 @@ checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f" [[package]] name = "yaserde" -version = "0.7.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2776ec5bb20e76d89268e87e1ea66c078b94f55e9771e4d648adda3019f87fc" +checksum = "3837963ac213fd0babf6be78811f1d9e673e5c9240ee0d00020fa69c0acb5b35" dependencies = [ "log", "xml-rs", @@ -4659,11 +4650,11 @@ dependencies = [ [[package]] name = "yaserde_derive" -version = "0.7.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0b0a4701f203ebaecce4971a6bb8575aa07b617bdc39ddfc6ffeff3a38530d" +checksum = "5b14b171e65b944cd8018ea60ac5cc6601bb0a07ce4b2979962e22c9f6fb6496" dependencies = [ - "heck 0.3.3", + "heck", "log", "proc-macro2", "quote", diff --git a/discovery-handlers/onvif/Cargo.toml b/discovery-handlers/onvif/Cargo.toml index 98dce407e..8fbbc1d23 100644 --- a/discovery-handlers/onvif/Cargo.toml +++ b/discovery-handlers/onvif/Cargo.toml @@ -28,8 +28,8 @@ tokio = { version = "1.0", features = ["time", "net", "sync"] } tokio-stream = { version = "0.1", features = ["net"] } tonic = { version = "0.10", features = ["tls"] } uuid = { version = "0.8.1", features = ["v4"] } -yaserde = "0.7.1" -yaserde_derive = "0.7.1" +yaserde = "0.11.2" +yaserde_derive = "0.11.2" [dev-dependencies] env_logger = "0.11.8" diff --git a/discovery-utils/src/discovery/v0.rs b/discovery-utils/src/discovery/v0.rs index e691f1458..a20490c38 100644 --- a/discovery-utils/src/discovery/v0.rs +++ b/discovery-utils/src/discovery/v0.rs @@ -9,10 +9,7 @@ pub struct RegisterDiscoveryHandlerRequest { /// Endpoint for the registering `DiscoveryHandler` #[prost(string, tag = "2")] pub endpoint: ::prost::alloc::string::String, - #[prost( - enumeration = "register_discovery_handler_request::EndpointType", - tag = "3" - )] + #[prost(enumeration = "register_discovery_handler_request::EndpointType", tag = "3")] pub endpoint_type: i32, /// Specifies whether this device could be used by multiple nodes (e.g. an IP camera) /// or can only be ever be discovered by a single node (e.g. a local USB device) @@ -22,7 +19,17 @@ pub struct RegisterDiscoveryHandlerRequest { /// Nested message and enum types in `RegisterDiscoveryHandlerRequest`. pub mod register_discovery_handler_request { /// Specifies the type of endpoint. - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] #[repr(i32)] pub enum EndpointType { Uds = 0, @@ -68,7 +75,10 @@ pub struct DiscoverRequest { /// list of Key-value pairs containing additional information /// for the 'DiscoveryHandler' to discover devices #[prost(map = "string, message", tag = "2")] - pub discovery_properties: ::std::collections::HashMap<::prost::alloc::string::String, ByteData>, + pub discovery_properties: ::std::collections::HashMap< + ::prost::alloc::string::String, + ByteData, + >, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -87,8 +97,10 @@ pub struct Device { /// and set as environment variables in the device's broker Pods. May be information /// about where to find the device such as an RTSP URL or a device node (e.g. `/dev/video1`) #[prost(map = "string, string", tag = "2")] - pub properties: - ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + pub properties: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::string::String, + >, /// Optionally specify mounts for Pods that request this device as a resource #[prost(message, repeated, tag = "3")] pub mounts: ::prost::alloc::vec::Vec, @@ -133,8 +145,8 @@ pub struct DeviceSpec { /// Generated client implementations. pub mod registration_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; /// Registration is the service advertised by the Akri Agent. /// Any `DiscoveryHandler` can register with the Akri Agent. #[derive(Debug, Clone)] @@ -175,13 +187,14 @@ pub mod registration_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, + http::Request, + Response = http::Response< + >::ResponseBody, >, - >>::Error: - Into + Send + Sync, + >, + , + >>::Error: Into + Send + Sync, { RegistrationClient::new(InterceptedService::new(inner, interceptor)) } @@ -220,20 +233,22 @@ pub mod registration_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/v0.Registration/RegisterDiscoveryHandler"); + let path = http::uri::PathAndQuery::from_static( + "/v0.Registration/RegisterDiscoveryHandler", + ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new( - "v0.Registration", - "RegisterDiscoveryHandler", - )); + req.extensions_mut() + .insert(GrpcMethod::new("v0.Registration", "RegisterDiscoveryHandler")); self.inner.unary(req, path, codec).await } } @@ -241,8 +256,8 @@ pub mod registration_client { /// Generated client implementations. pub mod discovery_handler_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct DiscoveryHandlerClient { inner: tonic::client::Grpc, @@ -281,13 +296,14 @@ pub mod discovery_handler_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, + http::Request, + Response = http::Response< + >::ResponseBody, >, - >>::Error: - Into + Send + Sync, + >, + , + >>::Error: Into + Send + Sync, { DiscoveryHandlerClient::new(InterceptedService::new(inner, interceptor)) } @@ -329,14 +345,19 @@ pub mod discovery_handler_client { tonic::Response>, tonic::Status, > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v0.DiscoveryHandler/Discover"); + let path = http::uri::PathAndQuery::from_static( + "/v0.DiscoveryHandler/Discover", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v0.DiscoveryHandler", "Discover")); @@ -381,7 +402,10 @@ pub mod registration_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -437,19 +461,27 @@ pub mod registration_server { "/v0.Registration/RegisterDiscoveryHandler" => { #[allow(non_camel_case_types)] struct RegisterDiscoveryHandlerSvc(pub Arc); - impl - tonic::server::UnaryService - for RegisterDiscoveryHandlerSvc - { + impl< + T: Registration, + > tonic::server::UnaryService + for RegisterDiscoveryHandlerSvc { type Response = super::Empty; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, - request: tonic::Request, + request: tonic::Request< + super::RegisterDiscoveryHandlerRequest, + >, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::register_discovery_handler(&inner, request) + ::register_discovery_handler( + &inner, + request, + ) .await }; Box::pin(fut) @@ -478,14 +510,18 @@ pub mod registration_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } @@ -525,7 +561,8 @@ pub mod discovery_handler_server { /// Server streaming response type for the Discover method. type DiscoverStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, - > + Send + > + + Send + 'static; async fn discover( &self, @@ -555,7 +592,10 @@ pub mod discovery_handler_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -611,14 +651,16 @@ pub mod discovery_handler_server { "/v0.DiscoveryHandler/Discover" => { #[allow(non_camel_case_types)] struct DiscoverSvc(pub Arc); - impl - tonic::server::ServerStreamingService - for DiscoverSvc - { + impl< + T: DiscoveryHandler, + > tonic::server::ServerStreamingService + for DiscoverSvc { type Response = super::DiscoverResponse; type ResponseStream = T::DiscoverStream; - type Future = - BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -653,14 +695,18 @@ pub mod discovery_handler_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } diff --git a/samples/brokers/udev-video-broker/src/util/camera.rs b/samples/brokers/udev-video-broker/src/util/camera.rs index a1ee7fe5d..4bd208251 100644 --- a/samples/brokers/udev-video-broker/src/util/camera.rs +++ b/samples/brokers/udev-video-broker/src/util/camera.rs @@ -13,8 +13,8 @@ pub struct NotifyResponse { /// Generated client implementations. pub mod camera_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct CameraClient { inner: tonic::client::Grpc, @@ -53,13 +53,14 @@ pub mod camera_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, + http::Request, + Response = http::Response< + >::ResponseBody, >, - >>::Error: - Into + Send + Sync, + >, + , + >>::Error: Into + Send + Sync, { CameraClient::new(InterceptedService::new(inner, interceptor)) } @@ -98,17 +99,19 @@ pub mod camera_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/camera.Camera/GetFrame"); let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("camera.Camera", "GetFrame")); + req.extensions_mut().insert(GrpcMethod::new("camera.Camera", "GetFrame")); self.inner.unary(req, path, codec).await } } @@ -148,7 +151,10 @@ pub mod camera_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -204,16 +210,21 @@ pub mod camera_server { "/camera.Camera/GetFrame" => { #[allow(non_camel_case_types)] struct GetFrameSvc(pub Arc); - impl tonic::server::UnaryService for GetFrameSvc { + impl tonic::server::UnaryService + for GetFrameSvc { type Response = super::NotifyResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::get_frame(&inner, request).await }; + let fut = async move { + ::get_frame(&inner, request).await + }; Box::pin(fut) } } @@ -240,14 +251,18 @@ pub mod camera_server { }; Box::pin(fut) } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap()) - }), + _ => { + Box::pin(async move { + Ok( + http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap(), + ) + }) + } } } } From 7d9dbfafa8b5052f00204a21baf41062a4649fba Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 16:02:41 +0100 Subject: [PATCH 18/19] style: more cargo fmt fixes Signed-off-by: Gaurav Gahlot --- discovery-utils/src/discovery/v0.rs | 192 +++++++----------- .../udev-video-broker/src/util/camera.rs | 71 +++---- 2 files changed, 101 insertions(+), 162 deletions(-) diff --git a/discovery-utils/src/discovery/v0.rs b/discovery-utils/src/discovery/v0.rs index a20490c38..e691f1458 100644 --- a/discovery-utils/src/discovery/v0.rs +++ b/discovery-utils/src/discovery/v0.rs @@ -9,7 +9,10 @@ pub struct RegisterDiscoveryHandlerRequest { /// Endpoint for the registering `DiscoveryHandler` #[prost(string, tag = "2")] pub endpoint: ::prost::alloc::string::String, - #[prost(enumeration = "register_discovery_handler_request::EndpointType", tag = "3")] + #[prost( + enumeration = "register_discovery_handler_request::EndpointType", + tag = "3" + )] pub endpoint_type: i32, /// Specifies whether this device could be used by multiple nodes (e.g. an IP camera) /// or can only be ever be discovered by a single node (e.g. a local USB device) @@ -19,17 +22,7 @@ pub struct RegisterDiscoveryHandlerRequest { /// Nested message and enum types in `RegisterDiscoveryHandlerRequest`. pub mod register_discovery_handler_request { /// Specifies the type of endpoint. - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum EndpointType { Uds = 0, @@ -75,10 +68,7 @@ pub struct DiscoverRequest { /// list of Key-value pairs containing additional information /// for the 'DiscoveryHandler' to discover devices #[prost(map = "string, message", tag = "2")] - pub discovery_properties: ::std::collections::HashMap< - ::prost::alloc::string::String, - ByteData, - >, + pub discovery_properties: ::std::collections::HashMap<::prost::alloc::string::String, ByteData>, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -97,10 +87,8 @@ pub struct Device { /// and set as environment variables in the device's broker Pods. May be information /// about where to find the device such as an RTSP URL or a device node (e.g. `/dev/video1`) #[prost(map = "string, string", tag = "2")] - pub properties: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub properties: + ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, /// Optionally specify mounts for Pods that request this device as a resource #[prost(message, repeated, tag = "3")] pub mounts: ::prost::alloc::vec::Vec, @@ -145,8 +133,8 @@ pub struct DeviceSpec { /// Generated client implementations. pub mod registration_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; /// Registration is the service advertised by the Akri Agent. /// Any `DiscoveryHandler` can register with the Akri Agent. #[derive(Debug, Clone)] @@ -187,14 +175,13 @@ pub mod registration_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { RegistrationClient::new(InterceptedService::new(inner, interceptor)) } @@ -233,22 +220,20 @@ pub mod registration_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v0.Registration/RegisterDiscoveryHandler", - ); + let path = + http::uri::PathAndQuery::from_static("/v0.Registration/RegisterDiscoveryHandler"); let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("v0.Registration", "RegisterDiscoveryHandler")); + req.extensions_mut().insert(GrpcMethod::new( + "v0.Registration", + "RegisterDiscoveryHandler", + )); self.inner.unary(req, path, codec).await } } @@ -256,8 +241,8 @@ pub mod registration_client { /// Generated client implementations. pub mod discovery_handler_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; #[derive(Debug, Clone)] pub struct DiscoveryHandlerClient { inner: tonic::client::Grpc, @@ -296,14 +281,13 @@ pub mod discovery_handler_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { DiscoveryHandlerClient::new(InterceptedService::new(inner, interceptor)) } @@ -345,19 +329,14 @@ pub mod discovery_handler_client { tonic::Response>, tonic::Status, > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v0.DiscoveryHandler/Discover", - ); + let path = http::uri::PathAndQuery::from_static("/v0.DiscoveryHandler/Discover"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("v0.DiscoveryHandler", "Discover")); @@ -402,10 +381,7 @@ pub mod registration_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -461,27 +437,19 @@ pub mod registration_server { "/v0.Registration/RegisterDiscoveryHandler" => { #[allow(non_camel_case_types)] struct RegisterDiscoveryHandlerSvc(pub Arc); - impl< - T: Registration, - > tonic::server::UnaryService - for RegisterDiscoveryHandlerSvc { + impl + tonic::server::UnaryService + for RegisterDiscoveryHandlerSvc + { type Response = super::Empty; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, - request: tonic::Request< - super::RegisterDiscoveryHandlerRequest, - >, + request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::register_discovery_handler( - &inner, - request, - ) + ::register_discovery_handler(&inner, request) .await }; Box::pin(fut) @@ -510,18 +478,14 @@ pub mod registration_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } @@ -561,8 +525,7 @@ pub mod discovery_handler_server { /// Server streaming response type for the Discover method. type DiscoverStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, - > - + Send + > + Send + 'static; async fn discover( &self, @@ -592,10 +555,7 @@ pub mod discovery_handler_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -651,16 +611,14 @@ pub mod discovery_handler_server { "/v0.DiscoveryHandler/Discover" => { #[allow(non_camel_case_types)] struct DiscoverSvc(pub Arc); - impl< - T: DiscoveryHandler, - > tonic::server::ServerStreamingService - for DiscoverSvc { + impl + tonic::server::ServerStreamingService + for DiscoverSvc + { type Response = super::DiscoverResponse; type ResponseStream = T::DiscoverStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = + BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, @@ -695,18 +653,14 @@ pub mod discovery_handler_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } diff --git a/samples/brokers/udev-video-broker/src/util/camera.rs b/samples/brokers/udev-video-broker/src/util/camera.rs index 4bd208251..a1ee7fe5d 100644 --- a/samples/brokers/udev-video-broker/src/util/camera.rs +++ b/samples/brokers/udev-video-broker/src/util/camera.rs @@ -13,8 +13,8 @@ pub struct NotifyResponse { /// Generated client implementations. pub mod camera_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; use tonic::codegen::http::Uri; + use tonic::codegen::*; #[derive(Debug, Clone)] pub struct CameraClient { inner: tonic::client::Grpc, @@ -53,14 +53,13 @@ pub mod camera_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, - , - >>::Error: Into + Send + Sync, + >>::Error: + Into + Send + Sync, { CameraClient::new(InterceptedService::new(inner, interceptor)) } @@ -99,19 +98,17 @@ pub mod camera_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/camera.Camera/GetFrame"); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("camera.Camera", "GetFrame")); + req.extensions_mut() + .insert(GrpcMethod::new("camera.Camera", "GetFrame")); self.inner.unary(req, path, codec).await } } @@ -151,10 +148,7 @@ pub mod camera_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -210,21 +204,16 @@ pub mod camera_server { "/camera.Camera/GetFrame" => { #[allow(non_camel_case_types)] struct GetFrameSvc(pub Arc); - impl tonic::server::UnaryService - for GetFrameSvc { + impl tonic::server::UnaryService for GetFrameSvc { type Response = super::NotifyResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_frame(&inner, request).await - }; + let fut = + async move { ::get_frame(&inner, request).await }; Box::pin(fut) } } @@ -251,18 +240,14 @@ pub mod camera_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") - .body(empty_body()) - .unwrap(), - ) - }) - } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", "12") + .header("content-type", "application/grpc") + .body(empty_body()) + .unwrap()) + }), } } } From 136e9cc3ad0e167f964c283c61b900af697c029d Mon Sep 17 00:00:00 2001 From: Gaurav Gahlot Date: Sat, 13 Dec 2025 18:00:29 +0100 Subject: [PATCH 19/19] chore: make exception for now Signed-off-by: Gaurav Gahlot --- .github/workflows/check-rust.yml | 6 +++++- .../src/plugin_manager/device_plugin_instance_controller.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 14ee638a1..0c4138f07 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -49,7 +49,11 @@ jobs: - name: Check clippy run: cargo clippy --all - name: Check clippy for tests - run: cargo clippy --all-targets --all-features -- -D warnings -A clippy::derive_partial_eq_without_eq + run: | + cargo clippy --all-targets --all-features -- -D warnings \ + -A clippy::derive_partial_eq_without_eq \ + -A clippy::doc_overindented_list_items \ + -A clippy::result_large_err # TODO: @gauravgahlot - revisit large error - name: Run check run: cargo check - name: Run tests diff --git a/agent/src/plugin_manager/device_plugin_instance_controller.rs b/agent/src/plugin_manager/device_plugin_instance_controller.rs index fd3bd077c..702dad2c8 100644 --- a/agent/src/plugin_manager/device_plugin_instance_controller.rs +++ b/agent/src/plugin_manager/device_plugin_instance_controller.rs @@ -724,8 +724,8 @@ fn config_device_usage_to_device( }) } -/// This module implements a controller for Instance resources that will ensure device plugins are correctly created with the correct health status - +/// This module implements a controller for Instance resources that will ensure +/// device plugins are correctly created with the correct health status pub struct DevicePluginManager { instance_plugins: Mutex>>, configuration_plugins: Mutex>>,