@@ -10,7 +10,6 @@ import (
1010 "strings"
1111 "time"
1212
13- "github.com/docker/docker/api/types"
1413 "github.com/docker/docker/api/types/container"
1514 "github.com/docker/docker/api/types/filters"
1615 "github.com/docker/docker/api/types/network"
@@ -224,7 +223,7 @@ func (rs *ReplicaSetService) ExecuteContainer(name string, exec *models.Containe
224223 }
225224
226225 ctx := context .Background ()
227- execCreate , err := docker .Cli .ContainerExecCreate (ctx , fmt .Sprintf ("%s-%d" , name , version ), types. ExecConfig {
226+ execCreate , err := docker .Cli .ContainerExecCreate (ctx , fmt .Sprintf ("%s-%d" , name , version ), container. ExecOptions {
228227 AttachStderr : true ,
229228 AttachStdout : true ,
230229 Detach : true ,
@@ -236,7 +235,7 @@ func (rs *ReplicaSetService) ExecuteContainer(name string, exec *models.Containe
236235 return resp , errors .Wrapf (err , "docker.ContainerExecCreate failed, name: %s, spec: %+v" , name , exec )
237236 }
238237
239- hijackedResp , err := docker .Cli .ContainerExecAttach (ctx , execCreate .ID , types. ExecStartCheck {})
238+ hijackedResp , err := docker .Cli .ContainerExecAttach (ctx , execCreate .ID , container. ExecAttachOptions {})
240239 defer hijackedResp .Close ()
241240 if err != nil {
242241 return resp , errors .Wrapf (err , "docker.ContainerExecAttach failed, name: %s, spec: %+v" , name , exec )
@@ -445,7 +444,9 @@ func (rs *ReplicaSetService) patchGpu(name string, spec *models.GpuPatch, info *
445444 name , len (uuids ), uuids )
446445 }
447446 if spec .GpuCount == 0 {
448- info .HostConfig .Resources = container.Resources {}
447+ info .HostConfig .Resources = container.Resources {
448+ Memory : info .HostConfig .Memory ,
449+ }
449450 } else {
450451 uuids , err = schedulers .GpuScheduler .Apply (spec .GpuCount )
451452 if err != nil {
@@ -704,6 +705,12 @@ func (rs *ReplicaSetService) RestartContainer(name string) (id, newContainerName
704705 return id , newContainerName , errors .WithMessage (err , "services.containerCpusetCpus failed" )
705706 }
706707
708+ // get memory info
709+ memory , err := rs .containerMemory (ctrVersionName )
710+ if err != nil {
711+ return id , newContainerName , errors .WithMessage (err , "services.containerMemory failed" )
712+ }
713+
707714 // get creation info from etcd
708715 infoBytes , err := etcd .GetValue (etcd .Containers , name )
709716 if err != nil {
@@ -742,6 +749,11 @@ func (rs *ReplicaSetService) RestartContainer(name string) (id, newContainerName
742749 info .HostConfig .Resources .CpusetCpus = availableCpus
743750 }
744751
752+ // check whether the container is using memory
753+ if memory != 0 {
754+ info .HostConfig .Resources .Memory = memory
755+ }
756+
745757 // create a container to replace the old one
746758 id , newContainerName , kv , err := rs .runContainer (ctx , name , info , true )
747759 if err != nil {
0 commit comments