From 163732177d450c2902a480dc88161b322b696606 Mon Sep 17 00:00:00 2001 From: Stefan Lendl Date: Thu, 18 Apr 2024 12:16:57 +0200 Subject: [PATCH] api: garbage collect job status Adds an api endpoint on the datastore that reports the gc job status such as: - Schedule - State (of last run) - Duration (of last run) - Last Run - Next Run (if scheduled) - Pending Chunks (of last run) - Pending Bytes (of last run) - Removed Chunks (of last run) - Removed Bytes (of last run) Adds a dedicated endpoint admin/gc that reports gc job status for all datastores including the onces without a gc-schedule. Signed-off-by: Stefan Lendl Originally-by: Gabriel Goller Tested-by: Gabriel Goller Reviewd-by: Gabriel Goller Tested-by: Lukas Wagner Reviewed-by: Lukas Wagner --- pbs-api-types/src/datastore.rs | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 8a8ec12d..c6641655 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -1307,6 +1307,52 @@ pub struct GarbageCollectionStatus { pub still_bad: usize, } +#[api( + properties: { + "last-run-upid": { + optional: true, + type: UPID, + }, + }, +)] +#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "kebab-case")] +/// Garbage Collection general info +pub struct GarbageCollectionJobStatus { + /// Datastore + pub store: String, + /// upid of the last run gc job + #[serde(skip_serializing_if = "Option::is_none")] + pub last_run_upid: Option, + /// Sum of removed bytes. + #[serde(skip_serializing_if = "Option::is_none")] + pub removed_bytes: Option, + /// Number of removed chunks + #[serde(skip_serializing_if = "Option::is_none")] + pub removed_chunks: Option, + /// Sum of pending bytes + #[serde(skip_serializing_if = "Option::is_none")] + pub pending_bytes: Option, + /// Number of pending chunks + #[serde(skip_serializing_if = "Option::is_none")] + pub pending_chunks: Option, + /// Schedule of the gc job + #[serde(skip_serializing_if = "Option::is_none")] + pub schedule: Option, + /// Time of the next gc run + #[serde(skip_serializing_if = "Option::is_none")] + pub next_run: Option, + /// Endtime of the last gc run + #[serde(skip_serializing_if = "Option::is_none")] + pub last_run_endtime: Option, + /// State of the last gc run + #[serde(skip_serializing_if = "Option::is_none")] + pub last_run_state: Option, + /// Duration of last gc run + #[serde(skip_serializing_if = "Option::is_none")] + pub duration: Option, +} + #[api( properties: { "gc-status": {