online bottlenecks soak throughtputs
[releng.git] / utils / retention_script.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 The Linux Foundation and others
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #  http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 ##############################################################################
17
18 PATH=$PATH:/usr/local/bin/
19
20 #These are the only projects that generate artifacts
21 for x in armband ovsnfv fuel apex compass4nfv
22 do
23
24   echo "Looking at artifacts for project $x"
25   echo "In path gs://artifacts.opnfv.org/$x"
26
27   while IFS= read -r artifact; do
28
29     artifact_date="$(gsutil ls -L $artifact | grep "Creation time:" | awk '{print $4,$5,$6}')"
30     age=$(($(date +%s)-$(date -d"$artifact_date" +%s)))
31     daysold=$(($age/86400))
32
33     if [[ "$daysold" -gt "10" ]]; then
34       echo "$daysold Days old deleting: $(basename $artifact)"
35       gsutil rm "$artifact"
36     else
37       echo "$daysold Days old retaining: $(basename $artifact)"
38     fi
39
40   done < <(gsutil ls gs://artifacts.opnfv.org/"$x" |grep -v "/$")
41 done