damccorm commented on code in PR #24770:
URL: https://github.com/apache/beam/pull/24770#discussion_r1059135734


##########
.test-infra/tools/stale_bq_datasets_cleaner.sh:
##########
@@ -33,11 +34,13 @@ for dataset in ${BQ_DATASETS[@]}; do
     if [[ $dataset =~ $template ]]; then
       # The BQ API reports LAST MODIFIED TIME in miliseconds, while unix works 
in seconds since epoch
       # thus why we need to convert to seconds.
-      LAST_MODIFIED_MS=`bq --format=json --project_id=$PROJECT show $dataset | 
jq -r .lastModifiedTime`
+      [[ `bq --format=json --project_id=$PROJECT show $dataset` =~ 
\"lastModifiedTime\":\"([0-9]+)\" ]]
+      LAST_MODIFIED_MS=${BASH_REMATCH[1]}
       LAST_MODIFIED=$(($LAST_MODIFIED_MS / 1000))
       if [[ $GRACE_PERIOD -gt $LAST_MODIFIED ]]; then
-        echo "Deleting $dataset (modified `date -d @$LAST_MODIFIED`) Command 
bq --project_id=$PROJECT rm -r -f $dataset"
-        bq --project_id=$PROJECT rm -r -f $dataset
+        echo "Deleting $dataset (modified `date -d @$LAST_MODIFIED`)"
+        # do not fail the script if delete dataset fail
+        bq --project_id=$PROJECT rm -r -f $dataset || true

Review Comment:
   Hm, are we able to manually clean up the remaining datasets? Have you 
narrowed down which ones are the problem?



##########
.test-infra/tools/stale_bq_datasets_cleaner.sh:
##########
@@ -33,11 +34,13 @@ for dataset in ${BQ_DATASETS[@]}; do
     if [[ $dataset =~ $template ]]; then
       # The BQ API reports LAST MODIFIED TIME in miliseconds, while unix works 
in seconds since epoch
       # thus why we need to convert to seconds.
-      LAST_MODIFIED_MS=`bq --format=json --project_id=$PROJECT show $dataset | 
jq -r .lastModifiedTime`
+      [[ `bq --format=json --project_id=$PROJECT show $dataset` =~ 
\"lastModifiedTime\":\"([0-9]+)\" ]]
+      LAST_MODIFIED_MS=${BASH_REMATCH[1]}
       LAST_MODIFIED=$(($LAST_MODIFIED_MS / 1000))
       if [[ $GRACE_PERIOD -gt $LAST_MODIFIED ]]; then
-        echo "Deleting $dataset (modified `date -d @$LAST_MODIFIED`) Command 
bq --project_id=$PROJECT rm -r -f $dataset"
-        bq --project_id=$PROJECT rm -r -f $dataset
+        echo "Deleting $dataset (modified `date -d @$LAST_MODIFIED`)"
+        # do not fail the script if delete dataset fail
+        bq --project_id=$PROJECT rm -r -f $dataset || true

Review Comment:
   This is the only part of the PR I'm not sure about, arguably we want the job 
to fail if this doesn't work - maybe we can catch the error, log the failing 
dataset, continue through the loop, then fail at the end?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to