Skip to content

Commit f5ce8a9

Browse files
committed
client: skip terminal allocations on reconnect
When the client reconnects with the server it synchronizes the state of its allocations by sending data using the `Node.UpdateAlloc` RPC and fetching data using the `Node.GetClientAllocs` RPC. If the data fetch happens before the data write, `unknown` allocations will still be in this state and would trigger the `allocRunner.Reconnect` flow. But when the server `DesiredStatus` for the allocation is `stop` the client should not reconnect the allocation.
1 parent aa324ad commit f5ce8a9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

client/client.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -2480,8 +2480,11 @@ func (c *Client) updateAlloc(update *structs.Allocation) {
24802480
return
24812481
}
24822482

2483-
// Reconnect unknown allocations
2484-
if update.ClientStatus == structs.AllocClientStatusUnknown && update.AllocModifyIndex > ar.Alloc().AllocModifyIndex {
2483+
// Reconnect unknown allocations if they were updated and are not terminal.
2484+
reconnect := update.ClientStatus == structs.AllocClientStatusUnknown &&
2485+
update.AllocModifyIndex > ar.Alloc().AllocModifyIndex &&
2486+
!update.ServerTerminalStatus()
2487+
if reconnect {
24852488
err = ar.Reconnect(update)
24862489
if err != nil {
24872490
c.logger.Error("error reconnecting alloc", "alloc_id", update.ID, "alloc_modify_index", update.AllocModifyIndex, "error", err)

0 commit comments

Comments
 (0)