Portal: continue a failed run from the same start action
This commit is contained in:
parent
aa37396f66
commit
44421bb76c
4 changed files with 17 additions and 2 deletions
|
|
@ -49,7 +49,8 @@ mode and snapshot it already had, so nothing is pinned twice. Until now a resume
|
|||
as the transient `archipelago-cycle-resume.service`, which the portal's stop button
|
||||
and status view did not know about; now one ordinary service unit covers starts,
|
||||
resumes and stops. `resolve_request` in the driver is covered by
|
||||
`tests/cycle-recovery.py`.
|
||||
`tests/cycle-recovery.py`. The portal shows `↻ Продолжить <run>` only while the
|
||||
latest run is failed and nothing is running, and sends exactly that request.
|
||||
|
||||
The first resume then failed in `building-core`, 38 s in, on
|
||||
`cp: cannot stat '.../software-adapter/libgs_plugin_archipelago.so'`: the failed
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ async function control(action, parameters) {
|
|||
const result=await api('/api/control',{method:'POST',headers:{'Content-Type':'application/json','X-Archipelago-Control':'1'},body:JSON.stringify(Object.assign({action},parameters||{}))});
|
||||
if(action==='start'){
|
||||
const req=result.request||{};
|
||||
$('action-result').textContent=`Принято: ${req.mode==='ostree'?'только OSTree':'ISO + OSTree'} · снимок ${req.snapshot}`;
|
||||
$('action-result').textContent=req.resume
|
||||
? `Принято: продолжение прогона ${status?.runs?.[0]?.run||''} · снимок и режим прежние`
|
||||
: `Принято: ${req.mode==='ostree'?'только OSTree':'ISO + OSTree'} · снимок ${req.snapshot}`;
|
||||
run='';runsKey='';
|
||||
} else {
|
||||
$('action-result').textContent=({stop:'Остановка передана systemd','schedule-on':'Расписание включено','schedule-off':'Расписание отключено'})[action]||'Принято';
|
||||
|
|
@ -46,6 +48,9 @@ async function control(action, parameters) {
|
|||
catch(e){showError(e);}finally{refresh();}
|
||||
}
|
||||
$('start').onclick=()=>control('start',{mode:$('build-mode').value,snapshot:$('build-snapshot').value});$('stop').onclick=()=>control('stop');
|
||||
// A failed run continues under the same service unit: it keeps its own mode and
|
||||
// immutable snapshot, so the stop button and the status always describe it.
|
||||
$('resume').onclick=()=>control('start',{resume:true});
|
||||
$('toggle-schedule').onclick=()=>control(status?.timer.ActiveState==='active'?'schedule-off':'schedule-on');
|
||||
function drawStatus(s) {
|
||||
status=s;const active=['active','activating'].includes(s.service.ActiveState);const stopping=s.service.ActiveState==='deactivating';
|
||||
|
|
@ -54,6 +59,10 @@ function drawStatus(s) {
|
|||
$('schedule').textContent=s.timer.ActiveState==='active'?'ISO+OSTree · 1-е число':'Приостановлено';
|
||||
$('next').textContent='Следующий: '+(s.timer.ActiveState==='active' && s.next_release ? `${s.next_release.date} · ${s.next_release.mode} · ${s.next_release.time}` : '—');
|
||||
$('start').disabled=active||stopping;$('stop').disabled=!active;$('toggle-schedule').disabled=false;
|
||||
// Continue only a failed run; a complete one is a finished publication.
|
||||
const latest=s.runs?.[0];
|
||||
$('resume').disabled=active||stopping||!latest||latest.state!=='failed';
|
||||
$('resume').textContent=latest&&latest.state==='failed'?`↻ Продолжить ${latest.run}`:'↻ Продолжить';
|
||||
$('build-mode').disabled=active||stopping;$('build-snapshot').disabled=active||stopping;
|
||||
const snapshots=s.snapshots||[];
|
||||
$('snapshot').textContent=snapshots.length?snapshots[0].date:'Нет снимков';
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
</select>
|
||||
</label>
|
||||
<button id="start" class="primary" disabled>▶ Запустить сборку</button>
|
||||
<button id="resume" class="tonal" disabled>↻ Продолжить</button>
|
||||
<button id="stop" class="danger" disabled>■ Остановить</button>
|
||||
<button id="toggle-schedule" class="tonal" disabled>Расписание</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -198,6 +198,10 @@ class Portal(unittest.TestCase):
|
|||
self.assertIn('function progressOf(', script)
|
||||
self.assertIn("track.setAttribute('aria-valuenow'", script)
|
||||
self.assertIn("control('start',{mode:$('build-mode').value,snapshot:$('build-snapshot').value})", script)
|
||||
# Resume is the same start action: one unit, one stop button, one status.
|
||||
self.assertIn('id="resume"', html)
|
||||
self.assertIn("$('resume').onclick=()=>control('start',{resume:true})", script)
|
||||
self.assertIn("latest.state!=='failed'", script)
|
||||
|
||||
def test_failed_action_is_durable(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue