From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id C58A31FF0AF for ; Thu, 10 Sep 2026 18:20:41 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 2E92621567; Thu, 10 Sep 2026 18:20:38 +0200 (CEST) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.proxmox.com Subject: [PATCH test-tools 3/4] instance: source certificate and task types directly Date: Thu, 10 Sep 2026 18:20:29 +0200 Message-ID: <20260910162030.1776719-4-m.koeppl@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260910162030.1776719-1-m.koeppl@proxmox.com> References: <20260910162030.1776719-1-m.koeppl@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1789057223701 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.431 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: P5SLOJWKAJ7VWGWMXWM4ZCSZVOGBSBTW X-Message-ID-Hash: P5SLOJWKAJ7VWGWMXWM4ZCSZVOGBSBTW X-MailFrom: m.koeppl@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Both types pdm-api-types provided here were a detour. CertificateInfo is its re-export of proxmox_acme_api::CertificateInfo, so take it from there. TaskStateType is simple enough to warrant a direct declaration here. This leaves proxmox-test-instance free of pdm crates. Signed-off-by: Michael Köppl --- proxmox-test-instance/Cargo.toml | 2 +- proxmox-test-instance/src/api/pve_client.rs | 26 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/proxmox-test-instance/Cargo.toml b/proxmox-test-instance/Cargo.toml index 5a7c333..9cbfc9b 100644 --- a/proxmox-test-instance/Cargo.toml +++ b/proxmox-test-instance/Cargo.toml @@ -9,7 +9,6 @@ repository.workspace = true [dependencies] proxmox-test-common = { workspace = true } -pdm-api-types = { workspace = true } anyhow.workspace = true dirs-next.workspace = true @@ -28,6 +27,7 @@ termcolor.workspace = true tokio = { workspace = true, features = [ "rt" ]} toml.workspace = true +proxmox-acme-api.workspace = true proxmox-async.workspace = true proxmox-auth-api = { workspace = true, features = [ "api-types" ] } proxmox-client = { workspace = true, features = ["hyper-client"] } diff --git a/proxmox-test-instance/src/api/pve_client.rs b/proxmox-test-instance/src/api/pve_client.rs index f719895..4e4c1f4 100644 --- a/proxmox-test-instance/src/api/pve_client.rs +++ b/proxmox-test-instance/src/api/pve_client.rs @@ -2,7 +2,7 @@ use std::net::Ipv4Addr; use std::{collections::HashSet, sync::Arc, time::Duration}; use anyhow::{Context, Error, bail}; -use pdm_api_types::{CertificateInfo, TaskStateType}; +use proxmox_acme_api::CertificateInfo; use proxmox_client::{AuthenticationKind, Client, HttpApiClient, HttpApiResponse, TlsOptions}; use proxmox_http::HttpOptions; use proxmox_login::Login; @@ -33,6 +33,28 @@ const SHUTDOWN_TIMEOUT_SECS: u64 = 300; /// This does not cancel the server-side task; large or slow operations can outlive this deadline. const TASK_TIMEOUT: Duration = Duration::from_secs(60 * 60); +/// The state a finished PVE task ended up in, as derived from its exit status. +enum TaskStateType { + Ok, + Warning, + Error, + Unknown, +} + +impl TaskStateType { + fn new_from_str(status: &str) -> Self { + if status == "unknown" || status.is_empty() { + TaskStateType::Unknown + } else if status == "OK" { + TaskStateType::Ok + } else if status.starts_with("WARNINGS: ") { + TaskStateType::Warning + } else { + TaskStateType::Error + } + } +} + #[derive(Debug)] struct TaskFailure { upid: String, @@ -1049,7 +1071,7 @@ where let exitstatus = value["exitstatus"].as_str().unwrap_or("unknown"); return match TaskStateType::new_from_str(exitstatus) { - TaskStateType::OK | TaskStateType::Warning => Ok(()), + TaskStateType::Ok | TaskStateType::Warning => Ok(()), TaskStateType::Error | TaskStateType::Unknown => { bail!(TaskFailure { upid: upid.to_string(), -- 2.47.3