summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLili González2025-10-25 00:23:49 +0000
committerPaul Donald2025-10-25 21:02:13 +0000
commit31fb9ce1967ee5650777588efaa167a6ac076417 (patch)
treed5362f23835419adfc7c935fc01d876c545651cb
parentbd5650565a57c49be22eb2706a1823112e7be88d (diff)
downloadluci-31fb9ce1967ee5650777588efaa167a6ac076417.tar.gz
luci-app-attendedsysupgrade: use the same logic as the main build when requesting rebuilds
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 <lili@guerra24.net>
-rw-r--r--applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js24
1 files 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 = [];