Skip to contentSkip to conversation

releaseselector: Fix know issues and improve configuration retrieval

PATCH New Mathieu Dubois-Briand 1 participant 6 messages Nov 4

lore
Share & tools
lore
#0 lore raw

cover releaseselector: Fix know issues and improve configuration retrieval

Try to fix known issue [1], where the selected configuration is not applied correctly. Also improved the way we retrieve the configuration, so we no longer use this hack where each list items contained the whole configuration.

This was AI-assisted quite a lot, because JS... Still, the code looks sane.

[1]: https://bugzilla.yoctoproject.org/show_bug.cgi?id=16291

---
Mathieu Dubois-Briand (5):
docker: Use https instead of git protocol
docker: Refresh patches and fix configuration
releaseselector: Fix release selector not applied on keyboard use
releaseselector: Fix checkbox filling
releaseselector: Read release shortcuts from the force scheduler spec

 docker/Dockerfile                                  |   8 +-
 docker/entry.sh                                    |   1 +
 ...builders-Do-not-create-tags-during-builds.patch |  10 +-
 ...Modify-free-space-check-to-work-in-docker.patch |  21 ++--
 yocto_console_view/src/releaseselectorfield.ts     | 107 +++++++++++----------
 yocto_console_view/yocto_console_view/__init__.py  |   9 +-
 6 files changed, 78 insertions(+), 78 deletions(-)

---
base-commit: 41f0281bea933dd4603a4fe25ddb9de8a062526f
change-id: 20261104-mathieu-release-selector-fix-ae4f17ca5dee

Best regards,

Signature · 1 line
Mathieu Dubois-Briand <[email protected]>
#1 lore raw

PATCH 1/5 docker: Use https instead of git protocol

---
 docker/Dockerfile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
docker/Dockerfile +2 -2
index 793343a26017..361d409f990c 100644
@@ -115,8 +115,8 @@ RUN sed -i \
         -e '$ a workers_prev_releases = {}' \
         /home/pokybuild/yocto-controller/yoctoabb/config.py && \
     sed -i \
-        # Use git protocol instead of ssh
-        -e "s#ssh://git@push\.\(yoctoproject.org\|openembedded.org\)/#git://git.\1/#" \
+        # Use https instead of ssh
+        -e "s#ssh://git@push\.\(yoctoproject.org\|openembedded.org\)/#https://git.\1/#" \
         /home/pokybuild/yocto-autobuilder-helper/config.json && \
     sed -i \
         # imp was removed in python 3.12, switch to importlib \
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/5 docker: Refresh patches and fix configuration

In reply to Mathieu Dubois-Briand
---
 docker/Dockerfile                                   |  4 ++--
 docker/entry.sh                                     |  1 +
 ...-builders-Do-not-create-tags-during-builds.patch | 10 +++++-----
 ...-Modify-free-space-check-to-work-in-docker.patch | 21 ++++++++++-----------
 4 files changed, 18 insertions(+), 18 deletions(-)
docker/Dockerfile +2 -2
index 361d409f990c..0ddd20d52ac6 100644
@@ -107,8 +107,8 @@ RUN sed -i \
         # Add local workers \
         -e "s/^\(workers_debian *=.*\).*/\1 + [f\"local-worker-debian\"]/" \
         -e "s/^\(workers *=.*\).*/\1 + [f\"local-worker-extra-{i}\" for i in range(1, 9)]/" \
-        # Remove workers_bringup from all_workers \
-        -e "/^all_workers *=/s/workers_bringup + //" \
+        # Empty workers_bringup variable \
+        -e "s/^\(workers_bringup *=\).*/\1 []/" \
         # Switch from ssh:// URLS to https:// so we do not need any auth \
         -e "s#ssh://git@push\.\(yoctoproject.org\|openembedded.org\)/#https://git.\1/#" \
         # Use any worker for any release \
docker/entry.sh +1 -0
index 125f447be4f2..aac1af9dc1da 100644
@@ -2,6 +2,7 @@
 
 chmod 666 /dev/kvm
 
+mkdir -p /srv/autobuilder/repos /srv/autobuilder/autobuilder.yocto.io/pub
 chown pokybuild:nogroup /srv/autobuilder/repos
 chown pokybuild:nogroup /srv/autobuilder/autobuilder.yocto.io/pub
 chown pokybuild:nogroup /home/pokybuild/git/mirror
docker/yocto-autobuilder2_patches/0001-builders-Do-not-create-tags-during-builds.patch +5 -5
index c1482f72c8e4..7549329ba68a 100644
@@ -1,4 +1,4 @@
-From b6a31b0c63a7529961ea02c53f43b9edb110f4de Mon Sep 17 00:00:00 2001
+From 3bc68471778693c59a692a26d5ef5a9d9212d901 Mon Sep 17 00:00:00 2001
 From: Mathieu Dubois-Briand <[email protected]>
 Date: Fri, 3 Jan 2025 09:39:06 +0100
 Subject: [PATCH 1/2] builders: Do not create tags during builds
@@ -9,10 +9,10 @@ Signed-off-by: Mathieu Dubois-Briand <[email protected]>
  1 file changed, 13 deletions(-)
 
 diff --git a/builders.py b/builders.py
-index b7379ece71f2..d87e41c9233e 100644
+index 2d42d07e3b9a..574a23cc86bd 100644
 --- a/builders.py
 +++ b/builders.py
-@@ -314,18 +314,9 @@ def create_parent_builder_factory(buildername, waitname):
+@@ -337,18 +337,9 @@ 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,
@@ -31,7 +31,7 @@ index b7379ece71f2..d87e41c9233e 100644
      factory.addStep(steps.SetProperty(
          property="sharedrepolocation",
          value=util.Interpolate("{}/%(prop:buildername)s-%(prop:buildnumber)s".format(config.sharedrepodir))
-@@ -374,7 +365,6 @@ def create_parent_builder_factory(buildername, waitname):
+@@ -406,7 +397,6 @@ def create_parent_builder_factory(buildername, waitname):
              "rc_number": util.Property("rc_number"),
              "yp_build_revision": util.Property("yp_build_revision"),
              "yp_build_branch": util.Property("yp_build_branch"),
@@ -39,7 +39,7 @@ index b7379ece71f2..d87e41c9233e 100644
          }
  
          for repo in config.buildertorepos[buildername]:
-@@ -385,9 +375,6 @@ def create_parent_builder_factory(buildername, waitname):
+@@ -417,9 +407,6 @@ def create_parent_builder_factory(buildername, waitname):
          set_props["milestone_number"] = util.Property("milestone_number")
          set_props["rc_number"] = util.Property("rc_number")
  
docker/yocto-autobuilder2_patches/0002-builders-Modify-free-space-check-to-work-in-docker.patch +10 -11
index 8c0ad1c93cbe..0ced8eaf7220 100644
@@ -1,19 +1,18 @@
-From c6032ab33d39981eb9dede27d0bbd073a8d58389 Mon Sep 17 00:00:00 2001
+From d2ac1923753ea987117f89506790f749370f8a77 Mon Sep 17 00:00:00 2001
 From: Mathieu Dubois-Briand <[email protected]>
 Date: Wed, 20 Nov 2024 14:53:34 +0100
 Subject: [PATCH 2/2] builders: Modify free space check to work in docker
 
 Signed-off-by: Mathieu Dubois-Briand <[email protected]>
 ---
- builders.py | 5 ++---
- 1 file changed, 2 insertions(+), 3 deletions(-)
+ builders.py | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
 
 diff --git a/builders.py b/builders.py
-index a16a857d9211..d5389283e605 100644
+index 574a23cc86bd..fb825bad72e7 100644
 --- a/builders.py
 +++ b/builders.py
-@@ -70,8 +70,7 @@ def canStartBuild(builder, wfb, request):
- 
+@@ -73,7 +73,6 @@ def canStartBuild(builder, wfb, request):
      # threshold is GB of space
      checks = {
 -        "." : (200, "HOME"),
@@ -22,15 +21,15 @@ index a16a857d9211..d5389283e605 100644
      }
  
      for mountpoint in checks:
-@@ -79,7 +78,7 @@ def canStartBuild(builder, wfb, request):
+@@ -81,7 +80,7 @@ def canStartBuild(builder, wfb, request):
  
          bytes_in_gb = 1024 * 1024 * 1024
  
--        cmd = yield shell("findmnt -T %s --df -n --bytes | awk '{print $5}'" % mountpoint, wfb.worker, builder)
-+        cmd = yield shell("findmnt --all -T %s --df -n --bytes | awk '{print $5}'" % mountpoint, wfb.worker, builder)
+-        cmd = yield shell(["findmnt", "-T", mountpoint, "--df", "-n", "--bytes",
++        cmd = yield shell(["findmnt", "--all", "-T", mountpoint, "--df", "-n", "--bytes",
+                            "-o", "AVAIL"],
+                           wfb.worker, builder)
          space = int(cmd.stdout.strip())
-         if space < threshold * bytes_in_gb:
-             log.msg("Detected {0} GB of space available on {1}, less than threshold of {2} GB. Can't start build".format(space / bytes_in_gb, name, threshold))
 -- 
 2.47.3
 
Signature · 1 line
2.47.3
#3 lore raw

PATCH 3/5 releaseselector: Fix release selector not applied on keyboard use

In reply to Mathieu Dubois-Briand

When a release shortcut was picked with the keyboard, the fields it maps to were not applied. Additionally, pressing return could raise a JS exception.

Now the configuration is captured in a selectors map when the menu opens, and reused later. Also, return key only applies the selected entry when the focus is in the release selector field.

[YOCTO #16291]

AI-Generated: Uses opencode (DeepSeek V4 Flash)

---
 yocto_console_view/src/releaseselectorfield.ts | 60 +++++++++++++++-----------
 1 file changed, 35 insertions(+), 25 deletions(-)
yocto_console_view/src/releaseselectorfield.ts +35 -25
index db707ef09174..1d82310da261 100644
@@ -3,6 +3,14 @@ buildbotSetupPlugin((reg) => {
 	let selectInputName = null;
 	let selectListName = null;
 	let inputRefs = null;
+	let selectors = new Map();
+	let lastName = null;
+
+	function selectedName() {
+		const input = document.getElementById(selectInputName);
+		const label = input && input.parentElement.previousElementSibling;
+		return label ? label.textContent.split(':')[0] : null;
+	}
 
 	const onTransitionEndEvent = (event) => {
 		/*
@@ -54,6 +62,7 @@ buildbotSetupPlugin((reg) => {
 		selectInputName = releaseSelector.attributes.getNamedItem('id').value;
 		const selectName = selectInputName.substring(0, selectInputName.lastIndexOf('-'));
 		selectListName = selectName + '-listbox';
+		lastName = selectedName();
 	}
 	window.addEventListener('transitionend', onTransitionEndEvent);
 
@@ -61,13 +70,13 @@ buildbotSetupPlugin((reg) => {
 		if (selectListName) {
 			const listDiv = document.getElementById(selectListName);
 			if (listDiv) {
-				/*
-				 * The ReleaseSelector menu is shown: clean menu items.
-				 */
-
 				listDiv.childNodes.forEach(div => {
 					const sepIdx = div.textContent.indexOf(':');
 					if (sepIdx >= 0) {
+						try {
+							selectors.set(div.textContent.substring(0, sepIdx),
+							              JSON.parse(div.textContent.substring(sepIdx + 1)));
+						} catch (e) {}
 						div.textContent = div.textContent.substring(0, sepIdx);
 					}
 				});
@@ -75,21 +84,11 @@ buildbotSetupPlugin((reg) => {
 		}
 	}
 
-	function findApplySelector() {
-		/*
-		 * One entry was clicked in the ReleaseSelector
-		 * menu: update all fields described by the
-		 * selector configuration.
-		 */
-		const branchInput = document.getElementById(selectInputName);
-		const inputText = branchInput.parentElement.previousElementSibling.textContent;
-		const sepIdx = inputText.indexOf(':');
-		const selectorName = inputText.substring(0, sepIdx);
-		const selector = inputText.substring(sepIdx + 1);
-
-		new Promise((resolve, reject) => {
-			return applySelector(JSON.parse(selector), selectorName).then(resolve);
-		});
+	function applySelectorByName(name) {
+		const selector = selectors.get(name);
+		if (selector) {
+			applySelector(selector, name).catch(e => console.error(e));
+		}
 	}
 
 	const onClick = (event) => {
@@ -98,18 +97,29 @@ buildbotSetupPlugin((reg) => {
 		if (event.target.parentElement) {
 			const parentId = event.target.parentElement.attributes.getNamedItem('id');
 			if (parentId && parentId.value == selectListName) {
-				findApplySelector();
+				lastName = event.target.textContent.split(':')[0];
+				applySelectorByName(lastName);
 			}
 		}
 	}
 	window.addEventListener('click', onClick);
 
 	const onKeyDown = (event) => {
-		if (event.key == "Enter") {
-			findApplySelector();
-		} else {
-			updateSelectors();
-		}
+		const branchInput = document.getElementById(selectInputName);
+		if (!branchInput || !branchInput.contains(event.target) || event.key != "Enter")
+			return;
+		/*
+		 * The combobox commits the selection when Enter is pressed. Read the
+		 * displayed label once the new value has been rendered (deferred), and
+		 * apply the shortcut only if it actually changed.
+		 */
+		setTimeout(() => {
+			const name = selectedName();
+			if (name && name != lastName) {
+				lastName = name;
+				applySelectorByName(name);
+			}
+		}, 0);
 	}
 	window.addEventListener('keydown', onKeyDown);
 
Signature · 1 line
2.47.3
#4 lore raw

PATCH 4/5 releaseselector: Fix checkbox filling

In reply to Mathieu Dubois-Briand

Set element.checked for checkboxes and dispatch a change event so the form picks the new value.

[YOCTO #16291]

AI-Generated: Uses opencode (DeepSeek V4 Flash)

---
 yocto_console_view/src/releaseselectorfield.ts | 5 +++++
 1 file changed, 5 insertions(+)
yocto_console_view/src/releaseselectorfield.ts +5 -0
index 1d82310da261..1c4d289af224 100644
@@ -182,6 +182,11 @@ buildbotSetupPlugin((reg) => {
 	const UIValue = Symbol('Displayed value in UI');
 	async function setFieldValue(element, value) {
 		element.focus();
+		if (element.type == 'checkbox') {
+			element.checked = !!value;
+			element.dispatchEvent(new Event('change', {bubbles: true}));
+			return;
+		}
 		element[UIValue] = value;
 		element.value = Object.assign(new String(value), {
 			[UIValue]: true
Signature · 1 line
2.47.3
#5 lore raw

PATCH 5/5 releaseselector: Read release shortcuts from the force scheduler spec

In reply to Mathieu Dubois-Briand

The release selector configuration was encoded in the choice strings and decoded in the browser. Instead, use field spec attribute to retrieve them.

AI-Generated: Uses opencode (DeepSeek V4 Flash)

---
 yocto_console_view/src/releaseselectorfield.ts    | 52 ++++++++++-------------
 yocto_console_view/yocto_console_view/__init__.py |  9 +---
 2 files changed, 23 insertions(+), 38 deletions(-)
yocto_console_view/src/releaseselectorfield.ts +22 -30
index 1c4d289af224..c5c681a51e29 100644
@@ -1,5 +1,5 @@
 import {buildbotSetupPlugin} from "buildbot-plugin-support";
-buildbotSetupPlugin((reg) => {
+buildbotSetupPlugin((reg, config) => {
 	let selectInputName = null;
 	let selectListName = null;
 	let inputRefs = null;
@@ -12,6 +12,26 @@ buildbotSetupPlugin((reg) => {
 		return label ? label.textContent.split(':')[0] : null;
 	}
 
+	async function loadSelectors() {
+		try {
+			const res = await fetch(config.buildbotURL + 'api/v2/forceschedulers', {
+				headers: {accept: 'application/json'}
+			});
+			const data = await res.json();
+			for (const sched of data.forceschedulers ?? []) {
+				for (const field of sched.all_fields) {
+					if (field.selectors) {
+						selectors = new Map(Object.entries(field.selectors));
+						return;
+					}
+				}
+			}
+		} catch (e) {
+			console.error('releaseselector: failed to load release shortcuts:', e);
+		}
+	}
+	loadSelectors();
+
 	const onTransitionEndEvent = (event) => {
 		/*
 		 * We are looking for the transition showing the "forcebuild" dialog.
@@ -46,19 +66,11 @@ buildbotSetupPlugin((reg) => {
 			prepareInterceptor(input);
 		});
 
-		/*
-		 * Only show the pretty name in the release selector field.
-		 */
-		const releaseSelector = inputRefs.get('force-field-branchselector');
-		const releaseSelectorLabel = releaseSelector.parentNode.previousSibling;
-		const sepIdx = releaseSelectorLabel.textContent.indexOf(':');
-		if (sepIdx >= 0) {
-			releaseSelectorLabel.textContent = releaseSelectorLabel.textContent.substring(0, sepIdx);
-		}
 
 		/*
 		 * Get the name of the ReleaseSelector field div.
 		 */
+		const releaseSelector = inputRefs.get('force-field-branchselector');
 		selectInputName = releaseSelector.attributes.getNamedItem('id').value;
 		const selectName = selectInputName.substring(0, selectInputName.lastIndexOf('-'));
 		selectListName = selectName + '-listbox';
@@ -66,24 +78,6 @@ buildbotSetupPlugin((reg) => {
 	}
 	window.addEventListener('transitionend', onTransitionEndEvent);
 
-	function updateSelectors() {
-		if (selectListName) {
-			const listDiv = document.getElementById(selectListName);
-			if (listDiv) {
-				listDiv.childNodes.forEach(div => {
-					const sepIdx = div.textContent.indexOf(':');
-					if (sepIdx >= 0) {
-						try {
-							selectors.set(div.textContent.substring(0, sepIdx),
-							              JSON.parse(div.textContent.substring(sepIdx + 1)));
-						} catch (e) {}
-						div.textContent = div.textContent.substring(0, sepIdx);
-					}
-				});
-			}
-		}
-	}
-
 	function applySelectorByName(name) {
 		const selector = selectors.get(name);
 		if (selector) {
@@ -92,8 +86,6 @@ buildbotSetupPlugin((reg) => {
 	}
 
 	const onClick = (event) => {
-		updateSelectors();
-
 		if (event.target.parentElement) {
 			const parentId = event.target.parentElement.attributes.getNamedItem('id');
 			if (parentId && parentId.value == selectListName) {
yocto_console_view/yocto_console_view/__init__.py +1 -8
index 6118ac29409b..eedf6958cfe9 100644
@@ -16,8 +16,6 @@
 from buildbot.www.plugin import Application
 from buildbot.schedulers.forcesched import ChoiceStringParameter
 
-import json
-
 # create the interface for the setuptools entry point
 ep = Application(__package__, "Yocto Buildbot Console View plugin")
 
@@ -27,10 +25,5 @@ class ReleaseSelector(ChoiceStringParameter):
     selectors = None
 
     def __init__(self, name, selectors, **kw):
-        def format_choice(choice):
-            return choice + ': ' + json.dumps(selectors.get(choice, {}))
-
         super().__init__(name, **kw)
-        self.choices = [format_choice(choice)
-                        for choice in kw.get('choices', {})]
-        self.__dict__['default'] = format_choice(self.__dict__['default'])
+        self.selectors = selectors
Signature · 1 line
2.47.3