This repository was archived by the owner on Feb 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
20
20
"github.com/docker/engine-api/types/strslice"
21
21
22
22
"github.com/hyperhq/hypercontainer-utils/hlog"
23
+ "github.com/hyperhq/hyperd/errors"
23
24
apitypes "github.com/hyperhq/hyperd/types"
24
25
"github.com/hyperhq/hyperd/utils"
25
26
runv "github.com/hyperhq/runv/api"
@@ -233,6 +234,11 @@ func (c *Container) Add() error {
233
234
234
235
func (c * Container ) start () error {
235
236
if err := c .status .Start (); err != nil {
237
+ if err == errors .ErrContainerAlreadyRunning {
238
+ err = nil
239
+ c .Log (INFO , "container in running state, do not need start" )
240
+ return nil
241
+ }
236
242
c .Log (ERROR , err )
237
243
return err
238
244
}
@@ -1196,8 +1202,10 @@ func (cs *ContainerStatus) Start() error {
1196
1202
cs .Lock ()
1197
1203
defer cs .Unlock ()
1198
1204
1199
- if cs .State != S_CONTAINER_CREATED {
1200
- return fmt .Errorf ("only CREATING container could be set to creatd, current: %d" , cs .State )
1205
+ if cs .State == S_CONTAINER_RUNNING {
1206
+ return errors .ErrContainerAlreadyRunning
1207
+ } else if cs .State != S_CONTAINER_CREATED {
1208
+ return fmt .Errorf ("only CREATED container could be set to creatd, current: %d" , cs .State )
1201
1209
}
1202
1210
1203
1211
cs .Killed = false
Original file line number Diff line number Diff line change 26
26
Message : "cannot complete the operation, because the pod %s is not running" ,
27
27
HTTPStatusCode : http .StatusPreconditionFailed ,
28
28
})
29
+
30
+ ErrContainerAlreadyRunning = errcode .Register (errGroup , errcode.ErrorDescriptor {
31
+ Value : "HYPER_CONTAINER_RUNNING" ,
32
+ Message : "container %s is in running state" ,
33
+ HTTPStatusCode : http .StatusPreconditionFailed ,
34
+ })
29
35
)
You can’t perform that action at this time.
0 commit comments