mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-03 09:54:33 +00:00
obs: wait: Fix error to detect building job
The job to wait for packages are built is failing randomly. Seems that sometimes the command is not returning and expected out out and may be mask by the `while osc pr | grep; done` This probably can fail at osc pr but because it failed at osc and not grep we consider is working. - We check for more states that we consider not ready, like excluded or blocked. First query the result, if fail the script will stop, if not then try to find the string `state=building`. Additionally, check for failed jobs in the same query to stop the job earlier. Fixes: #665 Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
@@ -56,6 +56,7 @@ docker_run() {
|
||||
--env GO_ARCH="${GO_ARCH}" \
|
||||
--env PUSH="${PUSH:-}" \
|
||||
--env DEBUG="${DEBUG:-}" \
|
||||
--env OBS_PROJECT="${OBS_PROJECT:-}" \
|
||||
--env OBS_SUBPROJECT="${OBS_SUBPROJECT:-}" \
|
||||
-v "${cache_dir}":/var/tmp/osbuild-packagecache/ \
|
||||
-v "${_obs_docker_packaging_repo_dir}":"${_obs_docker_packaging_repo_dir}" \
|
||||
|
@@ -11,6 +11,10 @@ set -o errtrace
|
||||
|
||||
script_name="$(basename "${BASH_SOURCE[0]}")"
|
||||
|
||||
OBS_PROJECT=${OBS_PROJECT:-"home:katacontainers:"}
|
||||
# Project to wait for
|
||||
project=""
|
||||
|
||||
handle_error() {
|
||||
local exit_code="${?}"
|
||||
local line_number="${1:-}"
|
||||
@@ -31,12 +35,33 @@ run_in_docker() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Check all project has finshed the build
|
||||
wait_finish_building() {
|
||||
while osc pr -q | grep '(building)'; do sleep 5; done
|
||||
# just in case something goes wrong
|
||||
while osc pr -q | grep '(building)'; do sleep 5; done
|
||||
local out
|
||||
while true; do
|
||||
sleep 10
|
||||
out=$(osc api "/build/${project}/_result")
|
||||
if echo "${out}" | grep '<details>failed</details>'; then
|
||||
echo "Project ${project} has failed packages"
|
||||
osc pr
|
||||
exit 1
|
||||
fi
|
||||
if echo "${out}" | grep 'code="blocked"'; then
|
||||
echo "Project ${project} has blocked packages, waiting"
|
||||
continue
|
||||
fi
|
||||
if echo "${out}" | grep 'code="excluded"'; then
|
||||
echo "Project ${project} has excluded packages, waiting"
|
||||
continue
|
||||
fi
|
||||
if echo "${out}" | grep 'state="building"'; then
|
||||
echo "Project ${project} is still building, waiting"
|
||||
continue
|
||||
fi
|
||||
echo "No jobs with building status were found"
|
||||
echo "${out}"
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
# obs distro final status is 'published'
|
||||
@@ -65,8 +90,7 @@ wait_published() {
|
||||
|
||||
check_failed() {
|
||||
failed_query=$(osc pr -c -s F)
|
||||
regex=".*failed.*"
|
||||
if [[ ${failed_query} =~ ${regex} ]];then
|
||||
if [[ ${failed_query} =~ failed ]]; then
|
||||
echo "ERROR: Build failed"
|
||||
osc pr -V -s 'F'
|
||||
exit 1
|
||||
@@ -106,8 +130,11 @@ main() {
|
||||
usage "Invalid option: ${1:-}" 1
|
||||
;;
|
||||
esac
|
||||
OBS_SUBPROJECT="${OBS_SUBPROJECT:-releases:x86_64:alpha}"
|
||||
project="home:katacontainers:${OBS_SUBPROJECT}"
|
||||
project=${1:-}
|
||||
if [ "${project}" == "" ]; then
|
||||
OBS_SUBPROJECT="${OBS_SUBPROJECT:-}"
|
||||
project="${OBS_PROJECT}${OBS_SUBPROJECT}"
|
||||
fi
|
||||
echo "Checkout: ${project}"
|
||||
osc co "$project" || true
|
||||
cd "$project" || exit 1
|
||||
|
Reference in New Issue
Block a user