summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2020-12-17 10:43:55 -0800
committergVisor bot <gvisor-bot@google.com>2020-12-17 10:46:47 -0800
commite7493a9e23325c00ad9a0db341d5887afe3ae5eb (patch)
tree3a690e63993aaafd6307778ba78c27a3e6e7ead5
parent74788b1b6194ef62f8355f7e4721c00f615d16ad (diff)
Set max memory not min
Closes #5048 PiperOrigin-RevId: 348050472
-rw-r--r--runsc/boot/loader.go2
-rw-r--r--test/e2e/integration_test.go8
2 files changed, 4 insertions, 6 deletions
diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go
index 3df013d34..98ea8db64 100644
--- a/runsc/boot/loader.go
+++ b/runsc/boot/loader.go
@@ -294,7 +294,7 @@ func New(args Args) (*Loader, error) {
if args.TotalMem > 0 {
// Adjust the total memory returned by the Sentry so that applications that
// use /proc/meminfo can make allocations based on this limit.
- usage.MinimumTotalMemoryBytes = args.TotalMem
+ usage.MaximumTotalMemoryBytes = args.TotalMem
log.Infof("Setting total memory to %.2f GB", float64(args.TotalMem)/(1<<30))
}
diff --git a/test/e2e/integration_test.go b/test/e2e/integration_test.go
index 03bdfa889..d07ed6ba5 100644
--- a/test/e2e/integration_test.go
+++ b/test/e2e/integration_test.go
@@ -260,12 +260,10 @@ func TestMemLimit(t *testing.T) {
d := dockerutil.MakeContainer(ctx, t)
defer d.CleanUp(ctx)
- // N.B. Because the size of the memory file may grow in large chunks,
- // there is a minimum threshold of 1GB for the MemTotal figure.
- allocMemory := 1024 * 1024 // In kb.
+ allocMemoryKb := 50 * 1024
out, err := d.Run(ctx, dockerutil.RunOpts{
Image: "basic/alpine",
- Memory: allocMemory * 1024, // In bytes.
+ Memory: allocMemoryKb * 1024, // In bytes.
}, "sh", "-c", "cat /proc/meminfo | grep MemTotal: | awk '{print $2}'")
if err != nil {
t.Fatalf("docker run failed: %v", err)
@@ -285,7 +283,7 @@ func TestMemLimit(t *testing.T) {
if err != nil {
t.Fatalf("failed to parse %q: %v", out, err)
}
- if want := uint64(allocMemory); got != want {
+ if want := uint64(allocMemoryKb); got != want {
t.Errorf("MemTotal got: %d, want: %d", got, want)
}
}