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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 0F42C60A57 for ; Thu, 3 Sep 2020 11:39:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F38C717799 for ; Thu, 3 Sep 2020 11:39:36 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 6EB3417791 for ; Thu, 3 Sep 2020 11:39:36 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 37D74449A5 for ; Thu, 3 Sep 2020 11:39:36 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Thu, 3 Sep 2020 11:39:35 +0200 Message-Id: <20200903093935.18536-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.086 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pbs-devel] [PATCH proxmox-backup] server/worker_task: fix 'unknown' status for some big task logs X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2020 09:39:37 -0000 when trying to parse the task status, we seek 8k from the end which may be into the middle of a line, so the datetime parsing can fail (when the log message contains ': ') so try the next line when the first datetime parsing fails if it was really a broken datetime, we now return either the datetime of the next line or an 'Unknown' TaskState (which was the fallback of most call sites anyway) Signed-off-by: Dominik Csapak --- we could save the error for later returning, but since that does not matter most of the time i did not do that but if wanted i can send a v2 or fixup for that src/server/worker_task.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs index a9e4a36a..f6d12ac3 100644 --- a/src/server/worker_task.rs +++ b/src/server/worker_task.rs @@ -209,14 +209,25 @@ pub fn upid_read_status(upid: &UPID) -> Result { let reader = BufReader::new(file); + let mut first_line = true; for line in reader.lines() { let line = line?; let mut iter = line.splitn(2, ": "); if let Some(time_str) = iter.next() { - endtime = chrono::DateTime::parse_from_rfc3339(time_str) - .map_err(|err| format_err!("cannot parse '{}': {}", time_str, err))? - .timestamp(); + let dt_parse_res = chrono::DateTime::parse_from_rfc3339(time_str) + .map_err(|err| format_err!("cannot parse timestamp '{}': {}", time_str, err)); + endtime = if first_line { + first_line = false; + match dt_parse_res { + Ok(dt) => dt.timestamp(), + // we maybe seeked into the middle of a line, + // so ignore errors on the first + Err(_) => continue, + } + } else { + dt_parse_res?.timestamp() + }; } else { continue; } -- 2.20.1