15942: Fix attempt to run container after deciding it cannot run.
authorTom Clegg <tom@tomclegg.ca>
Thu, 19 Dec 2019 04:41:21 +0000 (23:41 -0500)
committerTom Clegg <tom@tomclegg.ca>
Thu, 19 Dec 2019 04:41:21 +0000 (23:41 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/dispatchcloud/container/queue.go
lib/dispatchcloud/container/queue_test.go

index f684105c1231c14cd284d2a57f4e5f919b562aae..21b41ec4d86d6cdc6c909b63106511dfe548f3c4 100644 (file)
@@ -343,12 +343,19 @@ func (cq *Queue) updateWithResp(uuid string, resp arvados.Container) {
        if cq.dontupdate != nil {
                cq.dontupdate[uuid] = struct{}{}
        }
-       if ent, ok := cq.current[uuid]; !ok {
-               cq.addEnt(uuid, resp)
-       } else {
-               ent.Container.State, ent.Container.Priority, ent.Container.LockedByUUID = resp.State, resp.Priority, resp.LockedByUUID
-               cq.current[uuid] = ent
+       ent, ok := cq.current[uuid]
+       if !ok {
+               // Container is not in queue (e.g., it was not added
+               // because there is no suitable instance type, and
+               // we're just locking/updating it in order to set an
+               // error message). No need to add it, and we don't
+               // necessarily have enough information to add it here
+               // anyway because lock/unlock responses don't include
+               // runtime_constraints.
+               return
        }
+       ent.Container.State, ent.Container.Priority, ent.Container.LockedByUUID = resp.State, resp.Priority, resp.LockedByUUID
+       cq.current[uuid] = ent
        cq.notify()
 }
 
index b6e8678210c7cb3324529286af2f2f3e3ee0ab27..085e98a5f9de592889d1d389cef667818b97af6a 100644 (file)
@@ -117,11 +117,10 @@ func (suite *IntegrationSuite) TestCancelIfNoInstanceType(c *check.C) {
        c.Check(err, check.IsNil)
        c.Check(ctr.State, check.Equals, arvados.ContainerStateQueued)
 
-       cq.Update()
-
        // Wait for the cancel operation to take effect. Container
        // will have state=Cancelled or just disappear from the queue.
        suite.waitfor(c, time.Second, func() bool {
+               cq.Update()
                err := client.RequestAndDecode(&ctr, "GET", "arvados/v1/containers/"+arvadostest.QueuedContainerUUID, nil, nil)
                return err == nil && ctr.State == arvados.ContainerStateCancelled
        })