From ab794c55793096c9ef7330fb2203bf2808c419fa Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Sun, 25 Dec 2016 01:11:12 -0800 Subject: [PATCH] Add daemon option --default-shm-size This fix fixes issue raised in 29492 where it was not possible to specify a default `--default-shm-size` in daemon configuration for each `docker run``. The flag `--default-shm-size` which is reloadable, has been added to the daemon configuation. Related docs has been updated. This fix fixes 29492. Signed-off-by: Yong Tang --- command/service/opts.go | 25 ++----------------------- command/service/opts_test.go | 4 ++-- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/command/service/opts.go b/command/service/opts.go index b794b07a30..742c02eee8 100644 --- a/command/service/opts.go +++ b/command/service/opts.go @@ -11,7 +11,6 @@ import ( "github.com/docker/docker/opts" runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/docker/go-connections/nat" - units "github.com/docker/go-units" "github.com/spf13/cobra" ) @@ -19,26 +18,6 @@ type int64Value interface { Value() int64 } -type memBytes int64 - -func (m *memBytes) String() string { - return units.BytesSize(float64(m.Value())) -} - -func (m *memBytes) Set(value string) error { - val, err := units.RAMInBytes(value) - *m = memBytes(val) - return err -} - -func (m *memBytes) Type() string { - return "bytes" -} - -func (m *memBytes) Value() int64 { - return int64(*m) -} - // PositiveDurationOpt is an option type for time.Duration that uses a pointer. // It bahave similarly to DurationOpt but only allows positive duration values. type PositiveDurationOpt struct { @@ -149,9 +128,9 @@ type updateOptions struct { type resourceOptions struct { limitCPU opts.NanoCPUs - limitMemBytes memBytes + limitMemBytes opts.MemBytes resCPU opts.NanoCPUs - resMemBytes memBytes + resMemBytes opts.MemBytes } func (r *resourceOptions) ToResourceRequirements() *swarm.ResourceRequirements { diff --git a/command/service/opts_test.go b/command/service/opts_test.go index 78b956ad67..4031d6f251 100644 --- a/command/service/opts_test.go +++ b/command/service/opts_test.go @@ -11,12 +11,12 @@ import ( ) func TestMemBytesString(t *testing.T) { - var mem memBytes = 1048576 + var mem opts.MemBytes = 1048576 assert.Equal(t, mem.String(), "1 MiB") } func TestMemBytesSetAndValue(t *testing.T) { - var mem memBytes + var mem opts.MemBytes assert.NilError(t, mem.Set("5kb")) assert.Equal(t, mem.Value(), int64(5120)) }