diff --git a/scheduler/resource/host_manager.go b/scheduler/resource/host_manager.go index 6bd4771128e..561b5651cb7 100644 --- a/scheduler/resource/host_manager.go +++ b/scheduler/resource/host_manager.go @@ -158,6 +158,10 @@ func (h *hostManager) RunGC() error { if host.AnnounceInterval > 0 && elapsed > host.AnnounceInterval*2 { host.Log.Info("host elapsed exceeds twice the announce interval, causing the host to leave peers") host.LeavePeers() + // Directly reclaim the host, + // as host's ConcurrentUploadCount may not be 0 when the host exits abnormally. + host.Log.Info("host has been reclaimed") + h.Delete(host.ID) return true } diff --git a/scheduler/resource/host_manager_test.go b/scheduler/resource/host_manager_test.go index 4a245b9cbf3..bd7462538da 100644 --- a/scheduler/resource/host_manager_test.go +++ b/scheduler/resource/host_manager_test.go @@ -522,9 +522,8 @@ func TestHostManager_RunGC(t *testing.T) { return true }) - host, loaded := hostManager.Load(mockHost.ID) - assert.Equal(loaded, true) - assert.Equal(host.ID, mockHost.ID) + _, loaded := hostManager.Load(mockHost.ID) + assert.Equal(loaded, false) }, }, }