public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH v4 0/1] add uuid to schroot folder
@ 2022-07-13 15:52 Anton Mikanovich
  2022-07-13 15:52 ` [PATCH v4 1/1] " Anton Mikanovich
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Anton Mikanovich @ 2022-07-13 15:52 UTC (permalink / raw)
  To: isar-users; +Cc: Anton Mikanovich

Changes since v3:

- place generation logic inside bitbake
- regenerate UUID on every bitbake run

Changes since v2:

- re-add PID component
- remove PN component to shorten file name (was added as part of v1)

Changes since v1:

- Add ISAR_BUILD_UUID to BB_HASHBASE_WHITELIST to exclude from cache signature

Anton Mikanovich (1):
  add uuid to schroot folder

 meta/classes/base.bbclass        | 14 ++++++++++++++
 meta/classes/isar-events.bbclass |  3 +++
 meta/classes/sbuild.bbclass      |  2 +-
 meta/conf/bitbake.conf           |  2 +-
 4 files changed, 19 insertions(+), 2 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v4 1/1] add uuid to schroot folder
  2022-07-13 15:52 [PATCH v4 0/1] add uuid to schroot folder Anton Mikanovich
@ 2022-07-13 15:52 ` Anton Mikanovich
  2022-07-13 15:55 ` [PATCH v4 0/1] " Anton Mikanovich
  2022-07-21 12:24 ` Anton Mikanovich
  2 siblings, 0 replies; 4+ messages in thread
From: Anton Mikanovich @ 2022-07-13 15:52 UTC (permalink / raw)
  To: isar-users; +Cc: Anton Mikanovich, Felix Moessbauer

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 adds an additional UUID component stored till the end of
the build in bitbake persistend storage.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes/base.bbclass        | 14 ++++++++++++++
 meta/classes/isar-events.bbclass |  3 +++
 meta/classes/sbuild.bbclass      |  2 +-
 meta/conf/bitbake.conf           |  2 +-
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 4ec2c81..1d954de 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -278,3 +278,17 @@ def base_set_filespath(path, d):
             if p != "":
                 filespath.append(os.path.join(p, o))
     return ":".join(filespath)
+
+def calculate_build_uuid(d):
+    import uuid
+
+    uuid_data = bb.persist_data.persist('BB_ISAR_UUID_DATA', d)
+    if "uuid" not in uuid_data or not uuid_data["uuid"]:
+        # Generate new UUID
+        uuid_data["uuid"] = str(uuid.uuid4())
+
+    return uuid_data["uuid"]
+
+# Unique ID for this build, used to avoid name clashes on external mountpoints
+# When running parallel builds in different PID namespaces
+ISAR_BUILD_UUID = "${@ calculate_build_uuid(d)}"
diff --git a/meta/classes/isar-events.bbclass b/meta/classes/isar-events.bbclass
index 92aff20..f52b234 100644
--- a/meta/classes/isar-events.bbclass
+++ b/meta/classes/isar-events.bbclass
@@ -60,6 +60,9 @@ python build_completed() {
                     stdout=subprocess.DEVNULL,
                     stderr=subprocess.DEVNULL,
                 )
+
+    # Cleanup build UUID, the next bitbake run will generate new one
+    bb.persist_data.persist('BB_ISAR_UUID_DATA', d).clear()
 }
 
 build_completed[eventmask] = "bb.event.BuildCompleted"
diff --git a/meta/classes/sbuild.bbclass b/meta/classes/sbuild.bbclass
index f9bfaaf..7c39954 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}-${ISAR_BUILD_UUID}-${@os.getpid()}"
 
 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 6451cb5..cadfbdd 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -104,7 +104,7 @@ BB_HASHBASE_WHITELIST ?= "TMPDIR FILE PATH PWD BB_TASKHASH BBPATH BBSERVER DL_DI
     WORKDIR STAMPCLEAN PKGDATA_DIR BUILD_ARCH SSTATE_PKGARCH \
     BB_WORKERCONTEXT BB_LIMITEDDEPS DEPLOY_DIR BUILDCHROOT_DIR \
     REPO_ISAR_DIR REPO_ISAR_DB_DIR REPO_BASE_DIR REPO_BASE_DB_DIR LAYERDIR_core \
-    SCRIPTSDIR TOPDIR"
+    SCRIPTSDIR TOPDIR ISAR_BUILD_UUID"
 BB_HASHCONFIG_WHITELIST ?= "${BB_HASHBASE_WHITELIST} DATE TIME SSH_AGENT_PID \
     SSH_AUTH_SOCK PSEUDO_BUILD BB_ENV_EXTRAWHITE DISABLE_SANITY_CHECKS \
     BB_NUMBER_THREADS BB_ORIGENV BB_INVALIDCONF BBINCLUDED \
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4 0/1] add uuid to schroot folder
  2022-07-13 15:52 [PATCH v4 0/1] add uuid to schroot folder Anton Mikanovich
  2022-07-13 15:52 ` [PATCH v4 1/1] " Anton Mikanovich
@ 2022-07-13 15:55 ` Anton Mikanovich
  2022-07-21 12:24 ` Anton Mikanovich
  2 siblings, 0 replies; 4+ messages in thread
From: Anton Mikanovich @ 2022-07-13 15:55 UTC (permalink / raw)
  To: Felix Moessbauer, isar-users

13.07.2022 18:52, Anton Mikanovich wrote:
> Changes since v3:
>
> - place generation logic inside bitbake
> - regenerate UUID on every bitbake run
>
> Changes since v2:
>
> - re-add PID component
> - remove PN component to shorten file name (was added as part of v1)
>
> Changes since v1:
>
> - Add ISAR_BUILD_UUID to BB_HASHBASE_WHITELIST to exclude from cache signature
>
> Anton Mikanovich (1):
>    add uuid to schroot folder
>
>   meta/classes/base.bbclass        | 14 ++++++++++++++
>   meta/classes/isar-events.bbclass |  3 +++
>   meta/classes/sbuild.bbclass      |  2 +-
>   meta/conf/bitbake.conf           |  2 +-
>   4 files changed, 19 insertions(+), 2 deletions(-)
>
Here is a branch for testing v4 patch:
https://github.com/ilbers/isar/tree/amikan/uuid


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4 0/1] add uuid to schroot folder
  2022-07-13 15:52 [PATCH v4 0/1] add uuid to schroot folder Anton Mikanovich
  2022-07-13 15:52 ` [PATCH v4 1/1] " Anton Mikanovich
  2022-07-13 15:55 ` [PATCH v4 0/1] " Anton Mikanovich
@ 2022-07-21 12:24 ` Anton Mikanovich
  2 siblings, 0 replies; 4+ messages in thread
From: Anton Mikanovich @ 2022-07-21 12:24 UTC (permalink / raw)
  To: isar-users

13.07.2022 18:52, Anton Mikanovich wrote:
> Changes since v3:
>
> - place generation logic inside bitbake
> - regenerate UUID on every bitbake run
>
> Changes since v2:
>
> - re-add PID component
> - remove PN component to shorten file name (was added as part of v1)
>
> Changes since v1:
>
> - Add ISAR_BUILD_UUID to BB_HASHBASE_WHITELIST to exclude from cache signature
>
> Anton Mikanovich (1):
>    add uuid to schroot folder
>
>   meta/classes/base.bbclass        | 14 ++++++++++++++
>   meta/classes/isar-events.bbclass |  3 +++
>   meta/classes/sbuild.bbclass      |  2 +-
>   meta/conf/bitbake.conf           |  2 +-
>   4 files changed, 19 insertions(+), 2 deletions(-)
>
Applied to next.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-21 12:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 15:52 [PATCH v4 0/1] add uuid to schroot folder Anton Mikanovich
2022-07-13 15:52 ` [PATCH v4 1/1] " Anton Mikanovich
2022-07-13 15:55 ` [PATCH v4 0/1] " Anton Mikanovich
2022-07-21 12:24 ` Anton Mikanovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox