From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 47D2FBA16B for ; Wed, 13 Dec 2023 16:38:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2B332C7B4 for ; Wed, 13 Dec 2023 16:38:29 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 13 Dec 2023 16:38:28 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E79E4472D9 for ; Wed, 13 Dec 2023 16:38:27 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Wed, 13 Dec 2023 16:38:12 +0100 Message-Id: <20231213153819.391392-2-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231213153819.391392-1-c.ebner@proxmox.com> References: <20231213153819.391392-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.056 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [jobs.rs] Subject: [pbs-devel] [RFC proxmox-backup 1/8] api-types: jobs: add sanity checks job types X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2023 15:38:59 -0000 Defines the required types for managing sanity check jobs via the API. Signed-off-by: Christian Ebner --- pbs-api-types/src/jobs.rs | 106 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/pbs-api-types/src/jobs.rs b/pbs-api-types/src/jobs.rs index 1f5b3cf1..4f6b2cc7 100644 --- a/pbs-api-types/src/jobs.rs +++ b/pbs-api-types/src/jobs.rs @@ -57,12 +57,28 @@ pub const VERIFICATION_SCHEDULE_SCHEMA: Schema = .type_text("") .schema(); +pub const SANITY_CHECK_SCHEDULE_SCHEMA: Schema = + StringSchema::new("Run sanity check job at specified schedule.") + .format(&ApiStringFormat::VerifyFn( + proxmox_time::verify_calendar_event, + )) + .type_text("") + .schema(); + pub const REMOVE_VANISHED_BACKUPS_SCHEMA: Schema = BooleanSchema::new( "Delete vanished backups. This remove the local copy if the remote backup was deleted.", ) .default(false) .schema(); +pub const DATASTORE_USAGE_FULL_THRESHOLD_DEFAULT: u8 = 90; +pub const DATASTORE_USAGE_FULL_THRESHOLD_SCHEMA: Schema = + IntegerSchema::new("Datastore usage threshold level in percent for the datastore being full.") + .minimum(1) + .maximum(100) + .default(DATASTORE_USAGE_FULL_THRESHOLD_DEFAULT as isize) + .schema(); + #[api( properties: { "next-run": { @@ -753,3 +769,93 @@ pub struct PruneJobStatus { #[serde(flatten)] pub status: JobScheduleStatus, } + +#[api( + properties: { + "datastore-usage-full-threshold": { + schema: DATASTORE_USAGE_FULL_THRESHOLD_SCHEMA, + optional: true, + }, + "notify-user": { + optional: true, + type: Userid, + }, + } +)] +#[derive(Serialize, Deserialize, Default, Updater, Clone, PartialEq)] +#[serde(rename_all = "kebab-case")] +/// Sanity check options +pub struct SanityCheckJobOptions { + #[serde(skip_serializing_if = "Option::is_none")] + pub datastore_usage_full_threshold: Option, + /// Send job email notification to this user + #[serde(skip_serializing_if = "Option::is_none")] + pub notify_user: Option, +} + +#[api( + properties: { + id: { + schema: JOB_ID_SCHEMA, + }, + disable: { + type: Boolean, + optional: true, + default: false, + }, + schedule: { + schema: SANITY_CHECK_SCHEDULE_SCHEMA, + }, + comment: { + optional: true, + schema: SINGLE_LINE_COMMENT_SCHEMA, + }, + options: { + type: SanityCheckJobOptions, + }, + }, +)] +#[derive(Deserialize, Serialize, Updater, Clone, PartialEq)] +#[serde(rename_all = "kebab-case")] +/// Sanity check configuration. +pub struct SanityCheckJobConfig { + /// Unique ID to address this job + #[updater(skip)] + pub id: String, + + /// Flag to disable job + #[serde(default, skip_serializing_if = "is_false")] + #[updater(serde(skip_serializing_if = "Option::is_none"))] + pub disable: bool, + + /// When to schedule this job in calendar event notation + pub schedule: String, + + /// Additional comment for this job + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, + + /// Configuration options for this job + #[serde(flatten)] + pub options: SanityCheckJobOptions, +} + +#[api( + properties: { + config: { + type: SanityCheckJobConfig, + }, + status: { + type: JobScheduleStatus, + }, + }, +)] +#[derive(Serialize, Deserialize, Clone, PartialEq)] +#[serde(rename_all = "kebab-case")] +/// Status of sanity check job +pub struct SanityCheckJobStatus { + #[serde(flatten)] + pub config: SanityCheckJobConfig, + #[serde(flatten)] + pub status: JobScheduleStatus, +} -- 2.39.2