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 5BE3260A78 for ; Thu, 3 Sep 2020 12:37:38 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 496C717E9D for ; Thu, 3 Sep 2020 12:37:08 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 6FE6317E8C for ; Thu, 3 Sep 2020 12:37:06 +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 3AA80449EF for ; Thu, 3 Sep 2020 12:37:06 +0200 (CEST) Date: Thu, 3 Sep 2020 12:36:23 +0200 (CEST) From: Dietmar Maurer To: Proxmox Backup Server development discussion , Dominik Csapak Message-ID: <2037251149.686.1599129383852@webmail.proxmox.com> In-Reply-To: <20200903093935.18536-1-d.csapak@proxmox.com> References: <20200903093935.18536-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.3-Rev21 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.111 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com] Subject: Re: [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 10:37:38 -0000 cant we simply skip the first line? let reader = BufReader::new(file); let lines = reader.lines(); lines.next()?; // skip first // Then parse the rest for line in lines { } > On 09/03/2020 11:39 AM Dominik Csapak wrote: > > > 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 > > > > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel