Merge pull request #857 from hqhq/improve_update_memory
Improve update memory
This commit is contained in:
commit
e7b8d1903a
|
@ -103,6 +103,11 @@ function check_cgroup_value() {
|
|||
[ "$status" -eq 0 ]
|
||||
check_cgroup_value $CGROUP_MEMORY "memory.limit_in_bytes" 67108864
|
||||
|
||||
runc update test_update --memory 50M
|
||||
[ "$status" -eq 0 ]
|
||||
check_cgroup_value $CGROUP_MEMORY "memory.limit_in_bytes" 52428800
|
||||
|
||||
|
||||
# update memory soft limit
|
||||
runc update test_update --memory-reservation 33554432
|
||||
[ "$status" -eq 0 ]
|
||||
|
|
22
update.go
22
update.go
|
@ -9,6 +9,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/docker/go-units"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
|
||||
|
@ -158,11 +159,6 @@ other options are ignored.
|
|||
"cpu-period": r.CPU.Period,
|
||||
"cpu-quota": r.CPU.Quota,
|
||||
"cpu-share": r.CPU.Shares,
|
||||
"kernel-memory": r.Memory.Kernel,
|
||||
"kernel-memory-tcp": r.Memory.KernelTCP,
|
||||
"memory": r.Memory.Limit,
|
||||
"memory-reservation": r.Memory.Reservation,
|
||||
"memory-swap": r.Memory.Swap,
|
||||
} {
|
||||
if val := context.String(opt); val != "" {
|
||||
var err error
|
||||
|
@ -172,6 +168,22 @@ other options are ignored.
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for opt, dest := range map[string]*uint64{
|
||||
"kernel-memory": r.Memory.Kernel,
|
||||
"kernel-memory-tcp": r.Memory.KernelTCP,
|
||||
"memory": r.Memory.Limit,
|
||||
"memory-reservation": r.Memory.Reservation,
|
||||
"memory-swap": r.Memory.Swap,
|
||||
} {
|
||||
if val := context.String(opt); val != "" {
|
||||
v, err := units.RAMInBytes(val)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid value for %s: %s", opt, err)
|
||||
}
|
||||
*dest = uint64(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the value
|
||||
|
|
Loading…
Reference in New Issue