ci: fix hang of FreeBSD CI jobs
cover ci: fix hang of FreeBSD CI jobs
This addresses
https://gitlab.com/qemu-project/qemu/-/issues/1882
Which turned out to be a genuine flaw which we missed during merge as the patch hitting master co-incided with the FreeBSD CI job having an temporary outage due to changed release image version.
Daniel P. Berrangé (4):
microbit: add missing qtest_quit() call
qtest: kill orphaned qtest QEMU processes on FreeBSD
gitlab: make Cirrus CI timeout explicit
gitlab: make Cirrus CI jobs gating
.gitlab-ci.d/cirrus.yml | 4 +++- .gitlab-ci.d/cirrus/build.yml | 2 ++ tests/qtest/libqtest.c | 7 +++++++ tests/qtest/microbit-test.c | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-)
Signature · 1 line
2.41.0
PATCH 1/4 microbit: add missing qtest_quit() call
Without this call, the QEMU process is being left running which on FreeBSD 13.2 at least, makes meson think the test is still running, and thus execution of "make check" continues forever.
This fixes the regression introduced in:
commit a9c9bbee855877293683012942d3485d50f286af
Author: Chris Laplante <[email protected]>
Date: Tue Aug 22 17:31:02 2023 +0100
qtest: microbit-test: add tests for nRF51 DETECT
--- tests/qtest/microbit-test.c | 2 ++ 1 file changed, 2 insertions(+)
tests/qtest/microbit-test.c +2 -0
@@ -434,6 +434,8 @@ static void test_nrf51_gpio_detect(void)g_assert_true (qtest_get_irq (qts,0 ));qtest_set_irq_in (qts,"/machine/nrf51" ,"unnamed-gpio-in" ,3 ,0 );g_assert_true (qtest_get_irq (qts,0 )); + +qtest_quit (qts); }static void timer_task (QTestState *qts,hwaddr task)
Signature · 1 line
2.41.0
Re: [PATCH 1/4] microbit: add missing qtest_quit() call
Quoted 10 lines · Daniel P. Berrangé
Without this call, the QEMU process is being left running which on FreeBSD 13.2 at least, makes meson think the test is still running, and thus execution of "make check" continues forever.
This fixes the regression introduced in:
commit
a9c9bbee855877293683012942d3485d50f286af
Author: Chris Laplante<[email protected]>
Date: Tue Aug 22 17:31:02 2023 +0100
Quoted 7 lines
qtest: microbit-test: add tests for nRF51 DETECT
Signed-off-by Daniel P. Berrangé<[email protected]>--- tests/qtest/microbit-test.c | 2 ++ 1 file changed, 2 insertions(+)
But I think that it's unfortunate that we have to remember this for each test.
r~
Re: [PATCH 1/4] microbit: add missing qtest_quit() call
Quoted 19 lines · Richard Henderson
Quoted 10 lines · Daniel P. Berrangé
Without this call, the QEMU process is being left running which on FreeBSD 13.2 at least, makes meson think the test is still running, and thus execution of "make check" continues forever.
This fixes the regression introduced in:
commit
a9c9bbee855877293683012942d3485d50f286af
Author: Chris Laplante<[email protected]>
Date: Tue Aug 22 17:31:02 2023 +0100Quoted 7 lines
qtest: microbit-test: add tests for nRF51 DETECT
Signed-off-by Daniel P. Berrangé<[email protected]>--- tests/qtest/microbit-test.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 3 lines
Reviewed-by Richard Henderson <[email protected]>But I think that it's unfortunate that we have to remember this for each test.
We should use G_DEFINE_AUTOPTR_CLEANUP_FUNC for QTestState, and then we can change tests to declare
g_autoptr(QTestState) qts = qtest_init(....)
which will make it a bit more robust against forgotten cleanup.
We register an ABRT handler to kill off QEMU manually during g_asserts().
The "death signal" code will give another layer of robustness for exits too on Linux and now FreeBSD.
If we really wanted to we could add a 3rd layer of defence by adding an atexit() handler, but I'm not sure this last one is worth it for something we're not hitting frequently AFAIR.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH 2/4 qtest: kill orphaned qtest QEMU processes on FreeBSD
In reply to Daniel P. BerrangéOn Linux we use PR_SET_PDEATHSIG to kill orphaned QEMU processes if we fail to call qtest_quit(), or the test program aborts/segvs. This prevents meson from hanging forever due to the orphaned process keeping stdout open.
On FreeBSD we can achieve the same using PROC_PDEATHSIG_CTL, which gives us the equivalent protection against hangs.
--- tests/qtest/libqtest.c | 7 +++++++ 1 file changed, 7 insertions(+)
tests/qtest/libqtest.c +7 -0
@@ -24,6 +24,9 @@#ifdef __linux__#include <sys/prctl.h> #endif /* __linux__ */ +#ifdef __FreeBSD__ +#include <sys/procctl.h> +#endif /* __FreeBSD__ */ #include "libqtest.h" #include "libqmp.h"
@@ -414,6 +417,10 @@ static QTestState *G_GNUC_PRINTF(1, 2) qtest_spawn_qemu(const char *fmt, ...)*/ prctl (PR_SET_PDEATHSIG ,SIGKILL ,0 ,0 ,0 );#endif /* __linux__ */ +#ifdef __FreeBSD__ +int sig =SIGKILL ; +procctl (P_PID ,getpid (),PROC_PDEATHSIG_CTL , &sig); +#endif /* __FreeBSD__ */ if (!g_setenv ("QEMU_AUDIO_DRV" ,"none" , true)) {exit (1 ); }
Signature · 1 line
2.41.0
Re: [PATCH 2/4] qtest: kill orphaned qtest QEMU processes on FreeBSD
Quoted 28 lines · Daniel P. Berrangé
On Linux we use
PR_SET_PDEATHSIGto kill orphaned QEMU processes if we fail to callqtest_quit(), or the test program aborts/segvs. This prevents meson from hanging forever due to the orphaned process keeping stdout open.On FreeBSD we can achieve the same using
PROC_PDEATHSIG_CTL, which gives us the equivalent protection against hangs.Signed-off-by Daniel P. Berrangé <[email protected]>--- tests/qtest/libqtest.c | 7 +++++++ 1 file changed, 7 insertions(+)tests/qtest/libqtest.c +3
-0@@ -24,6 +24,9 @@#ifdef __linux__#include <sys/prctl.h> #endif /* __linux__ */ +#ifdef __FreeBSD__ +#include <sys/procctl.h> +#endif /* __FreeBSD__ */ #include "libqtest.h" #include "libqmp.h"
tests/qtest/libqtest.c static QTestState *G_GNUC_PRINTF(1, 2) qtest_spawn_qemu(const char *fmt, ...) · line 422
Quoted 6 lines
tests/qtest/libqtest.c +3
-0@@ -414,6 +417,10 @@ static QTestState *G_GNUC_PRINTF(1, 2) qtest_spawn_qemu(const char *fmt, ...)*/ prctl (PR_SET_PDEATHSIG ,SIGKILL ,0 ,0 ,0 );#endif /* __linux__ */ +#ifdef __FreeBSD__ +int sig =SIGKILL ; +procctl (P_PID ,getpid (),PROC_PDEATHSIG_CTL , &sig);
We could use 0 for "current process", but this works too.
r~
PATCH 3/4 gitlab: make Cirrus CI timeout explicit
In reply to Daniel P. BerrangéOn the GitLab side we're invoking the Cirrus CI job using the cirrus-run tool which speaks to the Cirrus REST API. Cirrus sometimes tasks 5-10 minutes to actually schedule the task, and thus the execution time of 'cirrus-run' inside GitLab will be slightly longer than the execution time of the Cirrus CI task.
Setting the timeout in the GitLab CI job should thus be done in relation to the timeout set for the Cirrus CI job. While Cirrus CI defaults to 60 minutes, it is better to set this explicitly, and make the relationship between the jobs explicit
--- .gitlab-ci.d/cirrus.yml | 3 +++ .gitlab-ci.d/cirrus/build.yml | 2 ++ 2 files changed, 5 insertions(+)
.gitlab-ci.d/cirrus.yml +3 -0
@@ -15,6 +15,9 @@ stage: build image: registry.gitlab.com/libvirt/libvirt-ci/cirrus-run:master needs: [] + # 20 mins larger than "timeout_in" in cirrus/build.yml + # as there's often a 5-10 minute delay before Cirrus CI + # actually starts the task timeout: 80m allow_failure: true script:
.gitlab-ci.d/cirrus/build.yml +2 -0
@@ -16,6 +16,8 @@ env: TEST_TARGETS: "@TEST_TARGETS@" build_task: + # A little shorter than GitLab timeout in ../cirrus.yml + timeout_in: 60m install_script: - @UPDATE_COMMAND@ - @INSTALL_COMMAND@ @PKGS@
Signature · 1 line
2.41.0
Re: [PATCH 3/4] gitlab: make Cirrus CI timeout explicit
Quoted 13 lines · Daniel P. Berrangé
On the GitLab side we're invoking the Cirrus CI job using the cirrus-run tool which speaks to the Cirrus REST API. Cirrus sometimes tasks 5-10 minutes to actually schedule the task, and thus the execution time of 'cirrus-run' inside GitLab will be slightly longer than the execution time of the Cirrus CI task.
Setting the timeout in the GitLab CI job should thus be done in relation to the timeout set for the Cirrus CI job. While Cirrus CI defaults to 60 minutes, it is better to set this explicitly, and make the relationship between the jobs explicit
Quoted 5 lines
Signed-off-by Daniel P. Berrangé <[email protected]>--- .gitlab-ci.d/cirrus.yml | 3 +++ .gitlab-ci.d/cirrus/build.yml | 2 ++ 2 files changed, 5 insertions(+)
PATCH 4/4 gitlab: make Cirrus CI jobs gating
In reply to Daniel P. BerrangéThe Cirrus CI jobs have been non-gating for a while to let us build confidence in their reliability. Aside from periodic dependancy problems when FreeBSD Ports switches to be based on a new FreeBSD image version, the jobs have been reliable. It is thus worth making them gating to prevent build failures being missed during merges.
--- .gitlab-ci.d/cirrus.yml | 1 - 1 file changed, 1 deletion(-)
.gitlab-ci.d/cirrus.yml +0 -1
@@ -19,7 +19,6 @@ # as there's often a 5-10 minute delay before Cirrus CI # actually starts the task timeout: 80m - allow_failure: true script: - source .gitlab-ci.d/cirrus/$NAME.vars - sed -e "s|[@]CI_REPOSITORY_URL@|$CI_REPOSITORY_URL|g"
Signature · 1 line
2.41.0
Quoted 15 lines · Daniel P. Berrangé
This addresses
https://gitlab.com/qemu-project/qemu/-/issues/1882
Which turned out to be a genuine flaw which we missed during merge as the patch hitting master co-incided with the FreeBSD CI job having an temporary outage due to changed release image version.
Daniel P. Berrangé (4):
microbit: add missingqtest_quit()call
qtest: kill orphaned qtest QEMU processes on FreeBSD
gitlab: make Cirrus CI timeout explicit
gitlab: make Cirrus CI jobs gating
Quoted 5 lines
.gitlab-ci.d/cirrus.yml | 4 +++- .gitlab-ci.d/cirrus/build.yml | 2 ++ tests/qtest/libqtest.c | 7 +++++++ tests/qtest/microbit-test.c | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-)
Thank you!
Quoted 14 lines · Daniel P. Berrangé
This addresses
https://gitlab.com/qemu-project/qemu/-/issues/1882Which turned out to be a genuine flaw which we missed during merge as the patch hitting master co-incided with the FreeBSD CI job having an temporary outage due to changed release image version.
Daniel P. Berrangé (4):
microbit: add missingqtest_quit()call
qtest: kill orphaned qtest QEMU processes on FreeBSD
gitlab: make Cirrus CI timeout explicit
gitlab: make Cirrus CI jobs gating
Quoted 6 lines
.gitlab-ci.d/cirrus.yml | 4 +++- .gitlab-ci.d/cirrus/build.yml | 2 ++ tests/qtest/libqtest.c | 7 +++++++ tests/qtest/microbit-test.c | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-)
Series
Alex, will you pick these up or shall I take them for my next PR? Or Stefan, do you want to apply these directly as a CI fix?
Thomas
Quoted 18 lines · Thomas Huth
Quoted 10 lines · Daniel P. Berrangé
This addresses
https://gitlab.com/qemu-project/qemu/-/issues/1882
Which turned out to be a genuine flaw which we missed during merge as the patch hitting master co-incided with the FreeBSD CI job having an temporary outage due to changed release image version. Daniel P. Berrangé (4):
microbit: add missingqtest_quit()call
qtest: kill orphaned qtest QEMU processes on FreeBSD
gitlab: make Cirrus CI timeout explicit
gitlab: make Cirrus CI jobs gatingQuoted 6 lines
.gitlab-ci.d/cirrus.yml | 4 +++- .gitlab-ci.d/cirrus/build.yml | 2 ++ tests/qtest/libqtest.c | 7 +++++++ tests/qtest/microbit-test.c | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-)
Quoted 4 lines
Series
Reviewed-by Thomas Huth <[email protected]>Alex, will you pick these up or shall I take them for my next PR?
Queued to testing/next, thanks.
Do you have a patch to disable the borked avacado tests? Or maybe I should just include Philippe's fix?
Quoted 3 lines
Or Stefan, do you want to apply these directly as a CI fix?
Thomas
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 24 lines · Alex Bennée
Quoted 21 lines · Thomas Huth
Quoted 10 lines · Daniel P. Berrangé
This addresses
https://gitlab.com/qemu-project/qemu/-/issues/1882
Which turned out to be a genuine flaw which we missed during merge as the patch hitting master co-incided with the FreeBSD CI job having an temporary outage due to changed release image version. Daniel P. Berrangé (4):
microbit: add missingqtest_quit()call
qtest: kill orphaned qtest QEMU processes on FreeBSD
gitlab: make Cirrus CI timeout explicit
gitlab: make Cirrus CI jobs gatingQuoted 6 lines
.gitlab-ci.d/cirrus.yml | 4 +++- .gitlab-ci.d/cirrus/build.yml | 2 ++ tests/qtest/libqtest.c | 7 +++++++ tests/qtest/microbit-test.c | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-)Series
Reviewed-by Thomas Huth <[email protected]>
Quoted 6 lines
Quoted 1 line
Alex, will you pick these up or shall I take them for my next PR?
Queued to testing/next, thanks.
Do you have a patch to disable the borked avacado tests? Or maybe I should just include Philippe's fix?
Not at this time. My hope was that this patch might address at least some of the broken tests:
https://lists.gnu.org/archive/html/qemu-devel/2023-09/msg02797.html
but I ran out of time to test that yesterday.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 24 lines · Alex Bennée
Quoted 21 lines · Thomas Huth
Quoted 10 lines · Daniel P. Berrangé
This addresses
https://gitlab.com/qemu-project/qemu/-/issues/1882Which turned out to be a genuine flaw which we missed during merge as the patch hitting master co-incided with the FreeBSD CI job having an temporary outage due to changed release image version. Daniel P. Berrangé (4):
microbit: add missingqtest_quit()call
qtest: kill orphaned qtest QEMU processes on FreeBSD
gitlab: make Cirrus CI timeout explicit
gitlab: make Cirrus CI jobs gatingQuoted 6 lines
.gitlab-ci.d/cirrus.yml | 4 +++- .gitlab-ci.d/cirrus/build.yml | 2 ++ tests/qtest/libqtest.c | 7 +++++++ tests/qtest/microbit-test.c | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-)Series
Reviewed-by Thomas Huth <[email protected]>
Quoted 6 lines
Quoted 1 line
Alex, will you pick these up or shall I take them for my next PR?
Queued to testing/next, thanks.
Do you have a patch to disable the borked avacado tests? Or maybe I should just include Philippe's fix?
I thought that Philippe mentioned that he wanted to provide a patch that disables the broken tests?
Thomas
Quoted 25 lines · Thomas Huth
Quoted 24 lines · Alex Bennée
Quoted 21 lines · Thomas Huth
Quoted 14 lines · Daniel P. Berrangé
This addresses
https://gitlab.com/qemu-project/qemu/-/issues/1882
Which turned out to be a genuine flaw which we missed during merge as the patch hitting master co-incided with the FreeBSD CI job having an temporary outage due to changed release image version. Daniel P. Berrangé (4):
microbit: add missingqtest_quit()call
qtest: kill orphaned qtest QEMU processes on FreeBSD
gitlab: make Cirrus CI timeout explicit
gitlab: make Cirrus CI jobs gating .gitlab-ci.d/cirrus.yml | 4 +++-.gitlab-ci.d/cirrus/build.yml| 2 ++ tests/qtest/libqtest.c | 7 +++++++ tests/qtest/microbit-test.c | 2 ++Quoted 2 lines
4 files changed, 14 insertions(+), 1 deletion(-)Series
Reviewed-by Thomas Huth <[email protected]>
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Alex, will you pick these up or shall I take them for my next PR?
Queued to testing/next, thanks.
Do you have a patch to disable the borked avacado tests? Or maybe I should just include Philippe's fix?
As we discussed with Richard yesterday, the fix is not correct.
Quoted 1 line
I thought that Philippe mentioned that he wanted to provide a patch that disables the broken tests?
Yes, I'm still discussing a bit more on the other thread:
https://lore.kernel.org/all/[email protected]/