Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSravan Kumar Lakkimsetti2017-05-04 07:36:47 -0400
committerSravan Kumar Lakkimsetti2017-05-04 07:39:26 -0400
commit658169d4e7298272fbc0d3f2f6767bb029f9ae41 (patch)
tree882d5d31c7262bcc4bd7189a388440999ae55100 /production
parentbb68cf6cd8b76e2eaf9f9ca918e5a46a411bedb2 (diff)
downloadeclipse.platform.releng.aggregator-658169d4e7298272fbc0d3f2f6767bb029f9ae41.tar.gz
eclipse.platform.releng.aggregator-658169d4e7298272fbc0d3f2f6767bb029f9ae41.tar.xz
eclipse.platform.releng.aggregator-658169d4e7298272fbc0d3f2f6767bb029f9ae41.zip
Bug 507271 - Implement new build retention policy for I-builds
Change-Id: If4d27cac3acea6e182d82ae6341d3b0a4b35563e Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
Diffstat (limited to 'production')
-rwxr-xr-xproduction/sdk/cleaners/dailyCleanDownloads.sh93
1 files changed, 75 insertions, 18 deletions
diff --git a/production/sdk/cleaners/dailyCleanDownloads.sh b/production/sdk/cleaners/dailyCleanDownloads.sh
index 72c24525..c3868ba2 100755
--- a/production/sdk/cleaners/dailyCleanDownloads.sh
+++ b/production/sdk/cleaners/dailyCleanDownloads.sh
@@ -21,9 +21,44 @@ fi
# Utility to clean build machine
echo -e "\n\tDaily clean of ${HOSTNAME} download server on $(date )\n"
+#
+# Checks whether a build can be retained or not.
+# returns 0 if the build can be retained
+#
+function canBeRetained ()
+{
+ retval=1
+ buildName=$1
+ grep BUILD_FAILED ${buildName}/buildproperties.shsource >/dev/null 2>&1
+ if [ $? -ne 0 ]; then #build didn't fail
+ if [ -f "${buildName}/buildUnstable" ]; then #build is marked unstable so should not be retained
+ retval=1
+ else
+ retval=0
+ fi
+ fi
+ return $retval
+}
+
+#
+# remove a build
+#
+
+function removeBuild ()
+{
+ buildName=$1
+ rm -fr $buildname
+ RC=$?
+ if [[ $RC = 0 ]];then
+ echo -e "Removed: $buildname"
+ else
+ echo -e "\n\tAn Error occurred removing $buildname. RC: $RC"
+ fi
+}
+
cDir="/home/data/httpd/download.eclipse.org/eclipse/downloads/drops4"
buildType="I*"
-allOldBuilds=$( find ${cDir} -maxdepth 1 -type d -ctime +5 -name "${buildType}" )
+allOldBuilds=$( find ${cDir} -maxdepth 1 -type d -ctime +5 -name "${buildType}"|sort )
nbuilds=$( find ${cDir} -maxdepth 1 -type d -name "${buildType}" | wc -l )
echo -e "\tNumber of I-builds before cleaning: $nbuilds"
#echo -e "\n\tDEBUG: allOldBuilds: \n${allOldBuilds}"
@@ -52,29 +87,51 @@ done
#DEBUG echo -e "\n\tnewest: \n${newest}";
areNotToDelete=$(printf '%s\n' "${newest[@]}" | paste -sd '|')
#echo "DEBUG: areNotToDelete: ${areNotToDelete}"
+
+currentWeekNum=0 #week number from start of the year user to identify the week in which the build is created
+found=0 #it will be 1 when we found a build that can be retained in that week
+
for buildname in ${allOldBuilds}; do
if [[ $buildname =~ $areNotToDelete ]]
then
echo -e "\tDEBUG: Not removed (since one of 4 newest, even though old): \n\t$buildname"
else
- buildId=$(basename $buildname)
- yy=$(echo $buildId|cut -b2-5)
- mm=$(echo $buildId|cut -b6-7)
- dd=$(echo $buildId|cut -b8-9)
- day=${mm}/${dd}/${yy}
- dayOfWeek=$(date -d $day +%u)
+ buildId=$(basename $buildname) #extract buildId
+ yy=$(echo $buildId|cut -b2-5) #extract year from buildId
+ mm=$(echo $buildId|cut -b6-7) #extract month
+ dd=$(echo $buildId|cut -b8-9) #extract day
+ day=${mm}/${dd}/${yy} #construct build date
+ dayOfWeek=$(date -d $day +%u) #get the day of the week like monday, tue, etc
+ weekNum=$(date -d $day +%U) #get the week number from start of the year
+
+ #special case for Sunday. unix considers sunday as the start of the week. but for us we need to consider
+ #monday as start of the week. For this purpose we subtract 1 to place the build in previous week
+ if [ $dayOfWeek -eq 7 ]; then
+ weekNum=$(expr $weekNum - 1)
+ if [ $weekNum -le 0 ]; then #check for the yearend
+ weekNum=53
+ fi
+ fi
- #Make sure donot remove I builds from Monday
- if [ $dayOfWeek != 1 ]
- then
- rm -fr $buildname
- RC=$?
- if [[ $RC = 0 ]]
- then
- echo -e "Removed: $buildname"
- else
- echo -e "\n\tAn Error occurred removing $buildname. RC: $RC"
- fi
+ canBeRetained ${buildname}
+ retain=$?
+
+ if [ $weekNum -eq $currentWeekNum ]; then
+ if [ $retain -eq 0 -a $found -ne 1 ]; then # we didn't found a build that can be retained in the current week
+ found=1
+ echo retaining $buildId
+ else
+ echo removing $buildId
+ fi
+ else #week changed
+ currentWeekNum=$weekNum
+ found=0
+ if [ $retain -eq 0 -a $dayOfWeek -eq 1 ]; then
+ found=1
+ echo retaining $buildId
+ else
+ echo removing $buildId
+ fi
fi
fi
done

Back to the top