api: status: graceful-degrade when a datastore lookup fails
This can happen if the underlying storage failed, in which case we do not want to fail the whole API call, as it should report the status of all datastores. So rather add the error inline to the related store entry and continue. Allows to nicely visualize those stores in the gui. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
5658504b90
commit
64591e731e
@ -55,6 +55,7 @@ use crate::config::acl::{
|
||||
},
|
||||
history: {
|
||||
type: Array,
|
||||
optional: true,
|
||||
description: "A list of usages of the past (last Month).",
|
||||
items: {
|
||||
type: Number,
|
||||
@ -69,6 +70,11 @@ use crate::config::acl::{
|
||||
of RRD data of the last Month. Missing if there are not enough data points yet.\
|
||||
If the estimate lies in the past, the usage is decreasing.",
|
||||
},
|
||||
"error": {
|
||||
type: String,
|
||||
optional: true,
|
||||
description: "An error description, for example, when the datastore could not be looked up.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -97,7 +103,19 @@ pub fn datastore_status(
|
||||
continue;
|
||||
}
|
||||
|
||||
let datastore = DataStore::lookup_datastore(&store)?;
|
||||
let datastore = match DataStore::lookup_datastore(&store) {
|
||||
Ok(datastore) => datastore,
|
||||
Err(err) => {
|
||||
list.push(json!({
|
||||
"store": store,
|
||||
"total": -1,
|
||||
"used": -1,
|
||||
"avail": -1,
|
||||
"error": err.to_string()
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let status = crate::tools::disks::disk_usage(&datastore.base_path())?;
|
||||
|
||||
let mut entry = json!({
|
||||
|
Loading…
Reference in New Issue
Block a user