From c19811454b70623c0f0f92e07ffc6c4b33deb63d Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 1 May 2023 11:54:23 -0400 Subject: [PATCH] 20457: Don't keep ctr mounts in memory after computing node size. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- lib/dispatchcloud/container/queue.go | 5 +++++ lib/dispatchcloud/container/queue_test.go | 3 +++ lib/dispatchcloud/test/queue.go | 1 + 3 files changed, 9 insertions(+) diff --git a/lib/dispatchcloud/container/queue.go b/lib/dispatchcloud/container/queue.go index 938ef915f2..5f6fdefbd5 100644 --- a/lib/dispatchcloud/container/queue.go +++ b/lib/dispatchcloud/container/queue.go @@ -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 diff --git a/lib/dispatchcloud/container/queue_test.go b/lib/dispatchcloud/container/queue_test.go index 0075ee324e..ca10983534 100644 --- a/lib/dispatchcloud/container/queue_test.go +++ b/lib/dispatchcloud/container/queue_test.go @@ -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) diff --git a/lib/dispatchcloud/test/queue.go b/lib/dispatchcloud/test/queue.go index e347338bf0..2be8246bd6 100644 --- a/lib/dispatchcloud/test/queue.go +++ b/lib/dispatchcloud/test/queue.go @@ -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, -- 2.39.5