This repository was archived by the owner on Feb 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -222,28 +222,39 @@ func (p *XPod) ContainerStart(cid string) error {
222222
223223// Start() means start a STOPPED pod.
224224func (p * XPod ) Start () error {
225+ var err error
226+
227+ defer func () {
228+ if err != nil && p .sandbox != nil {
229+ status := p .sandbox .Status ()
230+ if status .State .State == vc .StateRunning {
231+ vc .StopSandbox (p .sandbox .ID ())
232+ vc .DeleteSandbox (p .sandbox .ID ())
233+ }
234+ }
235+ }()
225236
226237 if p .IsStopped () {
227- if err : = p .createSandbox (p .globalSpec ); err != nil {
238+ if err = p .createSandbox (p .globalSpec ); err != nil {
228239 p .Log (ERROR , "failed to create sandbox for the stopped pod: %v" , err )
229240 return err
230241 }
231242
232- if err : = p .prepareResources (); err != nil {
243+ if err = p .prepareResources (); err != nil {
233244 return err
234245 }
235246
236- if err : = p .addResourcesToSandbox (); err != nil {
247+ if err = p .addResourcesToSandbox (); err != nil {
237248 return err
238249 }
239250 }
240251
241- err : = p .waitPodRun ("start pod" )
252+ err = p .waitPodRun ("start pod" )
242253 if err != nil {
243254 p .Log (ERROR , "wait running failed, cannot start pod" )
244255 return err
245256 }
246- if err : = p .startAll (); err != nil {
257+ if err = p .startAll (); err != nil {
247258 return err
248259 }
249260
You can’t perform that action at this time.
0 commit comments