Fix #99549: Remember Previous Status #104217
@ -163,6 +163,11 @@ func (f *Flamenco) SignOff(e echo.Context) error {
|
|||||||
w.StatusChangeClear()
|
w.StatusChangeClear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remember the previous status if an initial status exists
|
||||||
|
if w.StatusRequested == "" {
|
||||||
|
w.StatusChangeRequest(prevStatus, false)
|
||||||
|
}
|
||||||
|
|
||||||
// Pass a generic background context, as these changes should be stored even
|
// Pass a generic background context, as these changes should be stored even
|
||||||
// when the HTTP connection is aborted.
|
// when the HTTP connection is aborted.
|
||||||
bgCtx, bgCtxCancel := bgContext()
|
bgCtx, bgCtxCancel := bgContext()
|
||||||
|
@ -297,25 +297,28 @@ func TestWorkerRememberPreviousStatus(t *testing.T) {
|
|||||||
|
|
||||||
worker := testWorker()
|
worker := testWorker()
|
||||||
worker.Status = api.WorkerStatusTesting
|
worker.Status = api.WorkerStatusTesting
|
||||||
initialStatusRequested := worker.StatusRequested
|
|
||||||
initialLazyStatusRequest := worker.LazyStatusRequest
|
|
||||||
worker.StatusChangeRequest(api.WorkerStatusOffline, true)
|
worker.StatusChangeRequest(api.WorkerStatusOffline, true)
|
||||||
|
|
||||||
mf.broadcaster.EXPECT().BroadcastWorkerUpdate(api.SocketIOWorkerUpdate{
|
mf.broadcaster.EXPECT().BroadcastWorkerUpdate(api.SocketIOWorkerUpdate{
|
||||||
Id: worker.UUID,
|
Id: worker.UUID,
|
||||||
Name: worker.Name,
|
Name: worker.Name,
|
||||||
PreviousStatus: ptr(api.WorkerStatusTesting),
|
PreviousStatus: ptr(api.WorkerStatusAwake),
|
||||||
Status: api.WorkerStatusOffline,
|
Status: api.WorkerStatusOffline,
|
||||||
|
StatusChange: &api.WorkerStatusChangeRequest{
|
||||||
|
IsLazy: false,
|
||||||
|
Status: api.WorkerStatusAwake,
|
||||||
|
},
|
||||||
Updated: worker.UpdatedAt,
|
Updated: worker.UpdatedAt,
|
||||||
Version: worker.Software,
|
Version: worker.Software,
|
||||||
})
|
})
|
||||||
|
|
||||||
savedWorker := worker
|
savedWorker := worker
|
||||||
savedWorker.Status = api.WorkerStatusOffline
|
savedWorker.Status = api.WorkerStatusOffline
|
||||||
savedWorker.StatusChangeClear()
|
savedWorker.StatusRequested = api.WorkerStatusAwake
|
||||||
|
savedWorker.LazyStatusRequest = false
|
||||||
mf.persistence.EXPECT().SaveWorkerStatus(gomock.Any(), &savedWorker).Return(nil)
|
mf.persistence.EXPECT().SaveWorkerStatus(gomock.Any(), &savedWorker).Return(nil)
|
||||||
mf.stateMachine.EXPECT().RequeueActiveTasksOfWorker(gomock.Any(), &worker, "worker signed off").Return(nil)
|
mf.stateMachine.EXPECT().RequeueActiveTasksOfWorker(gomock.Any(), gomock.Eq(&worker), "worker signed off").Return(nil)
|
||||||
mf.persistence.EXPECT().WorkerSeen(gomock.Any(), &worker)
|
mf.persistence.EXPECT().WorkerSeen(gomock.Any(), gomock.Eq(&worker))
|
||||||
|
|
||||||
worker.Status = api.WorkerStatusAwake
|
worker.Status = api.WorkerStatusAwake
|
||||||
|
|
||||||
@ -325,8 +328,8 @@ func TestWorkerRememberPreviousStatus(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assertResponseNoContent(t, echo)
|
assertResponseNoContent(t, echo)
|
||||||
|
|
||||||
assert.Equal(t, initialStatusRequested, worker.StatusRequested)
|
assert.Equal(t, api.WorkerStatusAwake, worker.StatusRequested)
|
||||||
assert.Equal(t, initialLazyStatusRequest, worker.LazyStatusRequest)
|
assert.Equal(t, false, worker.LazyStatusRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWorkerState(t *testing.T) {
|
func TestWorkerState(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user