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 <s.lendl@proxmox.com>
Originally-by: Gabriel Goller <g.goller@proxmox.com>
Tested-by: Gabriel Goller <g.goller@proxmox.com>
Reviewd-by: Gabriel Goller <g.goller@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
Stefan Lendl 2024-04-18 12:16:57 +02:00 committed by Fabian Grünbichler
parent bec18b8e60
commit 163732177d

View File

@ -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<String>,
/// Sum of removed bytes.
#[serde(skip_serializing_if = "Option::is_none")]
pub removed_bytes: Option<u64>,
/// Number of removed chunks
#[serde(skip_serializing_if = "Option::is_none")]
pub removed_chunks: Option<usize>,
/// Sum of pending bytes
#[serde(skip_serializing_if = "Option::is_none")]
pub pending_bytes: Option<u64>,
/// Number of pending chunks
#[serde(skip_serializing_if = "Option::is_none")]
pub pending_chunks: Option<usize>,
/// Schedule of the gc job
#[serde(skip_serializing_if = "Option::is_none")]
pub schedule: Option<String>,
/// Time of the next gc run
#[serde(skip_serializing_if = "Option::is_none")]
pub next_run: Option<i64>,
/// Endtime of the last gc run
#[serde(skip_serializing_if = "Option::is_none")]
pub last_run_endtime: Option<i64>,
/// State of the last gc run
#[serde(skip_serializing_if = "Option::is_none")]
pub last_run_state: Option<String>,
/// Duration of last gc run
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<i64>,
}
#[api(
properties: {
"gc-status": {