14360: Fail Create calls fast during quota quarantine.
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 30 Oct 2018 20:12:11 +0000 (16:12 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Tue, 30 Oct 2018 20:12:11 +0000 (16:12 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

lib/dispatchcloud/worker/pool.go

index 68174e6b7156759c2b1cedb1dc0b319692b4681b..b1b570bd900f3a661816a217910d35fde3bc563b 100644 (file)
@@ -124,6 +124,7 @@ type Pool struct {
        loaded       bool                 // loaded list of instances from InstanceSet at least once
        exited       map[string]time.Time // containers whose crunch-run proc has exited, but KillContainer has not been called
        atQuotaUntil time.Time
+       atQuotaErr   cloud.QuotaError
        stop         chan bool
        mtx          sync.RWMutex
        setupOnce    sync.Once
@@ -208,6 +209,9 @@ func (wp *Pool) Create(it arvados.InstanceType) error {
        wp.setupOnce.Do(wp.setup)
        wp.mtx.Lock()
        defer wp.mtx.Unlock()
+       if time.Now().Before(wp.atQuotaUntil) {
+               return wp.atQuotaErr
+       }
        tags := cloud.InstanceTags{tagKeyInstanceType: it.Name}
        wp.creating[it]++
        go func() {
@@ -217,6 +221,7 @@ func (wp *Pool) Create(it arvados.InstanceType) error {
                defer wp.mtx.Unlock()
                wp.creating[it]--
                if err, ok := err.(cloud.QuotaError); ok && err.IsQuotaError() {
+                       wp.atQuotaErr = err
                        wp.atQuotaUntil = time.Now().Add(time.Minute)
                }
                if err != nil {