forked from TrueCloudLab/frostfs-node
[#1043] control: Add ResetEvacuationStatus implementation
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
926cdeb072
commit
31e2396a5f
8 changed files with 1254 additions and 705 deletions
|
@ -733,3 +733,13 @@ func (e *StorageEngine) EnqueRunningEvacuationStop(ctx context.Context) error {
|
|||
|
||||
return e.evacuateLimiter.CancelIfRunning()
|
||||
}
|
||||
|
||||
func (e *StorageEngine) ResetEvacuationStatus(ctx context.Context) error {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
return e.evacuateLimiter.ResetEvacuationStatus()
|
||||
}
|
||||
|
|
|
@ -204,3 +204,18 @@ func (l *evacuationLimiter) CancelIfRunning() error {
|
|||
l.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *evacuationLimiter) ResetEvacuationStatus() error {
|
||||
l.guard.Lock()
|
||||
defer l.guard.Unlock()
|
||||
|
||||
if l.state.processState == EvacuateProcessStateRunning {
|
||||
return logicerr.New("there is running evacuation task")
|
||||
}
|
||||
|
||||
l.state = EvacuationState{}
|
||||
l.eg = nil
|
||||
l.cancel = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -386,6 +386,8 @@ func TestEvacuateObjectsAsync(t *testing.T) {
|
|||
require.ElementsMatch(t, expectedShardIDs, st.ShardIDs(), "invalid running shard ids")
|
||||
require.Equal(t, "", st.ErrorMessage(), "invalid init error message")
|
||||
|
||||
require.Error(t, e.ResetEvacuationStatus(context.Background()))
|
||||
|
||||
close(blocker)
|
||||
|
||||
require.Eventually(t, func() bool {
|
||||
|
@ -401,6 +403,16 @@ func TestEvacuateObjectsAsync(t *testing.T) {
|
|||
require.Equal(t, "", st.ErrorMessage(), "invalid final error message")
|
||||
|
||||
require.NoError(t, eg.Wait())
|
||||
|
||||
require.NoError(t, e.ResetEvacuationStatus(context.Background()))
|
||||
st, err = e.GetEvacuationState(context.Background())
|
||||
require.NoError(t, err, "get state after reset failed")
|
||||
require.Equal(t, EvacuateProcessStateUndefined, st.ProcessingStatus(), "invalid state after reset")
|
||||
require.Equal(t, uint64(0), st.ObjectsEvacuated(), "invalid count after reset")
|
||||
require.Nil(t, st.StartedAt(), "invalid started at after reset")
|
||||
require.Nil(t, st.FinishedAt(), "invalid finished at after reset")
|
||||
require.ElementsMatch(t, []string{}, st.ShardIDs(), "invalid shard ids after reset")
|
||||
require.Equal(t, "", st.ErrorMessage(), "invalid error message after reset")
|
||||
}
|
||||
|
||||
func TestEvacuateTreesLocal(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue