From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 2571E954B7 for ; Mon, 26 Feb 2024 15:20:21 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 038C6109B4 for ; Mon, 26 Feb 2024 15:19:51 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 26 Feb 2024 15:19:50 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 282B447254 for ; Mon, 26 Feb 2024 15:19:50 +0100 (CET) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Mon, 26 Feb 2024 15:18:38 +0100 Message-ID: <20240226141943.822479-1-c.heiss@proxmox.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.005 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH installer] tui: install_progress: write low-level non-JSON messages to separate file X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Feb 2024 14:20:21 -0000 The low-level installer prints quite a few messages during the install to its stdout which are not JSON-formatted and thus parseable. Thus catch them early and write them to `/tmp/install-low-level.log`, to avoid polluting the log tty at /dev/tty2 with mostly useless parse errors. Signed-off-by: Christoph Heiss --- Nothing actually critical, but makes the log tty a lot more useful .. .../src/views/install_progress.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/proxmox-tui-installer/src/views/install_progress.rs b/proxmox-tui-installer/src/views/install_progress.rs index 4626fe4..c2c9ddf 100644 --- a/proxmox-tui-installer/src/views/install_progress.rs +++ b/proxmox-tui-installer/src/views/install_progress.rs @@ -6,6 +6,7 @@ use cursive::{ }; use serde::Deserialize; use std::{ + fs::File, io::{BufRead, BufReader, Write}, sync::{Arc, Mutex}, thread, @@ -86,6 +87,9 @@ impl InstallProgressView { .map_err(|err| format!("failed to serialize install config: {err}"))?; writeln!(writer).map_err(|err| format!("failed to write install config: {err}"))?; + let mut lowlevel_log = File::create("/tmp/install-low-level.log") + .map_err(|err| format!("failed to open low-level installer logfile: {err}"))?; + let writer = Arc::new(Mutex::new(writer)); for line in reader.lines() { @@ -94,11 +98,20 @@ impl InstallProgressView { Err(err) => return Err(format!("low-level installer exited early: {err}")), }; + // The low-level installer also spews the output of any command it runs on its + // stdout. Use a very simple heuricstic to determine whether it is actually JSON + // or not. + if !line.starts_with('{') || !line.ends_with('}') { + let _ = writeln!(lowlevel_log, "{}", line); + continue; + } + let msg = match serde_json::from_str::(&line) { Ok(msg) => msg, - Err(stray) => { + Err(err) => { // Not a fatal error, so don't abort the installation by returning - eprintln!("low-level installer: {stray}"); + eprintln!("low-level installer: error while parsing message: '{err}'"); + eprintln!(" original message was: '{line}'"); continue; } }; -- 2.43.0