fix: 从后端恢复 Runner claim
This commit is contained in:
@@ -90,3 +90,21 @@ func (r *Registry) Remove(assignmentID string) {
|
||||
defer r.mu.Unlock()
|
||||
delete(r.claims, assignmentID)
|
||||
}
|
||||
|
||||
// RecoverClaimed restores authorization for an executor that already claimed
|
||||
// its task before the controller restarted.
|
||||
func (r *Registry) RecoverClaimed(assignment taskassignment.Assignment) error {
|
||||
ready, err := r.Offer(assignment)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.mu.Lock()
|
||||
entry := r.claims[assignment.ID]
|
||||
if !entry.claimed {
|
||||
entry.claimed = true
|
||||
close(entry.ready)
|
||||
}
|
||||
r.mu.Unlock()
|
||||
<-ready
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user