k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/experiment/ml/prowlog/collect-annotations.sh (about) 1 #!/bin/bash 2 # Copyright 2022 The Kubernetes Authors. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -o errexit 17 set -o nounset 18 set -o pipefail 19 20 if [[ $# != 3 ]]; then 21 echo "Usage: $(basename "$0") <lookback-duration> <project> <append-to-file>" >&2 22 echo >&2 23 echo " Scans google cloud logging for 'Saved selected lines' log messages" >&2 24 echo " and writes/appends them to the specified file as a tsv:" >&2 25 echo " <gcs-url> <start-line> <end-line>" >&2 26 exit 1 27 fi 28 29 # TODO(fejta): provide a (preferred?) option to gather this info from GCS 30 31 fresh=$1 32 project=$2 33 location=$3 34 ( 35 set -o xtrace 36 gcloud logging read "--project=$project" \ 37 'jsonPayload.msg:"Saved selected lines"' \ 38 "--freshness=$fresh" \ 39 --format='value(jsonPayload.artifact,jsonPayload.start,jsonPayload.end)' \ 40 | tee -a "$location" 41 ) 42 sort -u -o "$location" "$location"