File tree 4 files changed +14
-5
lines changed
cmd/dra-example-kubeletplugin
deployments/helm/dra-example-driver/templates
4 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,7 @@ import (
28
28
"github.com/google/uuid"
29
29
)
30
30
31
- func enumerateAllPossibleDevices () (AllocatableDevices , error ) {
32
- numGPUs := 8
31
+ func enumerateAllPossibleDevices (numGPUs int ) (AllocatableDevices , error ) {
33
32
seed := os .Getenv ("NODE_NAME" )
34
33
uuids := generateUUIDs (seed , numGPUs )
35
34
Original file line number Diff line number Diff line change @@ -44,8 +44,9 @@ type Flags struct {
44
44
kubeClientConfig flags.KubeClientConfig
45
45
loggingConfig * flags.LoggingConfig
46
46
47
- nodeName string
48
- cdiRoot string
47
+ nodeName string
48
+ cdiRoot string
49
+ numDevices int
49
50
}
50
51
51
52
type Config struct {
@@ -79,6 +80,13 @@ func newApp() *cli.App {
79
80
Destination : & flags .cdiRoot ,
80
81
EnvVars : []string {"CDI_ROOT" },
81
82
},
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
+ },
82
90
}
83
91
cliFlags = append (cliFlags , flags .kubeClientConfig .Flags ()... )
84
92
cliFlags = append (cliFlags , flags .loggingConfig .Flags ()... )
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ type DeviceState struct {
63
63
}
64
64
65
65
func NewDeviceState (config * Config ) (* DeviceState , error ) {
66
- allocatable , err := enumerateAllPossibleDevices ()
66
+ allocatable , err := enumerateAllPossibleDevices (config . flags . numDevices )
67
67
if err != nil {
68
68
return nil , fmt .Errorf ("error enumerating all possible devices: %v" , err )
69
69
}
Original file line number Diff line number Diff line change 53
53
valueFrom :
54
54
fieldRef :
55
55
fieldPath : metadata.namespace
56
+ - name : NUM_DEVICES
57
+ value : " 8"
56
58
volumeMounts :
57
59
- name : plugins-registry
58
60
mountPath : /var/lib/kubelet/plugins_registry
You can’t perform that action at this time.
0 commit comments