* [pbs-devel] [PATCH proxmox-backup] disk: zfs: improve error logging for zfs commands
@ 2022-11-29 8:16 Dominik Csapak
2023-01-05 9:37 ` [pbs-devel] applied: " Wolfgang Bumiller
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2022-11-29 8:16 UTC (permalink / raw)
To: pbs-devel
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>
---
src/api2/node/disks/zfs.rs | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs
index 3efc8a05..2dcd6cfd 100644
--- a/src/api2/node/disks/zfs.rs
+++ b/src/api2/node/disks/zfs.rs
@@ -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()?;
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup] disk: zfs: improve error logging for zfs commands
2022-11-29 8:16 [pbs-devel] [PATCH proxmox-backup] disk: zfs: improve error logging for zfs commands Dominik Csapak
@ 2023-01-05 9:37 ` Wolfgang Bumiller
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2023-01-05 9:37 UTC (permalink / raw)
To: Dominik Csapak; +Cc: pbs-devel
applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-05 9:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 8:16 [pbs-devel] [PATCH proxmox-backup] disk: zfs: improve error logging for zfs commands Dominik Csapak
2023-01-05 9:37 ` [pbs-devel] applied: " Wolfgang Bumiller
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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal