public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Felix Moessbauer <felix.moessbauer@siemens.com>
To: isar-users@googlegroups.com
Cc: florian.bezdeka@siemens.com, amikan@ilbers.de,
	henning.schild@siemens.com,
	Felix Moessbauer <felix.moessbauer@siemens.com>
Subject: [PATCH] add uuid to schroot folder instead of pid
Date: Fri,  1 Jul 2022 14:21:19 +0200	[thread overview]
Message-ID: <20220701122119.3607843-1-felix.moessbauer@siemens.com> (raw)

PIDs are not unique across containers.
When running the build in a container (e.g. the kas container),
the PID of bitbake is likely the same across multiple simultaneously
running builds.

This is especially the case for CI runners, where it is common that
multiple jobs run in parallel.

This patch replaces the PID component by a random UUID that is injected
from the ISAR environment.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes/sbuild.bbclass    | 2 +-
 meta/conf/bitbake.conf         | 7 ++++++-
 scripts/isar-buildenv-internal | 4 +++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/meta/classes/sbuild.bbclass b/meta/classes/sbuild.bbclass
index f9bfaaf6..03917533 100644
--- a/meta/classes/sbuild.bbclass
+++ b/meta/classes/sbuild.bbclass
@@ -23,7 +23,7 @@ python __anonymous() {
     d.setVar('SCHROOT_DEP', dep)
 }
 
-SBUILD_CHROOT ?= "${DEBDISTRONAME}-${SCHROOT_USER}-${@os.getpid()}"
+SBUILD_CHROOT ?= "${DEBDISTRONAME}-${SCHROOT_USER}-${PN}-${ISAR_BUILD_UUID}"
 
 SBUILD_CONF_DIR ?= "${SCHROOT_CONF}/${SBUILD_CHROOT}"
 SCHROOT_CONF_FILE ?= "${SCHROOT_CONF}/chroot.d/${SBUILD_CHROOT}"
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 6451cb59..1beedbe8 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -110,7 +110,7 @@ BB_HASHCONFIG_WHITELIST ?= "${BB_HASHBASE_WHITELIST} DATE TIME SSH_AGENT_PID \
     BB_NUMBER_THREADS BB_ORIGENV BB_INVALIDCONF BBINCLUDED \
     GIT_PROXY_COMMAND ALL_PROXY all_proxy NO_PROXY no_proxy FTP_PROXY ftp_proxy \
     HTTP_PROXY http_proxy HTTPS_PROXY https_proxy SOCKS5_USER SOCKS5_PASSWD \
-    BB_SETSCENE_ENFORCE BB_CMDLINE BB_SERVER_TIMEOUT"
+    BB_SETSCENE_ENFORCE BB_CMDLINE BB_SERVER_TIMEOUT ISAR_BUILD_UUID"
 BB_SIGNATURE_HANDLER ?= "basichash"
 BB_STAMP_POLICY ?= "full"
 
@@ -134,6 +134,11 @@ USE_CCACHE ??= "0"
 CCACHE_TOP_DIR ?= "${TMPDIR}/ccache"
 CCACHE_DIR ?= "${CCACHE_TOP_DIR}/${DISTRO}-${DISTRO_ARCH}"
 
+# Unique ID for this build, used to avoid name clashes on external mountpoints
+# When running parallel builds in different PID namespaces, overwrite
+# this with a globally unique value (e.g. by injecting a UUID from the environment)
+ISAR_BUILD_UUID ??= "none"
+
 include conf/local.conf
 include conf/multiconfig/${BB_CURRENT_MC}.conf
 include conf/machine/${MACHINE}.conf
diff --git a/scripts/isar-buildenv-internal b/scripts/isar-buildenv-internal
index ec8e4377..e5cb5364 100755
--- a/scripts/isar-buildenv-internal
+++ b/scripts/isar-buildenv-internal
@@ -62,6 +62,8 @@ export BUILDDIR
 export BITBAKEDIR="${ISARROOT}/bitbake"
 export SCRIPTSDIR="${ISARROOT}/scripts"
 export TESTSUITEDIR="${ISARROOT}/testsuite"
+# use builtin python uuid to avoid dep to uuidgen
+export ISAR_BUILD_UUID="$(python3 -c 'import uuid; print(str(uuid.uuid4()))')"
 
 for newpath in "$BITBAKEDIR/bin" "$SCRIPTSDIR"; do
     # Remove any existences of $newpath from $PATH
@@ -77,5 +79,5 @@ export PATH
 BBPATH="${BUILDDIR}"
 export BBPATH
 
-BB_ENV_EXTRAWHITE="BITBAKEDIR SCRIPTSDIR TESTSUITEDIR http_proxy https_proxy ftp_proxy no_proxy GNUPGHOME"
+BB_ENV_EXTRAWHITE="BITBAKEDIR SCRIPTSDIR TESTSUITEDIR http_proxy https_proxy ftp_proxy no_proxy GNUPGHOME ISAR_BUILD_UUID"
 export BB_ENV_EXTRAWHITE
-- 
2.30.2


                 reply	other threads:[~2022-07-01 12:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220701122119.3607843-1-felix.moessbauer@siemens.com \
    --to=felix.moessbauer@siemens.com \
    --cc=amikan@ilbers.de \
    --cc=florian.bezdeka@siemens.com \
    --cc=henning.schild@siemens.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox