mirror of
https://github.com/warmbly/warmbly.git
synced 2026-10-25 16:03:31 +00:00
feat: keep worker startup reload requests pending when the backend returns a null heartbeat reply
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin AI
parent
c687b6fd78
commit
46673a0cb8
@@ -189,12 +189,12 @@ func (a *Agent) beat(ctx context.Context, booted, stopping bool) *models.NodeHea
|
||||
return nil
|
||||
}
|
||||
|
||||
var reply models.NodeHeartbeatReply
|
||||
if err := json.NewDecoder(resp.Body).Decode(&reply); err != nil {
|
||||
var reply *models.NodeHeartbeatReply
|
||||
if err := json.NewDecoder(resp.Body).Decode(&reply); err != nil || reply == nil {
|
||||
return nil
|
||||
}
|
||||
a.applyTarget(reply.DesiredVersion)
|
||||
return &reply
|
||||
return reply
|
||||
}
|
||||
|
||||
// applyTarget records the version the control plane wants. Writing a file the
|
||||
|
||||
@@ -40,6 +40,8 @@ func TestRunRetriesBootUntilAcknowledged(t *testing.T) {
|
||||
status = http.StatusServiceUnavailable
|
||||
case 3:
|
||||
body = "incomplete reply"
|
||||
case 4:
|
||||
body = "null"
|
||||
}
|
||||
return &http.Response{StatusCode: status, Body: io.NopCloser(strings.NewReader(body)), Header: make(http.Header)}, nil
|
||||
})}
|
||||
@@ -48,10 +50,10 @@ func TestRunRetriesBootUntilAcknowledged(t *testing.T) {
|
||||
defer cancel()
|
||||
done := make(chan struct{})
|
||||
go func() { a.Run(ctx); close(done) }()
|
||||
for i := range 5 {
|
||||
for i := range 6 {
|
||||
if i > 0 {
|
||||
interval := DefaultInterval
|
||||
if i == 4 {
|
||||
if i == 5 {
|
||||
interval = 40 * time.Second
|
||||
}
|
||||
time.Sleep(interval)
|
||||
@@ -59,7 +61,7 @@ func TestRunRetriesBootUntilAcknowledged(t *testing.T) {
|
||||
synctest.Wait()
|
||||
select {
|
||||
case beat := <-received:
|
||||
if beat.Booted != (i < 4) || beat.Stopping {
|
||||
if beat.Booted != (i < 5) || beat.Stopping {
|
||||
t.Fatalf("heartbeat %d: Booted=%t Stopping=%t", i+1, beat.Booted, beat.Stopping)
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user