tools: fix date parsing in patchwork polling

Message ID 20250331111926.3404719-1-david.marchand@redhat.com (mailing list archive)
State New
Headers
Series tools: fix date parsing in patchwork polling |

Commit Message

David Marchand March 31, 2025, 11:19 a.m. UTC
Though it is not fully understood why (maybe some system upgrade..?),
parsing date is now failing on some long running Debian system.

Specify date format earlier in the command line.

Fixes: baaec1836189 ("tools: filter new patchwork IDs by date")

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 tools/poll-pw | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Ali Alnubani April 8, 2025, 6:42 p.m. UTC | #1
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Monday, March 31, 2025 2:19 PM
> To: ci@dpdk.org
> Cc: NBU-Contact-Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>;
> aconole@redhat.com; Ali Alnubani <alialnu@nvidia.com>
> Subject: [PATCH] tools: fix date parsing in patchwork polling
> 
> Though it is not fully understood why (maybe some system upgrade..?),
> parsing date is now failing on some long running Debian system.

It's because the last date and time that were written to the file coincide with the Daylight-Saving Time transition.
That timestamp was invalid in the server's timezone.

> 
> Specify date format earlier in the command line.

I think what fixed it was adding the --utc arg.

> 
> Fixes: baaec1836189 ("tools: filter new patchwork IDs by date")
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  tools/poll-pw | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/poll-pw b/tools/poll-pw
> index c1df012..4c7fafd 100755
> --- a/tools/poll-pw
> +++ b/tools/poll-pw
> @@ -47,7 +47,7 @@ if [ ! -f "$since_file" ] ; then
>  	exit 1
>  fi
> 
> -if ! date -d "$(cat $since_file | tr '\n' ' ')" >/dev/null 2>&1 ; then
> +if ! date --utc '+%FT%T' -d $(cat $since_file | tr '\n' ' ') >/dev/null 2>&1 ; then
>  	printf "The file '$since_file' doesn't contain a valid date format.\n\n" >&2
>  	exit 1
>  fi
> @@ -77,7 +77,7 @@ callcmd () # <patchwork id>
> 
>  while true ; do
>  	date_now=$(date --utc '+%FT%T')
> -	since=$(date -d $(cat $since_file | tr '\n' ' ') '+%FT%T')
> +	since=$(date --utc '+%FT%T' -d $(cat $since_file | tr '\n' ' '))
>  	page=1
>  	while true ; do
>  		ids=$(curl -s "${URL}&page=${page}&since=${since}" |
> --
> 2.48.1

Thanks for addressing this, David.

Acked-by: Ali Alnubani <alialnu@nvidia.com>

- Ali
  
Aaron Conole April 14, 2025, 6:41 p.m. UTC | #2
David Marchand <david.marchand@redhat.com> writes:

> Though it is not fully understood why (maybe some system upgrade..?),
> parsing date is now failing on some long running Debian system.
>
> Specify date format earlier in the command line.
>
> Fixes: baaec1836189 ("tools: filter new patchwork IDs by date")
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---

Applied, thanks Ali and David.
  

Patch

diff --git a/tools/poll-pw b/tools/poll-pw
index c1df012..4c7fafd 100755
--- a/tools/poll-pw
+++ b/tools/poll-pw
@@ -47,7 +47,7 @@  if [ ! -f "$since_file" ] ; then
 	exit 1
 fi
 
-if ! date -d "$(cat $since_file | tr '\n' ' ')" >/dev/null 2>&1 ; then
+if ! date --utc '+%FT%T' -d $(cat $since_file | tr '\n' ' ') >/dev/null 2>&1 ; then
 	printf "The file '$since_file' doesn't contain a valid date format.\n\n" >&2
 	exit 1
 fi
@@ -77,7 +77,7 @@  callcmd () # <patchwork id>
 
 while true ; do
 	date_now=$(date --utc '+%FT%T')
-	since=$(date -d $(cat $since_file | tr '\n' ' ') '+%FT%T')
+	since=$(date --utc '+%FT%T' -d $(cat $since_file | tr '\n' ' '))
 	page=1
 	while true ; do
 		ids=$(curl -s "${URL}&page=${page}&since=${since}" |