Skip to content

Commit

Permalink
Resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianco95 committed Jun 17, 2024
2 parents 59730bc + 33d44b1 commit dfabf3d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
13 changes: 11 additions & 2 deletions pkg/docker/Create.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,16 @@ func (h *SidecarHandler) CreateHandler(w http.ResponseWriter, r *http.Request) {
podUID := string(data.Pod.UID)
podNamespace := string(data.Pod.Namespace)

podDirectoryPath := filepath.Join(wd, h.Config.DataRootFolder+podNamespace+"-"+podUID)
podDirectoryPath := filepath.Join(wd, h.Config.DataRootFolder+"/"+podNamespace+"-"+podUID)

// if the podDirectoryPath does not exist, create it
if _, err := os.Stat(podDirectoryPath); os.IsNotExist(err) {
err = os.MkdirAll(podDirectoryPath, os.ModePerm)
if err != nil {
HandleErrorAndRemoveData(h, w, "An error occurred during the creation of the pod directory", err, "", "")
return
}
}

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

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)
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)

var dindContainerID string
shell := exec.ExecTask{
Expand Down
15 changes: 14 additions & 1 deletion pkg/docker/Delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
exec "github.com/alexellis/go-execute/pkg/v1"
"github.com/containerd/containerd/log"
v1 "k8s.io/api/core/v1"

"path/filepath"
)

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

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

err = os.RemoveAll(podDirectoryPathToDelete)

//os.RemoveAll(h.Config.DataRootFolder + pod.Namespace + "-" + string(pod.UID))
}

w.WriteHeader(statusCode)
Expand Down

0 comments on commit dfabf3d

Please sign in to comment.