# Multiarch builds (lxd) always time out on failure instead of exit

**URL:** <https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659>\
**Category:** Multi CPU Architecture\
**Tags:** build-env, bug\
**Created:** [March 20, 2020, 2:49pm UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659 "2020-03-20T14:49:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/marco/32/3441_2.png) [@Marco](https://travis-ci.community/u/Marco)\
**Post date:** [March 20, 2020, 2:49pm UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/1 "2020-03-20T14:49:33Z")

</div>

Our multiarch build time out, whereas they should fail immediately on any error in the unit tests.

The issue is correlated with the virtualization solution: x86 uses gce vms and the others use lxd.

As travis has planned to switch x86 to lxd as well, it would be nice to fix this regression before that happens.

Here is a test matrix, where builds should either fail or pass within one minute. However, it can be seen that failing lxd builds last 10 minutes (the default timeout).

> **[Travis CI - Test and Deploy Your Code with Confidence](https://travis-ci.org/github/MarcoFalke/debug_travis/builds/664872146)**

---

<div class="post-metadata">

**Author:** ![Marco](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/marco/32/3441_2.png) [@Marco](https://travis-ci.community/u/Marco)\
**Post date:** [April 12, 2020, 1:09am UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/2 "2020-04-12T01:09:31Z")

</div>

This is still an issue: [https://travis-ci.org/github/MarcoFalke/debug\_travis/builds/673940545](https://travis-ci.org/github/MarcoFalke/debug_travis/builds/673940545)

---

<div class="post-metadata">

**Author:** ![fingolfin](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/fingolfin/32/2110_2.png) [@fingolfin](https://travis-ci.community/u/fingolfin)\
**Post date:** [April 13, 2020, 12:28pm UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/3 "2020-04-13T12:28:34Z")

</div>

I’ve been stuck on this problem for months: basically right after the arm/s390x/ppc64le support was announced, I made [https://github.com/gap-system/gap/pull/3744](https://github.com/gap-system/gap/pull/3744) and for all three architectures, the tests end in a timeout. I’ve changed our executable to `abort` and inserted a bunch of `echo FOOBAR NNN` statements in the script orchestrating the CI run to narrow it down, and it’s always the same: our exec exits with a non-zero code (or crashes via `abort`), and then… nothing; the shell script that launched it does not continue to execute, the VM just hangs until the timeout kills it.

Sadly that means we can’t use these; I was looking in particular forward to having s390x available so that we finally could do CI tests on a big endian machine. Ah well ☹

---

<div class="post-metadata">

**Author:** ![fingolfin](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/fingolfin/32/2110_2.png) [@fingolfin](https://travis-ci.community/u/fingolfin)\
**Post date:** [April 13, 2020, 2:16pm UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/4 "2020-04-13T14:16:47Z")

</div>

Here is a list of other threads that discuss the same or closely related issues:

- [https://travis-ci.community/t/7678](https://travis-ci.community/t/7678)
- [https://travis-ci.community/t/7630](https://travis-ci.community/t/7630)
- [https://travis-ci.community/t/7148](https://travis-ci.community/t/7148)
- [https://travis-ci.community/t/7044](https://travis-ci.community/t/7044)
- [https://travis-ci.community/t/5731](https://travis-ci.community/t/5731)

See also [https://github.com/travis-ci/travis-build/pull/1816](https://github.com/travis-ci/travis-build/pull/1816)

I’ve been able to workaround the issue by adding `|| travis_terminate $?` to each script line in out .travis.yml

---

<div class="post-metadata">

**Author:** ![Marco](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/marco/32/3441_2.png) [@Marco](https://travis-ci.community/u/Marco)\
**Post date:** [April 13, 2020, 6:29pm UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/5 "2020-04-13T18:29:28Z")

</div>

I’ve reduced the reproducible failure to a single-line `script` in the travis yaml:

[https://travis-ci.org/github/MarcoFalke/debug\_travis/builds/674533618](https://travis-ci.org/github/MarcoFalke/debug_travis/builds/674533618)

---

<div class="post-metadata">

**Author:** ![fingolfin](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/fingolfin/32/2110_2.png) [@fingolfin](https://travis-ci.community/u/fingolfin)\
**Post date:** [April 13, 2020, 7:04pm UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/6 "2020-04-13T19:04:01Z")

</div>

Yeah, any non-zero exit code stumps the whole thing.

---

<div class="post-metadata">

**Author:** ![Marco](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/marco/32/3441_2.png) [@Marco](https://travis-ci.community/u/Marco)\
**Post date:** [April 13, 2020, 7:59pm UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/7 "2020-04-13T19:59:17Z")

</div>

`set -o errexit;` is also required, I believe

---

<div class="post-metadata">

**Author:** ![fingolfin](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/fingolfin/32/2110_2.png) [@fingolfin](https://travis-ci.community/u/fingolfin)\
**Post date:** [April 13, 2020, 9:12pm UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/8 "2020-04-13T21:12:04Z")

</div>

@Marco indeed, yes (i.e., `set -e` )

---

<div class="post-metadata">

**Author:** ![Marco](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/marco/32/3441_2.png) [@Marco](https://travis-ci.community/u/Marco)\
**Post date:** [April 23, 2020, 10:55am UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/9 "2020-04-23T10:55:39Z")

</div>

On s390x, the machine will run idle up to **6 hours** after a failure, see [https://travis-ci.org/github/bitcoin/bitcoin/jobs/678415052](https://travis-ci.org/github/bitcoin/bitcoin/jobs/678415052)

Not only does it block our whole queue, this also seems wasteful of travis resources.

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [October 25, 2020, 2:09am UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/10 "2020-10-25T02:09:02Z")

</div>

Don’t set `errexit` in the main shell. This shell also runs the build’s internal logic and the sudden exit terminates it abnormally.

If a failing command should terminate the build, put it into a section other than `script:` – i.e. `install`. The `script:` section is designed to run tests – i.e. stuff that you want to run to completion even if something fails.

> [@Multiline \`script:\` is running without errexit?](https://travis-ci.community/t/multiline-script-not-failing-where-it-should/7644/2):
>
> This is by design. User commands run without errexit – because, by necessity, [they are run with eval in the same shell as other build logic](https://github.com/travis-ci/travis-build/blob/bc5ddbd594d61c1135d931af6dfa7da7c45b4b13/lib/travis/build/bash/travis_cmd.bash#L57) (so that environment changes they make are seen by further commands), so errexit would break the enveloping internal logic. You have a few options here: Put the commands into a separate script and run it (with -e or whatever), as a subprocess. Invoke consecutive commands as cmd1 && \ cmd2 && \ etc so that the status of the first failed command prop…

> **[Travis CI Documentation](https://docs.travis-ci.com/user/job-lifecycle/#breaking-the-build)**
>
> Job Lifecycle

> [@Builds are failing with truncated logs when errexit is used](https://travis-ci.community/t/builds-are-failing-with-truncated-logs-when-errexit-is-used/8708/2):
>
> You are setting errexit option, and your build is dying at the first sign of trouble. I would guess that the logs are not flushed when the script dies, giving you an impression that the build is failing at different points. I would suggest removing set -eto figure out how exactly things are failing for you.

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [October 26, 2020, 5:31am UTC](https://travis-ci.community/t/multiarch-builds-lxd-always-time-out-on-failure-instead-of-exit/7659/11 "2020-10-26T05:31:19Z")

</div>

Split this topic on October 26, 2020, 5:31am UTC

2 posts were split to a new topic: [Build shows as successful even though the sole job failed](https://travis-ci.community/t/build-shows-as-successful-even-though-the-sole-job-failed/10289)
