diff mbox series

[yocto-autobuilder2] builders: Add controller url in build tag

Message ID 20250206-mathieu-fix_build_tag-v1-1-f77ee974a76a@bootlin.com
State New
Headers show
Series [yocto-autobuilder2] builders: Add controller url in build tag | expand

Commit Message

Mathieu Dubois-Briand Feb. 6, 2025, 3:28 p.m. UTC
Make sure tags created on a-full/a-quick builds are unique, even across
different controller instances.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
We are creating a tag in https://git.yoctoproject.org/poky-ci-archive/
on each a-full and a-quick builds. Today tags only use buider name and
build number, creating tags such as "a-full-960". But as build number
will reset if we ever switch to a new buildbot controller, we should add
some part describing the controller itself. This patch will add a
fragment based on the controller url in the tag, creating tags like
"autobuilder.yoctoproject.org/valkyrie/a-full-960".
---
 builders.py                                                 | 13 ++++++++++++-
 .../0001-builders-Do-not-create-tags-during-builds.patch    |  8 ++++----
 2 files changed, 16 insertions(+), 5 deletions(-)


---
base-commit: cb639d12eb9694b0cf3b9f8c7fbe18ee08606597
change-id: 20250206-mathieu-fix_build_tag-b77ccc52d649

Best regards,
diff mbox series

Patch

diff --git a/builders.py b/builders.py
index 4f2bf00e5387..b4c08fa1f29c 100644
--- a/builders.py
+++ b/builders.py
@@ -19,6 +19,7 @@  from dateutil.tz import tzutc
 import os
 import json
 import random
+import urllib.parse
 
 
 builders = []
@@ -249,6 +250,16 @@  def prioritizeBuilders(master, builders):
     #log.msg("Using %s" % str(rv))
     return rv
 
+@util.renderer
+def createBuildTag(props):
+    buildername = props.getProperty('buildername')
+    buildnumber = props.getProperty('buildnumber')
+    build = props.getBuild()
+    url = urllib.parse.urlparse(build.master.config.buildbotURL)
+    host = url.netloc.replace(':', '_')
+    url.path
+    return f"{host}{url.path}{buildername}-{buildnumber}"
+
 def create_parent_builder_factory(buildername, waitname):
     factory = util.BuildFactory()
     # NOTE: Assumes that yocto-autobuilder repo has been cloned to home
@@ -273,7 +284,7 @@  def create_parent_builder_factory(buildername, waitname):
             util.Interpolate("%(prop:builddir)s/layerinfo.json"),
             util.Interpolate("{}/%(prop:buildername)s-%(prop:buildnumber)s".format(config.sharedrepodir)),
             "-p", get_publish_dest,
-            "-t", util.Interpolate("%(prop:buildername)s-%(prop:buildnumber)s"),
+            "-t", createBuildTag,
         ],
         haltOnFailure=True,
         name="Prepare shared repositories"))
diff --git a/docker/yocto-autobuilder2_patches/0001-builders-Do-not-create-tags-during-builds.patch b/docker/yocto-autobuilder2_patches/0001-builders-Do-not-create-tags-during-builds.patch
index 567b80f0ae7b..65b428caa1fc 100644
--- a/docker/yocto-autobuilder2_patches/0001-builders-Do-not-create-tags-during-builds.patch
+++ b/docker/yocto-autobuilder2_patches/0001-builders-Do-not-create-tags-during-builds.patch
@@ -1,4 +1,4 @@ 
-From ee671836ad9f0b65fa8b8b11c7f366377521ab20 Mon Sep 17 00:00:00 2001
+From 12db34cf42ca695bd34594853013e54464a809f5 Mon Sep 17 00:00:00 2001
 From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
 Date: Fri, 3 Jan 2025 09:39:06 +0100
 Subject: [PATCH 1/2] builders: Do not create tags during builds
@@ -9,14 +9,14 @@  Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
  1 file changed, 1 deletion(-)
 
 diff --git a/builders.py b/builders.py
-index 14ea1df1192e..ba47241de2cc 100644
+index b4c08fa1f29c..4e10bdceedb2 100644
 --- a/builders.py
 +++ b/builders.py
-@@ -273,7 +273,6 @@ def create_parent_builder_factory(buildername, waitname):
+@@ -284,7 +284,6 @@ def create_parent_builder_factory(buildername, waitname):
              util.Interpolate("%(prop:builddir)s/layerinfo.json"),
              util.Interpolate("{}/%(prop:buildername)s-%(prop:buildnumber)s".format(config.sharedrepodir)),
              "-p", get_publish_dest,
--            "-t", util.Interpolate("%(prop:buildername)s-%(prop:buildnumber)s"),
+-            "-t", createBuildTag,
          ],
          haltOnFailure=True,
          name="Prepare shared repositories"))