mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-08 00:17:31 +00:00
obs-packaging: fix wait for obs
Reimplement the loop that waits for OBS. Look for the packages that are still building, not for the repos. Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
f5b71d3455
commit
ae98ea450d
@ -35,41 +35,179 @@ run_in_docker() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# project information
|
||||||
|
project=""
|
||||||
|
|
||||||
|
# repo information
|
||||||
|
repo=""
|
||||||
|
repo_state=""
|
||||||
|
repo_code=""
|
||||||
|
|
||||||
|
# package information
|
||||||
|
package=""
|
||||||
|
package_code=""
|
||||||
|
package_details=""
|
||||||
|
|
||||||
|
# packages still building
|
||||||
|
packages_building=0
|
||||||
|
|
||||||
|
fail=0
|
||||||
|
return=0
|
||||||
|
continue=0
|
||||||
|
|
||||||
|
result_handler() {
|
||||||
|
# reset project information
|
||||||
|
project=""
|
||||||
|
|
||||||
|
# reset repo information
|
||||||
|
repo=""
|
||||||
|
repo_state=""
|
||||||
|
repo_code=""
|
||||||
|
|
||||||
|
local IFS=' '
|
||||||
|
for i in $1; do
|
||||||
|
case $(echo $i | cut -d= -f1) in
|
||||||
|
project)
|
||||||
|
project=$(echo $i | cut -d= -f2 | tr -d '"')
|
||||||
|
;;
|
||||||
|
|
||||||
|
repository)
|
||||||
|
repo=$(echo $i | cut -d= -f2 | tr -d '"')
|
||||||
|
;;
|
||||||
|
|
||||||
|
code)
|
||||||
|
repo_code=$(echo $i | cut -d= -f2 | tr -d '"')
|
||||||
|
;;
|
||||||
|
|
||||||
|
state)
|
||||||
|
repo_state=$(echo $i | cut -d= -f2 | tr -d '"')
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
case "${repo_code}" in
|
||||||
|
blocked)
|
||||||
|
continue=1
|
||||||
|
;;
|
||||||
|
|
||||||
|
unresolvable)
|
||||||
|
fail=1
|
||||||
|
;;
|
||||||
|
|
||||||
|
excluded)
|
||||||
|
return=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
status_handler() {
|
||||||
|
# reset package information
|
||||||
|
package=""
|
||||||
|
package_code=""
|
||||||
|
package_details=""
|
||||||
|
|
||||||
|
local IFS=' '
|
||||||
|
for i in $1; do
|
||||||
|
case $(echo $i | cut -d= -f1) in
|
||||||
|
package)
|
||||||
|
package=$(echo $i | cut -d= -f2 | tr -d '"')
|
||||||
|
;;
|
||||||
|
|
||||||
|
code)
|
||||||
|
package_code=$(echo $i | cut -d= -f2 | tr -d '"')
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
case "${package_code}" in
|
||||||
|
blocked)
|
||||||
|
continue=1
|
||||||
|
;;
|
||||||
|
|
||||||
|
unresolvable)
|
||||||
|
fail=1
|
||||||
|
;;
|
||||||
|
|
||||||
|
excluded)
|
||||||
|
return=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
details_handler() {
|
||||||
|
# reset package details
|
||||||
|
package_details="$(echo $1 | cut -d\> -f2 | cut -d\< -f1)"
|
||||||
|
|
||||||
|
if [ "$package_details" == "failed" ]; then
|
||||||
|
fail=1
|
||||||
|
osc pr
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$package_details" == "broken" ]; then
|
||||||
|
fail=1
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${package_details}" != "succeeded" ] || [ "${package_code}" != "finished" ]; then
|
||||||
|
packages_building=$((packages_building+1))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_repo() {
|
||||||
|
if [ -z "${repo}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
dump_info() {
|
||||||
|
echo "package: $package, code: $package_code, details: $package_details"
|
||||||
|
echo "repository: $repo, state: $repo_state, code: $repo_code"
|
||||||
|
echo "For more information go to https://build.opensuse.org/package/live_build_log/${project}/${package}/${repo}/$(uname -m)"
|
||||||
|
}
|
||||||
|
|
||||||
# Check all project has finshed the build
|
# Check all project has finshed the build
|
||||||
wait_finish_building() {
|
wait_finish_building() {
|
||||||
local out
|
local out
|
||||||
while true; do
|
while true; do
|
||||||
sleep 10
|
sleep 30
|
||||||
out=$(osc api "/build/${project}/_result")
|
out=$(osc api "/build/${project}/_result")
|
||||||
if echo "${out}" | grep '<details>failed</details>'; then
|
continue=0
|
||||||
echo "Project ${project} has failed packages"
|
packages_building=0
|
||||||
osc pr
|
|
||||||
exit 1
|
local IFS=$'\n'
|
||||||
fi
|
for i in ${out[*]}; do
|
||||||
if echo "${out}" | grep '<details>broken</details>'; then
|
i="$(echo $i | sed -e 's/^[[:space:]]*//' -e 's/^<//' -e 's/>$//')"
|
||||||
echo "Project ${project} has broken packages"
|
if echo "$i" | egrep -q "^result"; then
|
||||||
exit 1
|
result_handler "$i"
|
||||||
fi
|
elif echo "$i" | egrep -q "^status"; then
|
||||||
if echo "${out}" | grep 'code="blocked"'; then
|
status_handler "$i"
|
||||||
echo "Project ${project} has blocked packages, waiting"
|
elif echo "$i" | egrep -q "^details"; then
|
||||||
continue
|
details_handler "$i"
|
||||||
fi
|
|
||||||
if echo "${out}" | grep 'code="unresolvable"'; then
|
|
||||||
echo "Project ${project} has unresolvable packages"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if echo "${out}" | grep 'state="building"'; then
|
|
||||||
echo "Project ${project} is still building, waiting"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if echo "${out}" | grep 'code="excluded"'; then
|
|
||||||
echo "Project ${project} has excluded packages left, quit waiting"
|
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "No jobs with building status were found"
|
if [ $fail -eq 1 ]; then
|
||||||
echo "${out}"
|
echo -n "FAILED: "
|
||||||
|
dump_info
|
||||||
|
exit 1
|
||||||
|
elif [ $return -eq 1 ]; then
|
||||||
|
return
|
||||||
|
elif [ $packages_building -gt 0 ]; then
|
||||||
break
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $continue -eq 1 ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $packages_building -gt 0 ]; then
|
||||||
|
echo -n "BULDING: "
|
||||||
|
dump_info
|
||||||
|
else
|
||||||
|
echo "FINISHED: SUCCEEDED!"
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user