From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [RFC proxmox-backup 1/8] api-types: jobs: add sanity checks job types
Date: Wed, 13 Dec 2023 16:38:12 +0100 [thread overview]
Message-ID: <20231213153819.391392-2-c.ebner@proxmox.com> (raw)
In-Reply-To: <20231213153819.391392-1-c.ebner@proxmox.com>
Defines the required types for managing sanity check jobs via the API.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
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("<calendar-event>")
.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("<calendar-event>")
+ .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<u8>,
+ /// Send job email notification to this user
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub notify_user: Option<Userid>,
+}
+
+#[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<String>,
+
+ /// 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
next prev parent reply other threads:[~2023-12-13 15:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-13 15:38 [pbs-devel] [RFC proxmox-backup 0/8] implement sanity check jobs Christian Ebner
2023-12-13 15:38 ` Christian Ebner [this message]
2023-12-13 15:38 ` [pbs-devel] [RFC proxmox-backup 2/8] config: implement sanity check job configuration Christian Ebner
2023-12-13 15:38 ` [pbs-devel] [RFC proxmox-backup 3/8] api: config: sanity check jobs api endpoints Christian Ebner
2023-12-13 15:38 ` [pbs-devel] [RFC proxmox-backup 4/8] server: add sanity check job email notifications Christian Ebner
2023-12-13 15:38 ` [pbs-devel] [RFC proxmox-backup 5/8] server: implement sanity check job Christian Ebner
2023-12-13 15:38 ` [pbs-devel] [RFC proxmox-backup 6/8] api: admin: add sanity check job api endpoints Christian Ebner
2023-12-13 15:38 ` [pbs-devel] [RFC proxmox-backup 7/8] manager: add sanity check jobs management cli commands Christian Ebner
2023-12-13 15:38 ` [pbs-devel] [RFC proxmox-backup 8/8] proxy: add sanity check task to scheduler Christian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231213153819.391392-2-c.ebner@proxmox.com \
--to=c.ebner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.