detached 3aadd9b

fix(domain): emit one mirror.failed event per incident, including the pause

commit
3aadd9b8e88cb83fb7c3fe9058ec232cc3444002
author
brice · · 2026-10-20 05:30 UTC
committer
brice · · 2026-10-20 10:02 UTC
parent
1069a88
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +5 -4
M internal/domain/mirror_state.go +4 -3
@@ -57,7 +57,7 @@ type MirrorOutcome struct {
5757 } // Err nil == success
5858 type MirrorTransition struct {
5959 Status MirrorStatus
60- FailedEvent bool // State moved into Failing or Paused from OK/Disabled, or Failing -> Paused
60+ FailedEvent bool // State moved into Failing or Paused from OK/Disabled: once per incident
6161 Recovered bool // State moved from Failing/Paused to OK
6262 }
6363
@@ -113,7 +113,8 @@ func MirrorBackoff(n int) time.Duration {
113113 }
114114
115115 // MirrorDisable/MirrorReset are the config-change transitions: reset lifts Paused/Failing to OK
116-// with counters cleared (config changed, or sync --force before the attempt); disable -> Disabled.
116+// with counters cleared (config changed); disable -> Disabled. sync --force does not reset: the
117+// attempt is judged against the previous status so a recovery still reports Recovered.
117118 func MirrorReset(p MirrorStatus, now time.Time) MirrorStatus {
118119 p.State = MirrorOK
119120 p.Class = MirrorClassNone
@@ -158,7 +159,7 @@ func ApplyMirrorOutcome(prev MirrorStatus, out MirrorOutcome, now time.Time) Mir
158159 p.NextRetryAt = now.Add(MirrorBackoff(p.ConsecutiveFailures))
159160 }
160161 p.Reason = MirrorReason(p)
161- return MirrorTransition{Status: p, FailedEvent: prev.State != MirrorFailing && prev.State != MirrorPaused || prev.State == MirrorFailing && p.State == MirrorPaused}
162+ return MirrorTransition{Status: p, FailedEvent: prev.State != MirrorFailing && prev.State != MirrorPaused}
162163 }
163164
164165 // MirrorReason is the human sentence of a status, e.g.
@@ -57,7 +57,7 @@ type MirrorOutcome struct {
57 } // Err nil == success57 } // Err nil == success
58 type MirrorTransition struct {58 type MirrorTransition struct {
59 Status MirrorStatus59 Status MirrorStatus
60- FailedEvent bool // State moved into Failing or Paused from OK/Disabled, or Failing -> Paused60+ FailedEvent bool // State moved into Failing or Paused from OK/Disabled: once per incident
61 Recovered bool // State moved from Failing/Paused to OK61 Recovered bool // State moved from Failing/Paused to OK
62 }62 }
63 63
@@ -113,7 +113,8 @@ func MirrorBackoff(n int) time.Duration {
113 }113 }
114 114
115 // MirrorDisable/MirrorReset are the config-change transitions: reset lifts Paused/Failing to OK115 // MirrorDisable/MirrorReset are the config-change transitions: reset lifts Paused/Failing to OK
116-// with counters cleared (config changed, or sync --force before the attempt); disable -> Disabled.116+// with counters cleared (config changed); disable -> Disabled. sync --force does not reset: the
117+// attempt is judged against the previous status so a recovery still reports Recovered.
117 func MirrorReset(p MirrorStatus, now time.Time) MirrorStatus {118 func MirrorReset(p MirrorStatus, now time.Time) MirrorStatus {
118 p.State = MirrorOK119 p.State = MirrorOK
119 p.Class = MirrorClassNone120 p.Class = MirrorClassNone
@@ -158,7 +159,7 @@ func ApplyMirrorOutcome(prev MirrorStatus, out MirrorOutcome, now time.Time) Mir
158 p.NextRetryAt = now.Add(MirrorBackoff(p.ConsecutiveFailures))159 p.NextRetryAt = now.Add(MirrorBackoff(p.ConsecutiveFailures))
159 }160 }
160 p.Reason = MirrorReason(p)161 p.Reason = MirrorReason(p)
161- return MirrorTransition{Status: p, FailedEvent: prev.State != MirrorFailing && prev.State != MirrorPaused || prev.State == MirrorFailing && p.State == MirrorPaused}162+ return MirrorTransition{Status: p, FailedEvent: prev.State != MirrorFailing && prev.State != MirrorPaused}
162 }163 }
163 164
164 // MirrorReason is the human sentence of a status, e.g.165 // MirrorReason is the human sentence of a status, e.g.
M internal/domain/mirror_test.go +1 -1
@@ -138,7 +138,7 @@ func TestMirrorTransitions(t *testing.T) {
138138 if fatal || n >= 5 {
139139 want = MirrorPaused
140140 }
141- if tr.Status.State != want || tr.Status.ConsecutiveFailures != n || tr.FailedEvent != (n == 1 || !fatal && n == 5) {
141+ if tr.Status.State != want || tr.Status.ConsecutiveFailures != n || tr.FailedEvent != (n == 1) {
142142 t.Fatalf("n=%d %+v", n, tr)
143143 }
144144 if want == MirrorFailing && !tr.Status.NextRetryAt.Equal(now.Add(MirrorBackoff(n))) {
@@ -138,7 +138,7 @@ func TestMirrorTransitions(t *testing.T) {
138 if fatal || n >= 5 {138 if fatal || n >= 5 {
139 want = MirrorPaused139 want = MirrorPaused
140 }140 }
141- if tr.Status.State != want || tr.Status.ConsecutiveFailures != n || tr.FailedEvent != (n == 1 || !fatal && n == 5) {141+ if tr.Status.State != want || tr.Status.ConsecutiveFailures != n || tr.FailedEvent != (n == 1) {
142 t.Fatalf("n=%d %+v", n, tr)142 t.Fatalf("n=%d %+v", n, tr)
143 }143 }
144 if want == MirrorFailing && !tr.Status.NextRetryAt.Equal(now.Add(MirrorBackoff(n))) {144 if want == MirrorFailing && !tr.Status.NextRetryAt.Equal(now.Add(MirrorBackoff(n))) {

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 42

↑↓ moveenter openesc close