20457: Don't keep ctr mounts in memory after computing node size.
authorTom Clegg <tom@curii.com>
Mon, 1 May 2023 15:54:23 +0000 (11:54 -0400)
committerTom Clegg <tom@curii.com>
Mon, 1 May 2023 15:54:23 +0000 (11:54 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

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

index 938ef915f251e4d27e1ea4f714b82f10425d4224..5f6fdefbd51052289407930bbd0aa14b0ae6039e 100644 (file)
@@ -233,6 +233,11 @@ func (cq *Queue) delEnt(uuid string, state arvados.ContainerState) {
 // Caller must have lock.
 func (cq *Queue) addEnt(uuid string, ctr arvados.Container) {
        it, err := cq.chooseType(&ctr)
+
+       // Avoid wasting memory on a large Mounts attr (we don't need
+       // it after choosing type).
+       ctr.Mounts = nil
+
        if err != nil && (ctr.State == arvados.ContainerStateQueued || ctr.State == arvados.ContainerStateLocked) {
                // We assume here that any chooseType error is a hard
                // error: it wouldn't help to try again, or to leave
index 0075ee324ef8eb1d10a54207af97ddbf6a70b6bf..ca10983534a3579e79e8a02a6601126af9d32ae0 100644 (file)
@@ -41,6 +41,7 @@ func (suite *IntegrationSuite) TearDownTest(c *check.C) {
 
 func (suite *IntegrationSuite) TestGetLockUnlockCancel(c *check.C) {
        typeChooser := func(ctr *arvados.Container) (arvados.InstanceType, error) {
+               c.Check(ctr.Mounts["/tmp"].Capacity, check.Equals, int64(24000000000))
                return arvados.InstanceType{Name: "testType"}, nil
        }
 
@@ -64,6 +65,8 @@ func (suite *IntegrationSuite) TestGetLockUnlockCancel(c *check.C) {
                c.Check(ent.InstanceType.Name, check.Equals, "testType")
                c.Check(ent.Container.State, check.Equals, arvados.ContainerStateQueued)
                c.Check(ent.Container.Priority > 0, check.Equals, true)
+               // Mounts should be deleted to avoid wasting memory
+               c.Check(ent.Container.Mounts, check.IsNil)
 
                ctr, ok := cq.Get(uuid)
                c.Check(ok, check.Equals, true)
index e347338bf07f0ab74917e42815c0c524b3dc24a7..2be8246bd619640ee7cd6ffd43bfacf42236370c 100644 (file)
@@ -168,6 +168,7 @@ func (q *Queue) Update() error {
                        upd[ctr.UUID] = ent
                } else {
                        it, _ := q.ChooseType(&ctr)
+                       ctr.Mounts = nil
                        upd[ctr.UUID] = container.QueueEnt{
                                Container:    ctr,
                                InstanceType: it,