mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-05 10:50:18 +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:
@@ -27,7 +27,7 @@ user = ${OBS_USER}
|
|||||||
pass = ${OBS_PASS}
|
pass = ${OBS_PASS}
|
||||||
eom
|
eom
|
||||||
fi
|
fi
|
||||||
) >> /dev/null
|
) >>/dev/null
|
||||||
if [ ! -e "${OSCRC}" ]; then
|
if [ ! -e "${OSCRC}" ]; then
|
||||||
echo "${OSCRC}, please do 'export OBS_USER=your_user ; export OBS_PASS=your_pass' to configure osc for first time."
|
echo "${OSCRC}, please do 'export OBS_USER=your_user ; export OBS_PASS=your_pass' to configure osc for first time."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -56,6 +56,7 @@ docker_run() {
|
|||||||
--env GO_ARCH="${GO_ARCH}" \
|
--env GO_ARCH="${GO_ARCH}" \
|
||||||
--env PUSH="${PUSH:-}" \
|
--env PUSH="${PUSH:-}" \
|
||||||
--env DEBUG="${DEBUG:-}" \
|
--env DEBUG="${DEBUG:-}" \
|
||||||
|
--env OBS_PROJECT="${OBS_PROJECT:-}" \
|
||||||
--env OBS_SUBPROJECT="${OBS_SUBPROJECT:-}" \
|
--env OBS_SUBPROJECT="${OBS_SUBPROJECT:-}" \
|
||||||
-v "${cache_dir}":/var/tmp/osbuild-packagecache/ \
|
-v "${cache_dir}":/var/tmp/osbuild-packagecache/ \
|
||||||
-v "${_obs_docker_packaging_repo_dir}":"${_obs_docker_packaging_repo_dir}" \
|
-v "${_obs_docker_packaging_repo_dir}":"${_obs_docker_packaging_repo_dir}" \
|
||||||
|
@@ -11,6 +11,10 @@ set -o errtrace
|
|||||||
|
|
||||||
script_name="$(basename "${BASH_SOURCE[0]}")"
|
script_name="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
|
OBS_PROJECT=${OBS_PROJECT:-"home:katacontainers:"}
|
||||||
|
# Project to wait for
|
||||||
|
project=""
|
||||||
|
|
||||||
handle_error() {
|
handle_error() {
|
||||||
local exit_code="${?}"
|
local exit_code="${?}"
|
||||||
local line_number="${1:-}"
|
local line_number="${1:-}"
|
||||||
@@ -31,12 +35,33 @@ run_in_docker() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Check all project has finshed the build
|
# Check all project has finshed the build
|
||||||
wait_finish_building() {
|
wait_finish_building() {
|
||||||
while osc pr -q | grep '(building)'; do sleep 5; done
|
local out
|
||||||
# just in case something goes wrong
|
while true; do
|
||||||
while osc pr -q | grep '(building)'; do sleep 5; done
|
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'
|
# obs distro final status is 'published'
|
||||||
@@ -63,10 +88,9 @@ wait_published() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
check_failed(){
|
check_failed() {
|
||||||
failed_query=$(osc pr -c -s F)
|
failed_query=$(osc pr -c -s F)
|
||||||
regex=".*failed.*"
|
if [[ ${failed_query} =~ failed ]]; then
|
||||||
if [[ ${failed_query} =~ ${regex} ]];then
|
|
||||||
echo "ERROR: Build failed"
|
echo "ERROR: Build failed"
|
||||||
osc pr -V -s 'F'
|
osc pr -V -s 'F'
|
||||||
exit 1
|
exit 1
|
||||||
@@ -92,22 +116,25 @@ EOT
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
run_in_docker $@
|
run_in_docker $@
|
||||||
local no_wait_publish="false"
|
local no_wait_publish="false"
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
"-h"|"--help")
|
"-h" | "--help")
|
||||||
usage "Help" 0
|
usage "Help" 0
|
||||||
;;
|
;;
|
||||||
--no-wait-publish)
|
--no-wait-publish)
|
||||||
no_wait_publish="true"
|
no_wait_publish="true"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
usage "Invalid option: ${1:-}" 1
|
usage "Invalid option: ${1:-}" 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
OBS_SUBPROJECT="${OBS_SUBPROJECT:-releases:x86_64:alpha}"
|
project=${1:-}
|
||||||
project="home:katacontainers:${OBS_SUBPROJECT}"
|
if [ "${project}" == "" ]; then
|
||||||
|
OBS_SUBPROJECT="${OBS_SUBPROJECT:-}"
|
||||||
|
project="${OBS_PROJECT}${OBS_SUBPROJECT}"
|
||||||
|
fi
|
||||||
echo "Checkout: ${project}"
|
echo "Checkout: ${project}"
|
||||||
osc co "$project" || true
|
osc co "$project" || true
|
||||||
cd "$project" || exit 1
|
cd "$project" || exit 1
|
||||||
@@ -120,7 +147,7 @@ main() {
|
|||||||
check_failed
|
check_failed
|
||||||
echo "OK - build did not fail"
|
echo "OK - build did not fail"
|
||||||
|
|
||||||
if [ "${no_wait_publish}" == "true" ];then
|
if [ "${no_wait_publish}" == "true" ]; then
|
||||||
echo " Requested not wait for publish"
|
echo " Requested not wait for publish"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user