Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BUILD_DIR=$(shell pwd)/bin
COMPONENTS?=device-plugin status-updater kwok-gpu-device-plugin status-exporter topology-server mig-faker jupyter-notebook

DOCKER_REPO_BASE=gcr.io/run-ai-lab/fake-gpu-operator
DOCKER_REPO_BASE?=gcr.io/run-ai-lab/fake-gpu-operator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

DOCKER_TAG?=0.0.0-dev
NAMESPACE=gpu-operator

Expand Down
14 changes: 9 additions & 5 deletions cmd/nvidia-smi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ func main() {
fmt.Println("Debug mode enabled")
}

err := os.Setenv(constants.EnvTopologyCmNamespace, "gpu-operator")
if err != nil {
panic(err)
if _, ok := os.LookupEnv(constants.EnvTopologyCmNamespace); !ok {
err := os.Setenv(constants.EnvTopologyCmNamespace, "gpu-operator")
if err != nil {
panic(err)
}
}
err = os.Setenv(constants.EnvTopologyCmName, "topology")

err := os.Setenv(constants.EnvTopologyCmName, "topology")
if err != nil {
panic(err)
}
Expand All @@ -66,7 +69,8 @@ func getNvidiaSmiArgs() (args nvidiaSmiArgs) {
}

// Send http request to topology-server to get the topology
topologyUrl := "http://topology-server.gpu-operator/topology/nodes/" + nodeName
topologyUrl := fmt.Sprintf("http://topology-server.%s/topology/nodes/%s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please inject and use a FAKE_GPU_OPERATOR_NAMESPACE instead

os.Getenv(constants.EnvTopologyCmNamespace), nodeName)
if conf.Debug {
fmt.Printf("Requesting topology from: %s\n", topologyUrl)
}
Expand Down
2 changes: 1 addition & 1 deletion deploy/fake-gpu-operator/templates/runtime-class.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: nvidia
name: {{ .Values.runtimeClass.name | default "fake-nvidia" }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we keep the default nvidia to better fake the Nvidia GPU Operator behavior.

handler: runc
3 changes: 3 additions & 0 deletions deploy/fake-gpu-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,6 @@ topology:
gpuMemory: 11441
nodePoolLabelKey: run.ai/simulated-gpu-node-pool
migStrategy: mixed

runtimeClass:
name: fake-nvidia
12 changes: 10 additions & 2 deletions internal/deviceplugin/real_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (
"time"

"github.com/google/uuid"
"github.com/run-ai/fake-gpu-operator/internal/common/topology"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"

"github.com/run-ai/fake-gpu-operator/internal/common/constants"
"github.com/run-ai/fake-gpu-operator/internal/common/topology"
)

const (
Expand Down Expand Up @@ -170,11 +172,17 @@ func (m *RealNodeDevicePlugin) GetPreferredAllocation(context.Context, *pluginap
}

func (m *RealNodeDevicePlugin) Allocate(ctx context.Context, reqs *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error) {
ns := os.Getenv(constants.EnvTopologyCmNamespace)
if ns == "" {
ns = "gpu-operator"
}

responses := pluginapi.AllocateResponse{}
for _, req := range reqs.ContainerRequests {
response := pluginapi.ContainerAllocateResponse{
Envs: map[string]string{
"MOCK_NVIDIA_VISIBLE_DEVICES": strings.Join(req.DevicesIDs, ","),
"MOCK_NVIDIA_VISIBLE_DEVICES": strings.Join(req.DevicesIDs, ","),
constants.EnvTopologyCmNamespace: ns,
},
Mounts: []*pluginapi.Mount{
{
Expand Down