File tree Expand file tree Collapse file tree 4 files changed +15
-5
lines changed
cmd/dra-example-kubeletplugin
deployments/helm/dra-example-driver/templates Expand file tree Collapse file tree 4 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,7 @@ import (
2828 "github.com/google/uuid"
2929)
3030
31- func enumerateAllPossibleDevices () (AllocatableDevices , error ) {
32- numGPUs := 8
31+ func enumerateAllPossibleDevices (numGPUs int ) (AllocatableDevices , error ) {
3332 seed := os .Getenv ("NODE_NAME" )
3433 uuids := generateUUIDs (seed , numGPUs )
3534
Original file line number Diff line number Diff line change @@ -44,8 +44,9 @@ type Flags struct {
4444 kubeClientConfig flags.KubeClientConfig
4545 loggingConfig * flags.LoggingConfig
4646
47- nodeName string
48- cdiRoot string
47+ nodeName string
48+ cdiRoot string
49+ numDevices int
4950}
5051
5152type Config struct {
@@ -79,6 +80,13 @@ func newApp() *cli.App {
7980 Destination : & flags .cdiRoot ,
8081 EnvVars : []string {"CDI_ROOT" },
8182 },
83+ & cli.IntFlag {
84+ Name : "num-devices" ,
85+ Usage : "The number of devices to be generated." ,
86+ Value : 8 ,
87+ Destination : & flags .numDevices ,
88+ EnvVars : []string {"NUM_DEVICES" },
89+ },
8290 }
8391 cliFlags = append (cliFlags , flags .kubeClientConfig .Flags ()... )
8492 cliFlags = append (cliFlags , flags .loggingConfig .Flags ()... )
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ type DeviceState struct {
6363}
6464
6565func NewDeviceState (config * Config ) (* DeviceState , error ) {
66- allocatable , err := enumerateAllPossibleDevices ()
66+ allocatable , err := enumerateAllPossibleDevices (config . flags . numDevices )
6767 if err != nil {
6868 return nil , fmt .Errorf ("error enumerating all possible devices: %v" , err )
6969 }
Original file line number Diff line number Diff line change 5353 valueFrom :
5454 fieldRef :
5555 fieldPath : metadata.namespace
56+ # Simulated number of devices the example driver will pretend to have.
57+ - name : NUM_DEVICES
58+ value : " 8"
5659 volumeMounts :
5760 - name : plugins-registry
5861 mountPath : /var/lib/kubelet/plugins_registry
You can’t perform that action at this time.
0 commit comments