Skip to content

Commit

Permalink
allocs: Set reconnect timestamp. Watch for unknown status.
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekStrickland committed Mar 30, 2022
1 parent cb12d5f commit 277c36e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions client/allocrunner/alloc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@ func (ar *allocRunner) Reconnect(update *structs.Allocation) (err error) {
ar.logger.Trace("reconnecting alloc", "alloc_id", update.ID, "alloc_modify_index", update.AllocModifyIndex)

event := structs.NewTaskEvent(structs.TaskClientReconnected)
event.Time = time.Now().UnixNano()
for _, tr := range ar.tasks {
tr.AppendEvent(event)
}
Expand All @@ -1266,6 +1267,12 @@ func (ar *allocRunner) Reconnect(update *structs.Allocation) (err error) {
// Build the client allocation
alloc := ar.clientAlloc(states)

// Don't destroy until after we've appended the reconnect event.
if update.DesiredStatus != structs.AllocDesiredStatusRun {
ar.Destroy()
return
}

// Update the client state store.
err = ar.stateUpdater.PutAllocation(alloc)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion client/allocwatcher/alloc_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (p *remotePrevAlloc) Wait(ctx context.Context) error {
p.logger.Debug("blocking alloc was GC'd")
return nil
}
if resp.Alloc.Terminated() {
if resp.Alloc.Terminated() || resp.Alloc.ClientStatus == structs.AllocClientStatusUnknown {
// Terminated!
p.nodeID = resp.Alloc.NodeID
return nil
Expand Down

0 comments on commit 277c36e

Please sign in to comment.