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 4DC9760B0C for ; Thu, 3 Sep 2020 12:46:48 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4B48C17FEC for ; Thu, 3 Sep 2020 12:46:48 +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 66C6817FDF for ; Thu, 3 Sep 2020 12:46:47 +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 3E3B5449F2; Thu, 3 Sep 2020 12:46:47 +0200 (CEST) To: Dietmar Maurer , Proxmox Backup Server development discussion References: <20200903093935.18536-1-d.csapak@proxmox.com> <2037251149.686.1599129383852@webmail.proxmox.com> From: Dominik Csapak Message-ID: Date: Thu, 3 Sep 2020 12:46:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Thunderbird/81.0 MIME-Version: 1.0 In-Reply-To: <2037251149.686.1599129383852@webmail.proxmox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.768 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.324 Looks like a legit reply (A) 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:46:48 -0000 On 9/3/20 12:36 PM, Dietmar Maurer wrote: > 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 { > > } no for two reasons: if the task log contains only one line (this happens, e.g. 'TASK OK') or if the last Log line is exactly 8k long (i am not sure that could happen) for the first we could check if the file is < 8k long > >> 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