Skip to content

Commit 8c3b0a8

Browse files
committed
removed gpu bookkeeping and modified makefile target in order to disable cgo during build process
1 parent 3bee2ab commit 8c3b0a8

File tree

8 files changed

+9
-364
lines changed

8 files changed

+9
-364
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
all: sidecars
22

33
sidecars:
4-
CGO_ENABLED=1 GOOS=linux go build -o bin/docker-sd cmd/main.go
4+
CGO_ENABLED=0 GOOS=linux go build -o bin/docker-sd cmd/main.go
55

cmd/main.go

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
commonIL "github.com/intertwin-eu/interlink-docker-plugin/pkg/common"
1212
docker "github.com/intertwin-eu/interlink-docker-plugin/pkg/docker"
13-
"github.com/intertwin-eu/interlink-docker-plugin/pkg/docker/gpustrategies"
1413
)
1514

1615
func main() {
@@ -33,31 +32,9 @@ func main() {
3332
defer cancel()
3433
log.G(Ctx).Debug("Debug level: " + strconv.FormatBool(interLinkConfig.VerboseLogging))
3534

36-
var gpuManager gpustrategies.GPUManagerInterface
37-
gpuManager = &gpustrategies.GPUManager{
38-
GPUSpecsList: []gpustrategies.GPUSpecs{},
39-
Ctx: Ctx,
40-
}
41-
42-
err = gpuManager.Init()
43-
if err != nil {
44-
log.G(Ctx).Fatal(err)
45-
}
46-
47-
err = gpuManager.Discover()
48-
if err != nil {
49-
log.G(Ctx).Fatal(err)
50-
}
51-
52-
err = gpuManager.Check()
53-
if err != nil {
54-
log.G(Ctx).Fatal(err)
55-
}
56-
5735
SidecarAPIs := docker.SidecarHandler{
58-
Config: interLinkConfig,
59-
Ctx: Ctx,
60-
GpuManager: gpuManager,
36+
Config: interLinkConfig,
37+
Ctx: Ctx,
6138
}
6239

6340
mutex := http.NewServeMux()

pkg/docker/Create.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -66,55 +66,6 @@ func (h *SidecarHandler) CreateHandler(w http.ResponseWriter, r *http.Request) {
6666

6767
containerName := podNamespace + "-" + podUID + "-" + container.Name
6868

69-
var isGpuRequested bool = false
70-
var additionalGpuArgs []string
71-
72-
if val, ok := container.Resources.Limits["nvidia.com/gpu"]; ok {
73-
74-
numGpusRequested := val.Value()
75-
76-
log.G(h.Ctx).Infof("Number of GPU requested: %d", numGpusRequested)
77-
78-
// if the container is requesting 0 GPU, skip the GPU assignment
79-
if numGpusRequested == 0 {
80-
log.G(h.Ctx).Info("Container " + containerName + " is not requesting a GPU")
81-
82-
} else {
83-
84-
log.G(h.Ctx).Info("Container " + containerName + " is requesting " + val.String() + " GPU")
85-
86-
isGpuRequested = true
87-
88-
numGpusRequestedInt := int(numGpusRequested)
89-
_, err := h.GpuManager.GetAvailableGPUs(numGpusRequestedInt)
90-
91-
if err != nil {
92-
HandleErrorAndRemoveData(h, w, statusCode, "Some errors occurred while creating container. Check Docker Sidecar's logs", err, &data)
93-
return
94-
}
95-
96-
gpuSpecs, err := h.GpuManager.GetAndAssignAvailableGPUs(numGpusRequestedInt, containerName)
97-
if err != nil {
98-
HandleErrorAndRemoveData(h, w, statusCode, "Some errors occurred while creating container. Check Docker Sidecar's logs", err, &data)
99-
return
100-
}
101-
102-
var gpuUUIDs string = ""
103-
for _, gpuSpec := range gpuSpecs {
104-
if gpuSpec.UUID == gpuSpecs[len(gpuSpecs)-1].UUID {
105-
gpuUUIDs += strconv.Itoa(gpuSpec.Index)
106-
} else {
107-
gpuUUIDs += strconv.Itoa(gpuSpec.Index) + ","
108-
}
109-
}
110-
111-
additionalGpuArgs = append(additionalGpuArgs, "--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES="+gpuUUIDs)
112-
}
113-
114-
} else {
115-
log.G(h.Ctx).Info("Container " + containerName + " is not requesting a GPU")
116-
}
117-
11869
log.G(h.Ctx).Info("-- Preparing environment variables for " + containerName)
11970

12071
var envVars string = ""
@@ -156,10 +107,6 @@ func (h *SidecarHandler) CreateHandler(w http.ResponseWriter, r *http.Request) {
156107

157108
cmd = append(cmd, envVars)
158109

159-
if isGpuRequested {
160-
cmd = append(cmd, additionalGpuArgs...)
161-
}
162-
163110
var additionalPortArgs []string
164111
for _, port := range container.Ports {
165112
if port.HostPort != 0 {

pkg/docker/Delete.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func (h *SidecarHandler) DeleteHandler(w http.ResponseWriter, r *http.Request) {
4040
podUID := string(pod.UID)
4141
podNamespace := string(pod.Namespace)
4242

43-
4443
for _, container := range pod.Spec.Containers {
4544

4645
containerName := podNamespace + "-" + podUID + "-" + container.Name
@@ -90,9 +89,6 @@ func (h *SidecarHandler) DeleteHandler(w http.ResponseWriter, r *http.Request) {
9089
}
9190
}
9291

93-
// check if the container has GPU devices attacched using the GpuManager and release them
94-
h.GpuManager.Release(containerName)
95-
9692
os.RemoveAll(h.Config.DataRootFolder + pod.Namespace + "-" + string(pod.UID))
9793
}
9894

pkg/docker/Status.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (h *SidecarHandler) StatusHandler(w http.ResponseWriter, r *http.Request) {
4646
resp = append(resp, commonIL.PodStatus{PodName: pod.Name, PodUID: podUID, PodNamespace: podNamespace})
4747
for _, container := range pod.Spec.Containers {
4848
containerName := podNamespace + "-" + podUID + "-" + container.Name
49-
49+
5050
log.G(h.Ctx).Debug("- Getting status for container " + containerName)
5151
cmd := []string{"ps -af name=^" + containerName + "$ --format \"{{.Status}}\""}
5252

@@ -70,15 +70,13 @@ func (h *SidecarHandler) StatusHandler(w http.ResponseWriter, r *http.Request) {
7070
if execReturn.Stdout != "" {
7171
if containerstatus[0] == "Created" {
7272
log.G(h.Ctx).Info("-- Container " + containerName + " is going ready...")
73-
resp[i].Containers = append(resp[i].Containers,v1.ContainerStatus{Name: container.Name, State: v1.ContainerState{Waiting: &v1.ContainerStateWaiting{}}, Ready: false})
73+
resp[i].Containers = append(resp[i].Containers, v1.ContainerStatus{Name: container.Name, State: v1.ContainerState{Waiting: &v1.ContainerStateWaiting{}}, Ready: false})
7474
} else if containerstatus[0] == "Up" {
7575
log.G(h.Ctx).Info("-- Container " + containerName + " is running")
76-
resp[i].Containers = append(resp[i].Containers,v1.ContainerStatus{Name: container.Name, State: v1.ContainerState{Running: &v1.ContainerStateRunning{}}, Ready: true})
76+
resp[i].Containers = append(resp[i].Containers, v1.ContainerStatus{Name: container.Name, State: v1.ContainerState{Running: &v1.ContainerStateRunning{}}, Ready: true})
7777
} else if containerstatus[0] == "Exited" {
7878
log.G(h.Ctx).Info("-- Container " + containerName + " has been stopped")
79-
resp[i].Containers = append(resp[i].Containers,v1.ContainerStatus{Name: container.Name, State: v1.ContainerState{Terminated: &v1.ContainerStateTerminated{}}, Ready: false})
80-
// release all the GPUs from the container
81-
h.GpuManager.Release(containerName)
79+
resp[i].Containers = append(resp[i].Containers, v1.ContainerStatus{Name: container.Name, State: v1.ContainerState{Terminated: &v1.ContainerStateTerminated{}}, Ready: false})
8280
}
8381
} else {
8482
log.G(h.Ctx).Info("-- Container " + containerName + " doesn't exist")

pkg/docker/aux.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ import (
1414
"fmt"
1515

1616
commonIL "github.com/intertwin-eu/interlink-docker-plugin/pkg/common"
17-
"github.com/intertwin-eu/interlink-docker-plugin/pkg/docker/gpustrategies"
1817
)
1918

2019
type SidecarHandler struct {
21-
Config commonIL.InterLinkConfig
22-
Ctx context.Context
23-
GpuManager gpustrategies.GPUManagerInterface
20+
Config commonIL.InterLinkConfig
21+
Ctx context.Context
2422
}
2523

2624
// prepareMounts iterates along the struct provided in the data parameter and checks for ConfigMaps, Secrets and EmptyDirs to be mounted.

pkg/docker/gpustrategies/AmdHandler.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)