vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Start the live step tail at the step's offset
f32f846db159c21ba24c4e5c3005ba4da87aceb4 · Keenan Nemetz · 15d ago · parent 5baf4e73
Start the live step tail at the step's offset The log endpoint reads ?after= as an absolute offset in the attempt log, and clamps it up to the step's start when ?step= narrows the response. The live viewer started its counter at zero and then added the bytes it received, so its counter stayed below the step's start and every early poll was clamped back to the step start, replaying the opening bytes. Two runs of the same job print an identical banner, environment line and step header, so the repeated prefix looked like output leaked from the other running job. Carry the step's LogOffset through to the run page and start the tail counter there. The template test pins the rendered attribute, and a runSteps test pins the value coming from the live step event. Refs #320.
server/web/runs.go +9−2
| @@ -61,7 +61,9 @@ func (w *Web) RunLog(rw http.ResponseWriter, r *http.Request) { | |||
| 61 | 61 | } | |
| 62 | 62 | ||
| 63 | 63 | // ?after=N is the live tail: send the bytes after N and say whether the log is | |
| 64 | // final. A browser polls it while the run is going. | ||
| 64 | // final. A browser polls it while the run is going. N is an absolute offset in | ||
| 65 | // the attempt's log, including when ?step=N narrows the response to one step's | ||
| 66 | // range: the page starts its counter at that step's start, not at zero. | ||
| 65 | 67 | after := int64(-1) | |
| 66 | 68 | if v := r.URL.Query().Get("after"); v != "" { | |
| 67 | 69 | n, err := strconv.ParseInt(v, 10, 64) | |
| @@ -211,6 +213,10 @@ type runStepView struct { | |||
| 211 | 213 | Duration time.Duration | |
| 212 | 214 | Started time.Time | |
| 213 | 215 | LogURL string | |
| 216 | // LogOffset is where the step's output starts in the attempt's log. The live | ||
| 217 | // viewer starts its byte counter here, because ?after= is an absolute offset | ||
| 218 | // even when the response is narrowed to one step's range. | ||
| 219 | LogOffset int64 | ||
| 214 | 220 | } | |
| 215 | 221 | ||
| 216 | 222 | func runSteps(run *runs.Run, rec *runs.Record, live []runs.StepEvent, repo string) []runStepView { | |
| @@ -231,7 +237,7 @@ func runSteps(run *runs.Run, rec *runs.Record, live []runs.StepEvent, repo strin | |||
| 231 | 237 | v := runStepView{ | |
| 232 | 238 | Number: i + 1, Name: step.Name, Status: status, | |
| 233 | 239 | Label: label, Duration: step.Duration(), | |
| 234 | Started: step.Started, | ||
| 240 | Started: step.Started, LogOffset: step.LogOffset, | ||
| 235 | 241 | } | |
| 236 | 242 | if step.LogSize > 0 { | |
| 237 | 243 | v.LogURL = fmt.Sprintf("/%s/runs/%s/log?attempt=%d&step=%d", | |
| @@ -260,6 +266,7 @@ func runSteps(run *runs.Run, rec *runs.Record, live []runs.StepEvent, repo strin | |||
| 260 | 266 | v.Status = ev.Status | |
| 261 | 267 | v.Started = ev.Started | |
| 262 | 268 | v.Duration = ev.Duration() | |
| 269 | v.LogOffset = ev.LogOffset | ||
| 263 | 270 | switch ev.Status { | |
| 264 | 271 | case runs.StatusRunning: | |
| 265 | 272 | v.Label = "running" | |