| 15402 | addConsoleMessage('Connection dropped while updating - verifying whether the update completed...', 'info'); |
| 15403 | updateElement('update-info', 'Connection dropped. Verifying update...'); |
| 15404 | setButtonState(true, 'Verifying...'); |
| 15405 | setTimeout(() => { |
| 15406 | verifyServiceRestart(''); |
| 15407 | }, 5000); |
| 15408 | return; |
| 15409 | } |
| 15410 | const payload = error.payload || { error: error.message }; |
| 15411 | if (payload.code === 'busy') { |
| 15412 | // Two tabs, two clicks. The other one is doing the work - follow it |
| 15413 | // rather than reporting a failure that did not happen. |
| 15414 | addConsoleMessage('An update is already running on this box - watching it instead.', 'info'); |
| 15415 | setButtonState(true, 'Updating...'); |
| 15416 | verifyServiceRestart(''); |
| 15417 | return; |
| 15418 | } |
| 15419 | const message = reportUpdateProblem('Update failed', payload); |
| 15420 | setButtonState(false, idleLabel); |
| 15421 | updateElement('update-info', payload.hint || `Update failed: ${message}`); |
| 15422 | } |
| 15423 | } |
| 15424 | |
| 15425 | // Watch the box through the restart. Ragnar hands the tail of an update |
| 15426 | // (dependency installs, provisioning) to a transient systemd unit that restarts |
| 15427 | // the service when it is done, so "the API answers" is not the same as "the |
| 15428 | // update finished" - the commit the box reports has to change too. |
| 15429 | async function verifyServiceRestart(expectedCommit) { |
| 15430 | let attempts = 0; |
| 15431 | // 5 minutes of silence is the giving-up point, but post-update work that is |