diff --git a/Cargo.lock b/Cargo.lock index 295482fd..d017be43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -596,12 +596,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.21.3" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" dependencies = [ - "darling_core 0.21.3", - "darling_macro 0.21.3", + "darling_core 0.23.0", + "darling_macro 0.23.0", ] [[package]] @@ -620,11 +620,10 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.21.3" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" dependencies = [ - "fnv", "ident_case", "proc-macro2", "quote", @@ -645,11 +644,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.21.3" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ - "darling_core 0.21.3", + "darling_core 0.23.0", "quote", "syn 2.0.110", ] @@ -945,9 +944,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.5" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "foreign-types" @@ -1178,21 +1177,15 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" dependencies = [ "allocator-api2", "equivalent", "foldhash", ] -[[package]] -name = "hashbrown" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" - [[package]] name = "hdrhistogram" version = "7.5.4" @@ -1260,15 +1253,6 @@ dependencies = [ "digest", ] -[[package]] -name = "home" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "hostname" version = "0.4.1" @@ -1774,9 +1758,9 @@ dependencies = [ [[package]] name = "jsonpath-rust" -version = "0.7.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c00ae348f9f8fd2d09f82a98ca381c60df9e0820d8d79fce43e649b4dc3128b" +checksum = "633a7320c4bb672863a3782e89b9094ad70285e097ff6832cddd0ec615beadfa" dependencies = [ "pest", "pest_derive", @@ -1812,12 +1796,12 @@ dependencies = [ [[package]] name = "k8s-openapi" -version = "0.26.1" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06d9e5e61dd037cdc51da0d7e2b2be10f497478ea7e120d85dad632adb99882b" +checksum = "05a6d6f3611ad1d21732adbd7a2e921f598af6c92d71ae6e2620da4b67ee1f0d" dependencies = [ "base64 0.22.1", - "chrono", + "jiff", "schemars", "serde", "serde_json", @@ -1825,9 +1809,9 @@ dependencies = [ [[package]] name = "kube" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e7bb0b6a46502cc20e4575b6ff401af45cfea150b34ba272a3410b78aa014e" +checksum = "0dae7229247e4215781e5c5104a056e1e2163943e577f9084cf8bba7b5248f7a" dependencies = [ "k8s-openapi", "kube-client", @@ -1838,16 +1822,14 @@ dependencies = [ [[package]] name = "kube-client" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4987d57a184d2b5294fdad3d7fc7f278899469d21a4da39a8f6ca16426567a36" +checksum = "010875e291a9c0a4e076f4f9c35b97d82fd2372cb3bc713252c3d08b7e73ce5b" dependencies = [ "base64 0.22.1", "bytes", - "chrono", "either", "futures", - "home", "http 1.4.0", "http-body 1.0.1", "http-body-util", @@ -1855,6 +1837,7 @@ dependencies = [ "hyper-openssl", "hyper-timeout", "hyper-util", + "jiff", "jsonpath-rust", "k8s-openapi", "kube-core", @@ -1874,14 +1857,14 @@ dependencies = [ [[package]] name = "kube-core" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914bbb770e7bb721a06e3538c0edd2babed46447d128f7c21caa68747060ee73" +checksum = "1ac76281aa698dd34111e25b21f5f6561932a30feabab5357152be273f8a81bb" dependencies = [ - "chrono", "derive_more", "form_urlencoded", "http 1.4.0", + "jiff", "json-patch", "k8s-openapi", "schemars", @@ -1893,11 +1876,11 @@ dependencies = [ [[package]] name = "kube-derive" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03dee8252be137772a6ab3508b81cd797dee62ee771112a2453bc85cbbe150d2" +checksum = "599c09721efcccc0e6a26e93df28c587da60ff5e099c657626fff2af0ae4cbb8" dependencies = [ - "darling 0.21.3", + "darling 0.23.0", "proc-macro2", "quote", "serde", @@ -1907,9 +1890,9 @@ dependencies = [ [[package]] name = "kube-runtime" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aea4de4b562c5cc89ab10300bb63474ae1fa57ff5a19275f2e26401a323e3fd" +checksum = "6db43d26700f564baf850f681f3cb0f1195d2699bd379bfa70750ecec4dcb209" dependencies = [ "ahash", "async-broadcast", @@ -1917,7 +1900,7 @@ dependencies = [ "backon", "educe", "futures", - "hashbrown 0.15.5", + "hashbrown 0.16.0", "hostname", "json-patch", "k8s-openapi", @@ -2361,6 +2344,7 @@ version = "0.1.0" dependencies = [ "anyhow", "base64 0.22.1", + "chrono", "clevis-pin-trustee-lib", "compute-pcrs-lib", "env_logger", @@ -3187,9 +3171,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.148" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3084b546a1dd6289475996f182a22aba973866ea8e8b02c51d9f46b1336a22da" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ "itoa", "memchr", @@ -3698,9 +3682,9 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" dependencies = [ "futures-core", "futures-util", @@ -4230,15 +4214,6 @@ 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" diff --git a/Cargo.toml b/Cargo.toml index 87d9752a..b2823963 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,8 +19,8 @@ compute-pcrs-lib = { git = "https://github.com/trusted-execution-clusters/comput env_logger = "0.11.8" http = "1.4.0" ignition-config = "0.5.0" -k8s-openapi = { version = "0.26.1", features = ["v1_33", "schemars"] } -kube = { version = "2.0.1", default-features = false, features = ["derive", "runtime", "openssl-tls"] } +k8s-openapi = { version = "0.27.0", features = ["v1_33", "schemars"] } +kube = { version = "3.0.0", default-features = false, features = ["derive", "runtime", "openssl-tls"] } log = "0.4.29" serde = { version = "1.0.228", features = ["derive"] } serde_json = "1.0.148" diff --git a/compute-pcrs/src/main.rs b/compute-pcrs/src/main.rs index 2509e2c0..db1f5f0d 100644 --- a/compute-pcrs/src/main.rs +++ b/compute-pcrs/src/main.rs @@ -6,7 +6,7 @@ use anyhow::{Context, Result}; use clap::Parser; use compute_pcrs_lib::*; -use k8s_openapi::{api::core::v1::ConfigMap, chrono::Utc}; +use k8s_openapi::{api::core::v1::ConfigMap, jiff::Timestamp}; use kube::{Api, Client}; use trusted_cluster_operator_lib::{conditions::INSTALLED_REASON, reference_values::*, *}; @@ -57,7 +57,7 @@ async fn main() -> Result<()> { let mut image_pcrs: ImagePcrs = serde_json::from_str(image_pcrs_str)?; let image_pcr = ImagePcr { - first_seen: Utc::now(), + first_seen: Timestamp::now(), reference: args.image, pcrs, }; diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 33a79304..5ab81afb 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -8,6 +8,7 @@ pub mod reference_values; mod kopium; #[allow(clippy::all)] mod vendor_kopium; +use k8s_openapi::jiff::Timestamp; pub use kopium::approvedimages::*; pub use kopium::attestationkeys::*; pub use kopium::machines::*; @@ -17,7 +18,6 @@ pub use vendor_kopium::virtualmachines; use conditions::*; use k8s_openapi::apimachinery::pkg::apis::meta::v1::{Condition, Time}; -use k8s_openapi::chrono::Utc; #[macro_export] macro_rules! update_status { @@ -50,7 +50,7 @@ pub fn committed_condition(reason: &str, generation: Option) -> Condition { _ => "", } .to_string(), - last_transition_time: Time(Utc::now()), + last_transition_time: Time(Timestamp::now()), observed_generation: generation, } } diff --git a/lib/src/reference_values.rs b/lib/src/reference_values.rs index 0e6361f4..80661bf9 100644 --- a/lib/src/reference_values.rs +++ b/lib/src/reference_values.rs @@ -4,7 +4,7 @@ // SPDX-License-Identifier: MIT use compute_pcrs_lib::Pcr; -use k8s_openapi::chrono::{DateTime, Utc}; +use k8s_openapi::jiff::Timestamp; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; @@ -13,7 +13,7 @@ pub const PCR_CONFIG_FILE: &str = "image-pcrs.json"; #[derive(Deserialize, Serialize)] pub struct ImagePcr { - pub first_seen: DateTime, + pub first_seen: Timestamp, pub pcrs: Vec, pub reference: String, } diff --git a/operator/Cargo.toml b/operator/Cargo.toml index 0db4174e..85ddbba1 100644 --- a/operator/Cargo.toml +++ b/operator/Cargo.toml @@ -11,6 +11,7 @@ rust-version.workspace = true [dependencies] anyhow.workspace = true base64 = "0.22.1" +chrono = "0.4.42" clevis-pin-trustee-lib.workspace = true trusted-cluster-operator-lib = { path = "../lib" } compute-pcrs-lib.workspace = true diff --git a/operator/src/conditions.rs b/operator/src/conditions.rs index ae2b0fab..f969b059 100644 --- a/operator/src/conditions.rs +++ b/operator/src/conditions.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use k8s_openapi::apimachinery::pkg::apis::meta::v1::{Condition, Time}; -use k8s_openapi::chrono::Utc; +use k8s_openapi::jiff::Timestamp; use trusted_cluster_operator_lib::{condition_status, conditions::*}; pub fn known_trustee_address_condition(known: bool, generation: Option) -> Condition { @@ -18,7 +18,7 @@ pub fn known_trustee_address_condition(known: bool, generation: Option) -> status: condition_status(known), reason: reason.to_string(), message: message.to_string(), - last_transition_time: Time(Utc::now()), + last_transition_time: Time(Timestamp::now()), observed_generation: generation, } } @@ -38,7 +38,7 @@ pub fn installed_condition(reason: &str, generation: Option) -> Condition { _ => "", } .to_string(), - last_transition_time: Time(Utc::now()), + last_transition_time: Time(Timestamp::now()), observed_generation: generation, } } @@ -55,7 +55,7 @@ pub fn attestation_key_approved_condition(reason: &str, generation: Option) _ => "", } .to_string(), - last_transition_time: Time(Utc::now()), + last_transition_time: Time(Timestamp::now()), observed_generation: generation, } } diff --git a/operator/src/main.rs b/operator/src/main.rs index 2c2517fd..af0adac8 100644 --- a/operator/src/main.rs +++ b/operator/src/main.rs @@ -222,7 +222,7 @@ async fn main() -> Result<()> { #[cfg(test)] mod tests { use http::{Method, Request, StatusCode}; - use k8s_openapi::{apimachinery::pkg::apis::meta::v1::Time, chrono::Utc}; + use k8s_openapi::{apimachinery::pkg::apis::meta::v1::Time, jiff::Timestamp}; use kube::api::ObjectList; use kube::client::Body; @@ -240,7 +240,7 @@ mod tests { }; count_check!(1, clos, |client| { let mut cluster = dummy_cluster(); - cluster.metadata.deletion_timestamp = Some(Time(Utc::now())); + cluster.metadata.deletion_timestamp = Some(Time(Timestamp::now())); let result = reconcile(Arc::new(cluster), Arc::new(client)).await; assert_eq!(result.unwrap(), Action::await_change()); }); diff --git a/operator/src/reference_values.rs b/operator/src/reference_values.rs index 29bd6485..65e2c17d 100644 --- a/operator/src/reference_values.rs +++ b/operator/src/reference_values.rs @@ -15,7 +15,7 @@ use k8s_openapi::{ }, }, apimachinery::pkg::apis::meta::v1::OwnerReference, - chrono::Utc, + jiff::Timestamp, }; use kube::api::{DeleteParams, ObjectMeta}; use kube::runtime::{ @@ -321,7 +321,7 @@ pub async fn handle_new_image( } let image_pcr = ImagePcr { - first_seen: Utc::now(), + first_seen: Timestamp::now(), pcrs: label.unwrap(), reference: boot_image.to_string(), }; @@ -377,7 +377,7 @@ mod tests { ..Default::default() }, status: Some(JobStatus { - completion_time: Some(Time(Utc::now())), + completion_time: Some(Time(Timestamp::now())), ..Default::default() }), ..Default::default() diff --git a/operator/src/test_utils.rs b/operator/src/test_utils.rs index 6d8e5717..a9c0241d 100644 --- a/operator/src/test_utils.rs +++ b/operator/src/test_utils.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use compute_pcrs_lib::Pcr; -use k8s_openapi::{api::core::v1::ConfigMap, chrono::Utc}; +use k8s_openapi::{api::core::v1::ConfigMap, jiff::Timestamp}; use kube::Client; use operator::RvContextData; use std::collections::BTreeMap; @@ -15,7 +15,7 @@ pub fn dummy_pcrs() -> ImagePcrs { ImagePcrs(BTreeMap::from([( "cos".to_string(), ImagePcr { - first_seen: Utc::now(), + first_seen: Timestamp::now(), pcrs: vec![ Pcr { id: 0, diff --git a/operator/src/trustee.rs b/operator/src/trustee.rs index 74ad65d2..31ef1560 100644 --- a/operator/src/trustee.rs +++ b/operator/src/trustee.rs @@ -6,6 +6,7 @@ use anyhow::{Context, Result}; use base64::{Engine as _, engine::general_purpose}; +use chrono::{DateTime, TimeDelta, Utc}; use clevis_pin_trustee_lib::Key as ClevisKey; use k8s_openapi::api::apps::v1::{Deployment, DeploymentSpec}; use k8s_openapi::api::core::v1::{ @@ -17,7 +18,6 @@ use k8s_openapi::apimachinery::pkg::{ apis::meta::v1::{LabelSelector, OwnerReference}, util::intstr::IntOrString, }; -use k8s_openapi::chrono::{DateTime, TimeDelta, Utc}; use kube::{ Api, Client, Resource, api::{ObjectMeta, Patch, PatchParams}, diff --git a/test_utils/src/mock_client.rs b/test_utils/src/mock_client.rs index c74aa964..dea125ef 100644 --- a/test_utils/src/mock_client.rs +++ b/test_utils/src/mock_client.rs @@ -5,7 +5,8 @@ use http::{Method, Request, Response, StatusCode}; use kube::api::ObjectMeta; -use kube::{Client, client::Body, error::ErrorResponse}; +use kube::core::{Status, response::StatusSummary}; +use kube::{Client, client::Body}; use serde::Serialize; use std::fmt::Debug; use std::sync::atomic::{AtomicU32, Ordering}; @@ -58,11 +59,12 @@ async fn create_response>>( StatusCode::BAD_REQUEST => ("bad request", "BadRequest"), _ => (unknown_msg.as_str(), "Unknown"), }; - let error_response = ErrorResponse { - status: "Failure".to_string(), + let error_response = Status { + status: Some(StatusSummary::Failure), message: message.to_string(), reason: reason.to_string(), code: status_code.as_u16(), + ..Default::default() }; let error_json = serde_json::to_string(&error_response).unwrap(); (Body::from(error_json.into_bytes()), status_code) @@ -152,7 +154,7 @@ async fn test_error< count_check!(1, server, |client| { let err = action(client).await.unwrap_err(); let msg = "internal server error"; - assert_kube_api_error!(err, 500, "ServerTimeout", msg, "Failure"); + assert_kube_api_error!(err, 500, "ServerTimeout", msg, Some(StatusSummary::Failure)); }); }