@@ -406,6 +406,7 @@ func (c *CriManager) StopPodSandbox(ctx context.Context, r *runtime.StopPodSandb
406406 if err != nil {
407407 return nil , fmt .Errorf ("failed to stop container %q of sandbox %q: %v" , container .ID , podSandboxID , err )
408408 }
409+ logrus .Infof ("success to stop container %q of sandbox %q" , container .ID , podSandboxID )
409410 }
410411
411412 container , err := c .ContainerMgr .Get (ctx , podSandboxID )
@@ -437,6 +438,8 @@ func (c *CriManager) StopPodSandbox(ctx context.Context, r *runtime.StopPodSandb
437438 }
438439 } else if ! os .IsNotExist (err ) {
439440 return nil , fmt .Errorf ("failed to stat network namespace file %s of sandbox %s: %v" , sandboxMeta .NetNSPath , podSandboxID , err )
441+ } else {
442+ logrus .Warnf ("failed to find network namespace file %s of sandbox %s which may have been already stopped" , sandboxMeta .NetNSPath , podSandboxID )
440443 }
441444 }
442445
@@ -471,6 +474,7 @@ func (c *CriManager) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodS
471474 if err != nil {
472475 return nil , fmt .Errorf ("failed to remove container %q of sandbox %q: %v" , container .ID , podSandboxID , err )
473476 }
477+ logrus .Infof ("success to remove container %q of sandbox %q" , container .ID , podSandboxID )
474478 }
475479
476480 // Remove the sandbox container.
@@ -663,20 +667,19 @@ func (c *CriManager) CreateContainer(ctx context.Context, r *runtime.CreateConta
663667
664668 containerName := makeContainerName (sandboxConfig , config )
665669
666- var createErr error
667- createResp , createErr := c .ContainerMgr .Create (ctx , containerName , createConfig )
668- if createErr != nil {
670+ createResp , err := c .ContainerMgr .Create (ctx , containerName , createConfig )
671+ if err != nil {
669672 return nil , fmt .Errorf ("failed to create container for sandbox %q: %v" , podSandboxID , err )
670673 }
671674
672675 containerID := createResp .ID
673676
674677 defer func () {
675678 // If the container failed to be created, clean up the container.
676- if createErr != nil {
677- err := c .ContainerMgr .Remove (ctx , containerID , & apitypes.ContainerRemoveOptions {Volumes : true , Force : true })
678- if err != nil {
679- logrus .Errorf ("failed to remove the container when creating container failed: %v" , err )
679+ if err != nil {
680+ removeErr := c .ContainerMgr .Remove (ctx , containerID , & apitypes.ContainerRemoveOptions {Volumes : true , Force : true })
681+ if removeErr != nil {
682+ logrus .Errorf ("failed to remove the container when creating container failed: %v" , removeErr )
680683 }
681684 }
682685 }()
@@ -687,7 +690,7 @@ func (c *CriManager) CreateContainer(ctx context.Context, r *runtime.CreateConta
687690 // NOTE: If we attach log here, the IO of container will be created
688691 // by this function first, so we should decide whether open the stdin
689692 // here. It's weird actually, make it more elegant in the future.
690- err : = c .attachLog (logPath , containerID , config .Stdin )
693+ err = c .attachLog (logPath , containerID , config .Stdin )
691694 if err != nil {
692695 return nil , err
693696 }
0 commit comments