Skip to content

Commit dfabf3d

Browse files
committed
Resolved merge conflicts
2 parents 59730bc + 33d44b1 commit dfabf3d

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

pkg/docker/Create.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,16 @@ func (h *SidecarHandler) CreateHandler(w http.ResponseWriter, r *http.Request) {
235235
podUID := string(data.Pod.UID)
236236
podNamespace := string(data.Pod.Namespace)
237237

238-
podDirectoryPath := filepath.Join(wd, h.Config.DataRootFolder+podNamespace+"-"+podUID)
238+
podDirectoryPath := filepath.Join(wd, h.Config.DataRootFolder+"/"+podNamespace+"-"+podUID)
239+
240+
// if the podDirectoryPath does not exist, create it
241+
if _, err := os.Stat(podDirectoryPath); os.IsNotExist(err) {
242+
err = os.MkdirAll(podDirectoryPath, os.ModePerm)
243+
if err != nil {
244+
HandleErrorAndRemoveData(h, w, "An error occurred during the creation of the pod directory", err, "", "")
245+
return
246+
}
247+
}
239248

240249
// call prepareDockerRuns to get the DockerRunStruct array
241250
dockerRunStructs, err := h.prepareDockerRuns(data, w)
@@ -282,7 +291,7 @@ func (h *SidecarHandler) CreateHandler(w http.ResponseWriter, r *http.Request) {
282291
dindContainerArgs = append(dindContainerArgs, "-v", "/cvmfs:/cvmfs")
283292
}
284293

285-
dindContainerArgs = append(dindContainerArgs, "--privileged", "-v", "/home:/home", "-v", "/var/lib/docker/overlay2:/var/lib/docker/overlay2", "-v", "/var/lib/docker/image:/var/lib/docker/image", "-d", "--name", string(data.Pod.UID)+"_dind", dindImage)
294+
dindContainerArgs = append(dindContainerArgs, "--privileged", "-v", wd+":/"+wd, "-v", "/home:/home", "-v", "/var/lib/docker/overlay2:/var/lib/docker/overlay2", "-v", "/var/lib/docker/image:/var/lib/docker/image", "-d", "--name", string(data.Pod.UID)+"_dind", dindImage)
286295

287296
var dindContainerID string
288297
shell := exec.ExecTask{

pkg/docker/Delete.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
exec "github.com/alexellis/go-execute/pkg/v1"
1111
"github.com/containerd/containerd/log"
1212
v1 "k8s.io/api/core/v1"
13+
14+
"path/filepath"
1315
)
1416

1517
// DeleteHandler stops and deletes Docker containers from provided data
@@ -108,7 +110,18 @@ func (h *SidecarHandler) DeleteHandler(w http.ResponseWriter, r *http.Request) {
108110
log.G(h.Ctx).Info("\u2705 [DELETE CALL] Deleted container " + podUID + "_dind")
109111
}
110112

111-
os.RemoveAll(h.Config.DataRootFolder + pod.Namespace + "-" + string(pod.UID))
113+
// check if the container has GPU devices attacched using the GpuManager and release them
114+
wd, err := os.Getwd()
115+
if err != nil {
116+
HandleErrorAndRemoveData(h, w, "Unable to get current working directory", err, "", "")
117+
return
118+
}
119+
podDirectoryPathToDelete := filepath.Join(wd, h.Config.DataRootFolder+"/"+podNamespace+"-"+podUID)
120+
log.G(h.Ctx).Info("\u2705 [DELETE CALL] Deleting directory " + podDirectoryPathToDelete)
121+
122+
err = os.RemoveAll(podDirectoryPathToDelete)
123+
124+
//os.RemoveAll(h.Config.DataRootFolder + pod.Namespace + "-" + string(pod.UID))
112125
}
113126

114127
w.WriteHeader(statusCode)

0 commit comments

Comments
 (0)