Skip to content

Commit

Permalink
feat(hatchery): MaxConcurrentRegistering (#4244)
Browse files Browse the repository at this point in the history
* feat(hatchery): key MaxConcurrentRegistering

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
  • Loading branch information
yesnault committed May 2, 2019
1 parent e51a063 commit 3668678
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sdk/hatchery/register.go
Expand Up @@ -3,7 +3,6 @@ package hatchery
import (
"context"
"fmt"
"math"
"strings"
"sync/atomic"

Expand Down Expand Up @@ -40,7 +39,10 @@ func workerRegister(ctx context.Context, h Interface, startWorkerChan chan<- wor
continue
}

maxRegistration := int64(math.Floor(float64(h.Configuration().Provision.MaxWorker) / 4))
maxRegistration := int64(h.Configuration().Provision.MaxConcurrentRegistering)
if maxRegistration == 0 {
maxRegistration = 2
}
if atomic.LoadInt64(&nbRegisteringWorkerModels) > maxRegistration {
log.Debug("hatchery> workerRegister> max registering worker reached")
return nil
Expand Down
1 change: 1 addition & 0 deletions sdk/hatchery/types.go
Expand Up @@ -35,6 +35,7 @@ type CommonConfiguration struct {
Frequency int `toml:"frequency" default:"30" comment:"Check provisioning each n Seconds" json:"frequency"`
MaxWorker int `toml:"maxWorker" default:"10" comment:"Maximum allowed simultaneous workers" json:"maxWorker"`
MaxConcurrentProvisioning int `toml:"maxConcurrentProvisioning" default:"10" comment:"Maximum allowed simultaneous workers provisioning" json:"maxConcurrentProvisioning"`
MaxConcurrentRegistering int `toml:"maxConcurrentRegistering" default:"2" comment:"Maximum allowed simultaneous workers registering. -1 to disable registering on this hatchery" json:"maxConcurrentRegistering"`
GraceTimeQueued int `toml:"graceTimeQueued" default:"4" comment:"if worker is queued less than this value (seconds), hatchery does not take care of it" json:"graceTimeQueued"`
RegisterFrequency int `toml:"registerFrequency" default:"60" comment:"Check if some worker model have to be registered each n Seconds" json:"registerFrequency"`
WorkerLogsOptions struct {
Expand Down

0 comments on commit 3668678

Please sign in to comment.