reproducible_html_nodes_info.sh 10.6 KB
Newer Older
1
#!/bin/bash
2
# vim: set noexpandtab:
3

4
# Copyright © 2015-2019 Holger Levsen <holger@layer-acht.org>
5
#           ©      2018 Mattia Rizzolo <mattia@debian.org>
6 7
# released under the GPLv=2

8 9
set -e

10 11 12 13 14 15 16
DEBUG=false
. /srv/jenkins/bin/common-functions.sh
common_init "$@"

# common code defining db access
. /srv/jenkins/bin/reproducible_common.sh

17 18 19
explain_nodes() {
	case $JENKINS_NODENAME in
		jenkins)	;;
20
		profitbricks7)	write_page "<br /><small>(buildinfos.debian.net)</small>" ;;
21 22
		profitbricks9)	write_page "<br /><small>(jenkins.d.n rebootstrap jobs)</small>" ;;
		profitbricks10)	write_page "<br /><small>(jenkins.d.n chroot-installation jobs)</small>" ;;
23
		osuosl167)	write_page "<br /><small>(http-proxy for osuosl nodes)</small>" ;;
24
		osuosl168)	write_page "<br /><small>(r-b F-Droid builds)</small>" ;;
25 26
		osuosl169)	write_page "<br /><small>(r-b Archlinux builds)</small>" ;;
		osuosl170)	write_page "<br /><small>(r-b Archlinux builds)</small>" ;;
27
		osuosl171)	write_page "<br /><small>(r-b OpenWrt, NetBSD, Coreboot builds)</small>" ;;
28 29
		osuosl172)	write_page "<br /><small>(r-b OpenWrt, Coreboot builds)</small>" ;;
		osuosl173)	write_page "<br /><small>(r-b Debian rebuilder)</small>" ;;
30
		osuosl174)	write_page "<br /><small>(r-b openSUSE)</small>" ;;
31 32 33 34
		*)		write_page "<br /><small>(r-b Debian builds)</small>" ;;
	esac
}

35 36 37 38 39
build_nodes_health_page() {
	#
	# build node health page
	#
	VIEW=nodes_health
40 41 42 43
	PAGE=index_${VIEW}.html
	ARCH=amd64
	SUITE=unstable
	echo "$(date -u) - starting to write $PAGE page."
44
	write_page_header $VIEW "Nodes health overview"
45 46 47 48
	write_page "<p style=\"clear:both;\">"
	for ARCH in ${ARCHS} ; do
		write_page "<h3>$ARCH nodes</h3>"
		write_page "<table>"
49 50 51 52 53 54 55 56 57 58
		write_page "<tr><th>Name</th><th>health check</th><th>maintenance</th><th>Debian worker.log links</th>"
			for SUITE in ${SUITES} ; do
				write_page "<th>pbuilder setup $SUITE</th>"
			done
			for SUITE in ${SUITES} ; do
				if [ "$SUITE" = "experimental" ]; then
					continue
				fi
				write_page "<th>schroot setup $SUITE</th>"
			done
59
		write_page "</tr>"
60 61 62 63 64 65 66
		# the following for-loop is a hack to insert nodes which are not part of the
		# Debian Reproducible Builds node network but are using for reproducible builds
		# tests of other projects…
		REPRODUCIBLE_NODES="jenkins"

		for NODE in $BUILD_NODES ; do
			REPRODUCIBLE_NODES="$REPRODUCIBLE_NODES $NODE"
67
			if [ "$NODE" = "profitbricks-build6-i386.debian.net" ] ; then
68 69
				# pb9 	rebootstrap jobs
				# pb10	chroot jobs
70
				REPRODUCIBLE_NODES="$REPRODUCIBLE_NODES profitbricks-build9-amd64.debian.net profitbricks-build10-amd64.debian.net"
71 72
			fi
		done
73
		for NODE in $REPRODUCIBLE_NODES ; do
74 75 76 77 78 79 80 81
			if [ -z "$(echo $NODE | grep $ARCH || true)" ] && [ "$NODE" != "jenkins" ] ; then
				continue
			elif [ "$NODE" = "jenkins" ] && [ "$ARCH" != "amd64" ] ; then
				continue
			fi
			if [ "$NODE" = "jenkins" ] ; then
				JENKINS_NODENAME=jenkins
				NODE="jenkins.debian.net"
82
			else
83 84 85 86 87
				case $ARCH in
					amd64|i386) 	JENKINS_NODENAME=$(echo $NODE | cut -d "-" -f1-2|sed 's#-build##' ) ;;
					arm64) 		JENKINS_NODENAME=$(echo $NODE | cut -d "-" -f1-2|sed 's#-sled##' ) ;;
					armhf) 		JENKINS_NODENAME=$(echo $NODE | cut -d "-" -f1) ;;
				esac
88
			fi
89
			write_page "<tr><td>$JENKINS_NODENAME"
90
			explain_nodes
91 92 93 94 95
			write_page "</td>"
			# health check
			URL="https://jenkins.debian.net/view/reproducible/view/Node_maintenance/job/reproducible_node_health_check_${ARCH}_${JENKINS_NODENAME}"
			BADGE="$URL/badge/icon"
			write_page "<td><a href='$URL'><img src='$BADGE' /></a></td>"
96 97 98 99
			# maintenance
			URL="https://jenkins.debian.net/view/reproducible/view/Node_maintenance/job/reproducible_maintenance_${ARCH}_${JENKINS_NODENAME}"
			BADGE="$URL/badge/icon"
			write_page "<td><a href='$URL'><img src='$BADGE' /></a></td>"
100
			# mark offline nodes
101
			JENKINS_OFFLINE_GIT_LIST=~jenkins-adm/jenkins.debian.net/jenkins-home/offline_nodes
102 103
			if [ -f "$JENKINS_OFFLINE_GIT_LIST" ] && ! grep -q "$NODE" "$JENKINS_OFFLINE_GIT_LIST" \
			 && ( [ -f "$JENKINS_OFFLINE_LIST" ] && grep -q "$NODE" "$JENKINS_OFFLINE_LIST" ) ; then
104
				write_page '</td><td colspan="9" style="text-align: center;"><span style="font-style: italic;">temporarily marked offline by jenkins</span></td>'
105 106
				continue
			elif [ -f "$JENKINS_OFFLINE_LIST" ] && grep -q "$NODE" "$JENKINS_OFFLINE_LIST"; then
107
				write_page '</td><td colspan="9" style="text-align: center;"><span style="font-style: italic;">offline</span></td>'
108
				continue
109 110 111 112
			fi
			# worker.log links
			case $JENKINS_NODENAME in
				jenkins)	write_page "<td></td>" ;;
113
				profitbricks7)	write_page "<td></td>" ;;
114
				profitbricks9)	write_page "<td></td>" ;;
115
				profitbricks10)	write_page "<td></td>" ;;
116
				osuosl*)	write_page "<td></td>" ;;
117 118 119 120 121 122 123 124 125 126 127 128 129
				*)		write_page "<td>"
						SHORTNAME=$(echo $NODE | cut -d '.' -f1)
						for WORKER in $(grep "${ARCH}_" /srv/jenkins/bin/reproducible_build_service.sh | grep -v \# |grep $SHORTNAME | cut -d ')' -f1) ; do
							write_page "<a href='https://jenkins.debian.net/userContent/reproducible/debian/build_service/${WORKER}/worker.log'>"
							write_page "$(echo $WORKER |cut -d '_' -f2)</a> "
						done
						write_page "</td>"
						;;
			esac
			# pbuilder setup
			for SUITE in ${SUITES} ; do
				case $JENKINS_NODENAME in
					jenkins)	write_page "<td></td>" ;;
130
					profitbricks7)	write_page "<td></td>" ;;
131
					profitbricks9)	write_page "<td></td>" ;;
132
					profitbricks10)	write_page "<td></td>" ;;
133
					osuosl*)	write_page "<td></td>" ;;
134 135 136 137 138 139 140 141 142 143
					*)		URL="https://jenkins.debian.net/view/reproducible/view/Debian_setup_${ARCH}/job/reproducible_setup_pbuilder_${SUITE}_${ARCH}_${JENKINS_NODENAME}"
							BADGE="$URL/badge/icon"
							write_page "<td><a href='$URL'><img src='$BADGE' /></a></td>"
							;;
				esac
			done
			# diffoscope schroot setup
			for SUITE in ${SUITES} ; do
				if [ "$SUITE" = "experimental" ]; then
					continue
144
				fi
145 146 147
				URL="https://jenkins.debian.net/view/reproducible/view/Debian_setup_${ARCH}/job/reproducible_setup_schroot_${SUITE}_diffoscope_${ARCH}_${JENKINS_NODENAME}"
				BADGE="$URL/badge/icon"
				case $JENKINS_NODENAME in
148
					osuosl171)
149 150 151 152 153 154
						if [ "$SUITE" = "unstable" ]; then
							write_page "<td><a href='$URL'><img src='$BADGE' /></a></td>"
						else
							write_page "<td></td>"
						fi
						;;
155 156 157 158 159 160 161
					osuosl173)
						if [ "$SUITE" = "buster" ]; then
							write_page "<td><a href='$URL'><img src='$BADGE' /></a></td>"
						else
							write_page "<td></td>"
						fi
						;;
162 163 164 165 166
					jenkins)
						write_page "<td><a href='$URL'><img src='$BADGE' /></a></td>"
						;;
					*) write_page "<td></td>" ;;
				esac
167 168
			done
			write_page "</tr>"
169
		done
170
		write_page "</table>"
171
	done
172 173 174
	write_page "</p>"
	write_page_footer
	publish_page debian
175
}
176

177 178
build_graph_overview_pages() {
	#
179
	# munin nodes daily/weekly/monthly/yearly pages
180
	#
181
	for TYPE in daily weekly monthly yearly ; do
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
		VIEW=nodes_${TYPE}_graphs
		PAGE=index_${VIEW}.html
		ARCH=amd64
		SUITE=unstable
		echo "$(date -u) - starting to write $PAGE page."
		write_page_header $VIEW "Nodes $TYPE graphs"
		write_page "<p style=\"clear:both;\">"
		for ARCH in ${ARCHS} ; do
			write_page "<h3>$ARCH nodes</h3>"
			write_page "<table>"
			write_page "<tr><th>Name</th><th colspan='6'></th>"
			write_page "</tr>"
			for NODE in $REPRODUCIBLE_NODES ; do
				if [ -z "$(echo $NODE | grep $ARCH || true)" ] && [ "$NODE" != "jenkins" ] ; then
					continue
				elif [ "$NODE" = "jenkins" ] && [ "$ARCH" != "amd64" ] ; then
					continue
				fi
				if [ "$NODE" = "jenkins" ] ; then
					JENKINS_NODENAME=jenkins
					NODE="jenkins.debian.net"
				else
					case $ARCH in
						amd64|i386) 	JENKINS_NODENAME=$(echo $NODE | cut -d "-" -f1-2|sed 's#-build##' ) ;;
						arm64) 		JENKINS_NODENAME=$(echo $NODE | cut -d "-" -f1-2|sed 's#-sled##' ) ;;
						armhf) 		JENKINS_NODENAME=$(echo $NODE | cut -d "-" -f1) ;;
					esac
				fi
210 211 212
				write_page "<tr><td>$JENKINS_NODENAME"
				explain_nodes
				write_page "</td>"
213 214 215 216
				for GRAPH in jenkins_reproducible_builds cpu memory df swap load ; do
					if [ "$GRAPH" = "jenkins_reproducible_builds" ] ; then
						case $JENKINS_NODENAME in
							jenkins)	write_page "<td></td>" ; continue ;;
217
							profitbricks7)	write_page "<td></td>" ; continue ;;
218
							profitbricks9)	write_page "<td></td>" ; continue ;;
219
							profitbricks10)	write_page "<td></td>" ; continue ;;
220 221
							osuosl*)	write_page "<td></td>" ; continue ;;
							*)		;;
222 223 224
						esac
					fi
					write_page "<td><a href='https://jenkins.debian.net/munin/debian.net/$NODE/$GRAPH.html'>"
225
					case "$TYPE" in
Holger Levsen's avatar
Holger Levsen committed
226 227 228
						daily)		IMG=day.png ;;
						weekly)		IMG=week.png ;;
						monthly)	IMG=month.png ;;
229
						yearly)		IMG=year.png ;;
230
					esac
231 232 233 234 235 236 237 238 239
					write_page "<img src='https://jenkins.debian.net/munin/debian.net/$NODE/${GRAPH}-${IMG}' width='150' /></a></td>"
				done
				write_page "</tr>"
			done
			write_page "</table>"
		done
		write_page "</p>"
		write_page_footer
		publish_page debian
240
	done
241 242 243 244 245 246 247 248 249 250
}

build_job_health_page() {
	#
	# job health page
	#
	VIEW=job_health
	PAGE=index_${VIEW}.html
	ARCH=amd64
	SUITE=unstable
251
	# these are or-filters used with egrep
252 253
	FILTER[0]="(builds|spec|lfs)"
	FILTER[1]="html_(all|break|dash|dd|index|live|node|pkg|repo)"
254
	FILTER[2]="(reproducible_compare|pool)"
255 256 257 258 259 260 261 262 263
	FILTER[3]="reproducible_diffoscope"
	FILTER[4]="(reprotest|strip-nonderminism|disorderfs)"
	FILTER[5]="(json|le_scheduler|meta|le_nodes|rsync|notes)"
	FILTER[6]="archlinux"
	FILTER[7]="coreboot"
	FILTER[8]="(openwrt)"
	FILTER[9]="(le_netbsd|le_freebsd)"
	FILTER[10]="fdroid"
	FILTER[11]="fedora"
264 265 266 267
	echo "$(date -u) - starting to write $PAGE page."
	write_page_header $VIEW "Job health overview"
	write_page "<p style=\"clear:both;\">"
	write_page "<table>"
268
	for CATEGORY in $(seq 0 10) ; do
269
		write_page "<tr>"
270 271 272 273
		for JOB in $(cd ~/jobs ; ls -1d reproducible_* | egrep "${FILTER[$CATEGORY]}" | cut -d '_' -f2- | sort ) ; do
			SHORTNAME="$(echo $JOB \
				| sed 's#archlinux_##' \
				| sed 's#builder_fedora#builder#' \
274
				| sed 's#_x86_64##' \
275 276
				| sed 's#_from_git_master#_git#' \
				| sed 's#setup_schroot_##' \
277
				| sed 's#setup_mock_fedora-##' \
278
				| sed 's#create_##' \
279 280
				| sed 's#fdroid_build_##' \
				| sed 's#html_archlinux#html#' \
281 282 283
				| sed 's#html_##' \
				| sed 's#builds_##' \
				| sed 's#_diffoscope_amd64##' \
284
				| sed 's#compare_Debian_##' \
285 286 287
				| sed 's#_#-#g' \
				)"
			write_page "<th>$SHORTNAME</th>"
288 289
		done
		write_page "</tr><tr>"
290
		for JOB in $(cd ~/jobs ; ls -1d reproducible_* | egrep "${FILTER[$CATEGORY]}" | cut -d '_' -f2- | sort ) ; do
291 292 293 294 295
			URL="https://jenkins.debian.net/job/reproducible_$JOB"
			BADGE="$URL/badge/icon"
			write_page "<td><a href='$URL'><img src='$BADGE' /></a></td>"
		done
		write_page "</tr>"
296
	done
297 298 299 300 301
	write_page "</table>"
	write_page "</p>"
	write_page_footer
	publish_page debian
}
302

303 304 305
#
# main
#
306 307
PAGE=""
JENKINS_NODENAME=""
308 309 310
build_job_health_page
build_nodes_health_page
build_graph_overview_pages