detached 43e0ba0

fix(broker): back off absent-daemon observations under demand

commit
43e0ba000ac660f9785fd07bebf8dae1d8944d0a
author
brice · · 2026-09-23 09:29 UTC
parent
d031a8e
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +37 -1
M internal/usecase/broker/registry.go +3 -1
@@ -1110,7 +1110,9 @@ func (r *Registry) apply(result probeResult) {
11101110 if !failed && availability == domain.RemoteAvailabilityNoDaemon {
11111111 current.Availability = availability
11121112 current.LastSuccess = result.at
1113- current.NextDue = result.at.Add(r.jitter(r.freshForLocked(false), result.endpoint, result.attempt))
1113+ // An absent daemon is stable: demand does not require a fresh SSH
1114+ // handshake every two seconds just to confirm it is still absent.
1115+ current.NextDue = result.at.Add(r.jitter(r.freshFor, result.endpoint, result.attempt))
11141116 current.ConsecutiveFailures = 0
11151117 current.LastFailure = domain.RemoteFailure{}
11161118 current.Identity = ""
@@ -1110,7 +1110,9 @@ func (r *Registry) apply(result probeResult) {
1110 if !failed && availability == domain.RemoteAvailabilityNoDaemon {1110 if !failed && availability == domain.RemoteAvailabilityNoDaemon {
1111 current.Availability = availability1111 current.Availability = availability
1112 current.LastSuccess = result.at1112 current.LastSuccess = result.at
1113- current.NextDue = result.at.Add(r.jitter(r.freshForLocked(false), result.endpoint, result.attempt))1113+ // An absent daemon is stable: demand does not require a fresh SSH
1114+ // handshake every two seconds just to confirm it is still absent.
1115+ current.NextDue = result.at.Add(r.jitter(r.freshFor, result.endpoint, result.attempt))
1114 current.ConsecutiveFailures = 01116 current.ConsecutiveFailures = 0
1115 current.LastFailure = domain.RemoteFailure{}1117 current.LastFailure = domain.RemoteFailure{}
1116 current.Identity = ""1118 current.Identity = ""
A internal/usecase/broker/registry_no_daemon_backoff_test.go +34 -0
@@ -0,0 +1,34 @@
1+package broker
2+
3+import (
4+ "testing"
5+ "time"
6+
7+ "github.com/stretchr/testify/require"
8+
9+ "github.com/bnema/vev/internal/domain"
10+ "github.com/bnema/vev/internal/ports"
11+)
12+
13+func TestRegistryNoDaemonUsesPassiveCadenceEvenWithDemand(t *testing.T) {
14+ start := time.Unix(100, 0)
15+ clock := newManualClock(start)
16+ probe := newTestProbe(2)
17+ registry := newTestRegistry(t, 1, newTestStore(), probe, clock)
18+ registry.jitter = identityJitter
19+ reg := registration(t, "example.test", 1)
20+ require.NoError(t, registry.setHosts(hostRecords(reg)))
21+ registry.SetDemand(true)
22+ startRegistry(t, registry)
23+
24+ call := receiveCall(t, probe)
25+ call.result <- probeAnswer{snapshot: ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityNoDaemon}}
26+ host := waitHost(t, registry, reg.Endpoint, func(host ports.BrokerDaemonObservation) bool {
27+ return !host.Checking && host.Availability == domain.RemoteAvailabilityNoDaemon
28+ })
29+ require.Equal(t, start.Add(defaultFreshFor), host.NextDue)
30+ clock.Advance(defaultDemandFreshForRemote)
31+ requireNoProbeWithin(t, probe, probeGrace)
32+ clock.Advance(defaultFreshFor - defaultDemandFreshForRemote)
33+ receiveCall(t, probe)
34+}
@@ -0,0 +1,34 @@
1+package broker
2+
3+import (
4+ "testing"
5+ "time"
6+
7+ "github.com/stretchr/testify/require"
8+
9+ "github.com/bnema/vev/internal/domain"
10+ "github.com/bnema/vev/internal/ports"
11+)
12+
13+func TestRegistryNoDaemonUsesPassiveCadenceEvenWithDemand(t *testing.T) {
14+ start := time.Unix(100, 0)
15+ clock := newManualClock(start)
16+ probe := newTestProbe(2)
17+ registry := newTestRegistry(t, 1, newTestStore(), probe, clock)
18+ registry.jitter = identityJitter
19+ reg := registration(t, "example.test", 1)
20+ require.NoError(t, registry.setHosts(hostRecords(reg)))
21+ registry.SetDemand(true)
22+ startRegistry(t, registry)
23+
24+ call := receiveCall(t, probe)
25+ call.result <- probeAnswer{snapshot: ports.BrokerDaemonObservation{Availability: domain.RemoteAvailabilityNoDaemon}}
26+ host := waitHost(t, registry, reg.Endpoint, func(host ports.BrokerDaemonObservation) bool {
27+ return !host.Checking && host.Availability == domain.RemoteAvailabilityNoDaemon
28+ })
29+ require.Equal(t, start.Add(defaultFreshFor), host.NextDue)
30+ clock.Advance(defaultDemandFreshForRemote)
31+ requireNoProbeWithin(t, probe, probeGrace)
32+ clock.Advance(defaultFreshFor - defaultDemandFreshForRemote)
33+ receiveCall(t, probe)
34+}

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 12

Tags 11

↑↓ moveenter openesc close