@@ -10,7 +10,6 @@ import (
10
10
"strings"
11
11
"time"
12
12
13
- "github.com/docker/docker/api/types"
14
13
"github.com/docker/docker/api/types/container"
15
14
"github.com/docker/docker/api/types/filters"
16
15
"github.com/docker/docker/api/types/network"
@@ -224,7 +223,7 @@ func (rs *ReplicaSetService) ExecuteContainer(name string, exec *models.Containe
224
223
}
225
224
226
225
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 {
228
227
AttachStderr : true ,
229
228
AttachStdout : true ,
230
229
Detach : true ,
@@ -236,7 +235,7 @@ func (rs *ReplicaSetService) ExecuteContainer(name string, exec *models.Containe
236
235
return resp , errors .Wrapf (err , "docker.ContainerExecCreate failed, name: %s, spec: %+v" , name , exec )
237
236
}
238
237
239
- hijackedResp , err := docker .Cli .ContainerExecAttach (ctx , execCreate .ID , types. ExecStartCheck {})
238
+ hijackedResp , err := docker .Cli .ContainerExecAttach (ctx , execCreate .ID , container. ExecAttachOptions {})
240
239
defer hijackedResp .Close ()
241
240
if err != nil {
242
241
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 *
445
444
name , len (uuids ), uuids )
446
445
}
447
446
if spec .GpuCount == 0 {
448
- info .HostConfig .Resources = container.Resources {}
447
+ info .HostConfig .Resources = container.Resources {
448
+ Memory : info .HostConfig .Memory ,
449
+ }
449
450
} else {
450
451
uuids , err = schedulers .GpuScheduler .Apply (spec .GpuCount )
451
452
if err != nil {
@@ -704,6 +705,12 @@ func (rs *ReplicaSetService) RestartContainer(name string) (id, newContainerName
704
705
return id , newContainerName , errors .WithMessage (err , "services.containerCpusetCpus failed" )
705
706
}
706
707
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
+
707
714
// get creation info from etcd
708
715
infoBytes , err := etcd .GetValue (etcd .Containers , name )
709
716
if err != nil {
@@ -742,6 +749,11 @@ func (rs *ReplicaSetService) RestartContainer(name string) (id, newContainerName
742
749
info .HostConfig .Resources .CpusetCpus = availableCpus
743
750
}
744
751
752
+ // check whether the container is using memory
753
+ if memory != 0 {
754
+ info .HostConfig .Resources .Memory = memory
755
+ }
756
+
745
757
// create a container to replace the old one
746
758
id , newContainerName , kv , err := rs .runContainer (ctx , name , info , true )
747
759
if err != nil {
0 commit comments