mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
add queue.full and timeout count
This commit is contained in:
@@ -42,7 +42,7 @@ var (
|
|||||||
ErrTimeOutNoMemory = errors.New("Task timed out. No available memory.")
|
ErrTimeOutNoMemory = errors.New("Task timed out. No available memory.")
|
||||||
ErrFullQueue = errors.New("The runner queue is full")
|
ErrFullQueue = errors.New("The runner queue is full")
|
||||||
|
|
||||||
WaitMemoryTimeout = 3 * time.Second
|
WaitMemoryTimeout = 10 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
func New() (*Runner, error) {
|
func New() (*Runner, error) {
|
||||||
@@ -58,7 +58,7 @@ func New() (*Runner, error) {
|
|||||||
|
|
||||||
r := &Runner{
|
r := &Runner{
|
||||||
driver: driver,
|
driver: driver,
|
||||||
taskQueue: make(chan *containerTask, 0),
|
taskQueue: make(chan *containerTask, 100),
|
||||||
}
|
}
|
||||||
|
|
||||||
go r.queueHandler()
|
go r.queueHandler()
|
||||||
@@ -97,6 +97,7 @@ func (r *Runner) queueHandler() {
|
|||||||
|
|
||||||
if timedOut {
|
if timedOut {
|
||||||
// Send to a signal to this task saying it cannot run
|
// Send to a signal to this task saying it cannot run
|
||||||
|
LogMetricCount(task.ctx, (metricBaseName + "timeout"), 1)
|
||||||
task.canRun <- false
|
task.canRun <- false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -132,6 +133,7 @@ func (r *Runner) Run(ctx context.Context, cfg *Config) (drivers.RunResult, error
|
|||||||
case r.taskQueue <- ctask:
|
case r.taskQueue <- ctask:
|
||||||
default:
|
default:
|
||||||
// If queue is full, return error
|
// If queue is full, return error
|
||||||
|
LogMetricCount(ctx, "queue.full", 1)
|
||||||
return nil, ErrFullQueue
|
return nil, ErrFullQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +231,7 @@ func checkProc() (uint64, error) {
|
|||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(f)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
b := scanner.Text()
|
b := scanner.Text()
|
||||||
if !strings.HasPrefix(b, "MemFree") {
|
if !strings.HasPrefix(b, "MemAvailable") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user