5
0
mirror of git://git.proxmox.com/git/proxmox-backup.git synced 2025-01-08 21:18:07 +03:00

disk: zfs: improve error logging for zfs commands

zfs errors might include a newline in the output (e.g. when trying to
create a mirror on two differently sized disks), which trips up our
task log status parser since that expectes a 'TASK {status}' on the
beginning of the first line.

print the error from zfs into the log and bail out with a short notice
to check the task log

this fixes the 'unknown error' issue in the ui when an error happnes
during the zfs commands

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2022-11-29 09:16:11 +01:00 committed by Wolfgang Bumiller
parent ff2910666b
commit 79de842ca3

View File

@ -3,7 +3,7 @@ use serde_json::{json, Value};
use proxmox_router::{Permission, Router, RpcEnvironment, RpcEnvironmentType};
use proxmox_schema::api;
use proxmox_sys::task_log;
use proxmox_sys::{task_error, task_log};
use pbs_api_types::{
DataStoreConfig, ZfsCompressionType, ZfsRaidLevel, ZpoolListItem, DATASTORE_SCHEMA,
@ -277,8 +277,13 @@ pub fn create_zpool(
task_log!(worker, "# {:?}", command);
let output = proxmox_sys::command::run_command(command, None)?;
task_log!(worker, "{}", output);
match proxmox_sys::command::run_command(command, None) {
Ok(output) => task_log!(worker, "{output}"),
Err(err) => {
task_error!(worker, "{err}");
bail!("Error during 'zpool create', see task log for more details");
}
};
if std::path::Path::new("/lib/systemd/system/zfs-import@.service").exists() {
let import_unit = format!(
@ -295,8 +300,13 @@ pub fn create_zpool(
}
command.args(["relatime=on", &name]);
task_log!(worker, "# {:?}", command);
let output = proxmox_sys::command::run_command(command, None)?;
task_log!(worker, "{}", output);
match proxmox_sys::command::run_command(command, None) {
Ok(output) => task_log!(worker, "{output}"),
Err(err) => {
task_error!(worker, "{err}");
bail!("Error during 'zfs set', see task log for more details");
}
};
if add_datastore {
let lock = pbs_config::datastore::lock_config()?;