File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
cmd/power-dra-kubeletplugin
deployments/helm/power-dra-driver/templates Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,24 @@ import (
10
10
"math/rand"
11
11
"os"
12
12
13
+ "github.com/google/uuid"
13
14
resourceapi "k8s.io/api/resource/v1beta1"
14
15
"k8s.io/apimachinery/pkg/api/resource"
16
+ "k8s.io/klog/v2"
15
17
"k8s.io/utils/ptr"
16
-
17
- "github.com/google/uuid"
18
18
)
19
19
20
+ const NXGZIPCAPS = "/host-sys/devices/vio/ibm,compression-v1/nx_gzip_caps"
21
+
20
22
func enumerateAllPossibleDevices (numNx int ) (AllocatableDevices , error ) {
21
23
seed := os .Getenv ("NODE_NAME" )
22
24
uuids := generateUUIDs (seed , numNx )
23
-
24
25
alldevices := make (AllocatableDevices )
26
+ if ! existsNxGzip () {
27
+ // If nx-gzip doesn't exist, then don't return any devices.
28
+ return alldevices , nil
29
+ }
30
+
25
31
for i , uuid := range uuids {
26
32
device := resourceapi.Device {
27
33
Name : fmt .Sprintf ("nx-%d" , i ),
@@ -73,3 +79,13 @@ func hash(s string) int64 {
73
79
}
74
80
return h
75
81
}
82
+
83
+ // Detect NXGZIPCAPS exists
84
+ func existsNxGzip () bool {
85
+ _ , err := os .Stat (NXGZIPCAPS )
86
+ if err != nil {
87
+ klog .V (5 ).ErrorS (err , "Failed to detect Nest Accelerator nx-gzip feature" )
88
+ return false
89
+ }
90
+ return true
91
+ }
Original file line number Diff line number Diff line change 66
66
mountPath : /var/lib/kubelet/plugins
67
67
- name : cdi
68
68
mountPath : /var/run/cdi
69
+ - name : host-sys
70
+ mountPath : /host-sys
69
71
volumes :
70
72
- name : plugins-registry
71
73
hostPath :
75
77
hostPath :
76
78
path : /var/lib/kubelet/plugins
77
79
type : Directory
80
+ - name : host-sys
81
+ hostPath :
82
+ path : /sys
83
+ type : Directory
78
84
- name : cdi
79
85
hostPath :
80
86
path : /var/run/cdi
You can’t perform that action at this time.
0 commit comments