[ARVADOS] updated: 1.3.0-641-g6f4e3ff91

Git user git at public.curoverse.com
Thu Apr 4 13:47:24 UTC 2019


Summary of changes:
 lib/dispatchcloud/container/queue.go      | 14 +++++++++-----
 lib/dispatchcloud/container/queue_test.go | 10 ++++++++++
 2 files changed, 19 insertions(+), 5 deletions(-)

       via  6f4e3ff911ab778c83240e9faf9c71fa6470f50c (commit)
      from  cae02ce88e24b9e760fbacbeea630c85946dcbe6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 6f4e3ff911ab778c83240e9faf9c71fa6470f50c
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Thu Apr 4 09:44:07 2019 -0400

    Fix stale cached container state after successful Cancel.
    
    Avoids needless retries between a successful Cancel and the next sync.
    
    No issue #
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/lib/dispatchcloud/container/queue.go b/lib/dispatchcloud/container/queue.go
index af17aaf39..50e73189e 100644
--- a/lib/dispatchcloud/container/queue.go
+++ b/lib/dispatchcloud/container/queue.go
@@ -314,15 +314,14 @@ func (cq *Queue) setRuntimeError(uuid, errorString string) error {
 
 // Cancel cancels the given container.
 func (cq *Queue) Cancel(uuid string) error {
-	err := cq.client.RequestAndDecode(nil, "PUT", "arvados/v1/containers/"+uuid, nil, map[string]map[string]interface{}{
+	var resp arvados.Container
+	err := cq.client.RequestAndDecode(&resp, "PUT", "arvados/v1/containers/"+uuid, nil, map[string]map[string]interface{}{
 		"container": {"state": arvados.ContainerStateCancelled},
 	})
 	if err != nil {
 		return err
 	}
-	cq.mtx.Lock()
-	defer cq.mtx.Unlock()
-	cq.notify()
+	cq.updateWithResp(uuid, resp)
 	return nil
 }
 
@@ -332,7 +331,13 @@ func (cq *Queue) apiUpdate(uuid, action string) error {
 	if err != nil {
 		return err
 	}
+	cq.updateWithResp(uuid, resp)
+	return nil
+}
 
+// Update the local queue with the response received from a
+// state-changing API request (lock/unlock/cancel).
+func (cq *Queue) updateWithResp(uuid string, resp arvados.Container) {
 	cq.mtx.Lock()
 	defer cq.mtx.Unlock()
 	if cq.dontupdate != nil {
@@ -345,7 +350,6 @@ func (cq *Queue) apiUpdate(uuid, action string) error {
 		cq.current[uuid] = ent
 	}
 	cq.notify()
-	return nil
 }
 
 func (cq *Queue) poll() (map[string]*arvados.Container, error) {
diff --git a/lib/dispatchcloud/container/queue_test.go b/lib/dispatchcloud/container/queue_test.go
index 91d65359e..3c63fe51e 100644
--- a/lib/dispatchcloud/container/queue_test.go
+++ b/lib/dispatchcloud/container/queue_test.go
@@ -74,6 +74,7 @@ func (suite *IntegrationSuite) TestGetLockUnlockCancel(c *check.C) {
 			defer wg.Done()
 			err := cq.Unlock(uuid)
 			c.Check(err, check.NotNil)
+
 			err = cq.Lock(uuid)
 			c.Check(err, check.IsNil)
 			ctr, ok := cq.Get(uuid)
@@ -81,6 +82,7 @@ func (suite *IntegrationSuite) TestGetLockUnlockCancel(c *check.C) {
 			c.Check(ctr.State, check.Equals, arvados.ContainerStateLocked)
 			err = cq.Lock(uuid)
 			c.Check(err, check.NotNil)
+
 			err = cq.Unlock(uuid)
 			c.Check(err, check.IsNil)
 			ctr, ok = cq.Get(uuid)
@@ -88,6 +90,14 @@ func (suite *IntegrationSuite) TestGetLockUnlockCancel(c *check.C) {
 			c.Check(ctr.State, check.Equals, arvados.ContainerStateQueued)
 			err = cq.Unlock(uuid)
 			c.Check(err, check.NotNil)
+
+			err = cq.Cancel(uuid)
+			c.Check(err, check.IsNil)
+			ctr, ok = cq.Get(uuid)
+			c.Check(ok, check.Equals, true)
+			c.Check(ctr.State, check.Equals, arvados.ContainerStateCancelled)
+			err = cq.Lock(uuid)
+			c.Check(err, check.NotNil)
 		}()
 	}
 	wg.Wait()

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list