Use proper variable for error return in Server#createSandboxContainer
@@ -250,7 +250,7 @@ func makeAccessible(path string, uid, gid int) error {
}
// nolint:gocyclo
-func (s *Server) createSandboxContainer(ctx context.Context, containerID, containerName string, sb *sandbox.Sandbox, sandboxConfig *pb.PodSandboxConfig, containerConfig *pb.ContainerConfig) (*oci.Container, error) {
+func (s *Server) createSandboxContainer(ctx context.Context, containerID, containerName string, sb *sandbox.Sandbox, sandboxConfig *pb.PodSandboxConfig, containerConfig *pb.ContainerConfig) (cntr *oci.Container, errRet error) {
if sb == nil {
return nil, errors.New("createSandboxContainer needs a sandbox")
}
@@ -402,7 +402,7 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID, contai
}
defer func() {
- if err != nil {
+ if errRet != nil {
err2 := s.StorageRuntimeServer().DeleteContainer(containerInfo.ID)
if err2 != nil {
log.Warnf(ctx, "Failed to cleanup container directory: %v", err2)
