From 3111992beaaec830fe28d4ce05024df155515c26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lili=20Gonz=C3=A1lez?= Date: Fri, 24 Oct 2025 18:23:49 -0600 Subject: [PATCH] luci-app-attendedsysupgrade: use the same logic as the main build when requesting rebuilds MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When initiating a build the requests were build differently between main and rebuild servers leading to the latter using only POST request instead of the POST->GET flow. This led to incorrect tracking of builds in the target ASU server due to each request being classified unique. This is fixed by switching rebuild requests to the POST->GET flow and storing each server's request hash in a map and using it regardless if it is the main or a rebuild server handling the request. Fixes: openwrt/asu#1526 Signed-off-by: Lili González (cherry picked from commit 31fb9ce1967ee5650777588efaa167a6ac076417) --- .../view/attendedsysupgrade/overview.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js b/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js index 579385d158..eef35d4fda 100644 --- a/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js +++ b/applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js @@ -75,7 +75,7 @@ return view.extend({ unpack_imagebuilder: [ 40, _('Setting Up ImageBuilder')], }, - request_hash: '', + request_hash: new Map(), sha256_unsigned: '', applyPackageChanges: async function(package_info) { @@ -224,9 +224,6 @@ return view.extend({ }, handle202: function (response) { - response = response.json(); - this.request_hash = response.request_hash; - if ('queue_position' in response) { ui.showModal(_('Queued...'), [ E( @@ -251,11 +248,11 @@ return view.extend({ } }, - handleError: function (response, data, firmware) { + handleError: function (response, data, firmware, request_hash) { response = response.json(); const request_data = { ...data, - request_hash: this.request_hash, + request_hash: request_hash, sha256_unsigned: this.sha256_unsigned, ...firmware }; @@ -293,13 +290,14 @@ return view.extend({ let request_url = `${server}/api/v1/build`; let method = 'POST'; let local_content = content; + const request_hash = this.request_hash.get(server); /** * If `request_hash` is available use a GET request instead of * sending the entire object. */ - if (this.request_hash && main == true) { - request_url += `/${this.request_hash}`; + if (request_hash) { + request_url += `/${request_hash}`; local_content = {}; method = 'GET'; } @@ -309,11 +307,13 @@ return view.extend({ .then((response) => { switch (response.status) { case 202: + response = response.json(); + + this.request_hash.set(server, response.request_hash); + if (main) { this.handle202(response); } else { - response = response.json(); - let view = document.getElementById(server); view.innerText = `⏳ (${ this.steps[response.imagebuilder_status][0] @@ -341,7 +341,7 @@ return view.extend({ default: // any error or unexpected responses if (main == true) { poll.remove(this.pollFn); - this.handleError(response, data, firmware); + this.handleError(response, data, firmware, request_hash); } else { poll.remove(this.rebuilder_polls[server]); document.getElementById(server).innerText = '🚫 %s'.format( @@ -441,7 +441,7 @@ return view.extend({ }, handleCheck: function (data, firmware) { - this.request_hash = ''; + this.request_hash.clear(); let { url, revision, advanced_mode, branch } = data; let { version, target, profile, packages } = firmware; let candidates = []; -- 2.30.2