runservice executor: report running tasks
This commit is contained in:
parent
adf9c73518
commit
455623e58a
@ -656,14 +656,17 @@ func (e *Executor) sendExecutorStatus(ctx context.Context) error {
|
||||
labels = make(map[string]string)
|
||||
}
|
||||
|
||||
activeTasks := e.runningTasks.len()
|
||||
|
||||
// Add special labels (and override config provided ones)
|
||||
arch := runtime.GOARCH
|
||||
labels["arch"] = arch
|
||||
|
||||
executor := &types.Executor{
|
||||
ID: e.id,
|
||||
ListenURL: e.listenURL,
|
||||
Labels: labels,
|
||||
ID: e.id,
|
||||
ListenURL: e.listenURL,
|
||||
Labels: labels,
|
||||
ActiveTasks: activeTasks,
|
||||
}
|
||||
|
||||
log.Debugf("send executor status: %s", util.Dump(executor))
|
||||
@ -1153,6 +1156,12 @@ func (r *runningTasks) delete(rtID string) {
|
||||
delete(r.tasks, rtID)
|
||||
}
|
||||
|
||||
func (r *runningTasks) len() int {
|
||||
r.m.Lock()
|
||||
defer r.m.Unlock()
|
||||
return len(r.tasks)
|
||||
}
|
||||
|
||||
func (e *Executor) handleTasks(ctx context.Context, c <-chan *types.ExecutorTask) {
|
||||
for et := range c {
|
||||
go e.executeTask(ctx, et)
|
||||
|
@ -658,6 +658,8 @@ type Executor struct {
|
||||
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
|
||||
ActiveTasks int `json:"active_tasks,omitempty"`
|
||||
|
||||
// internal values not saved
|
||||
Revision int64 `json:"-"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user