@@ -28,7 +28,6 @@ import (
28
28
"golang.org/x/time/rate"
29
29
resourceapi "k8s.io/api/resource/v1beta1"
30
30
"k8s.io/apimachinery/pkg/util/validation"
31
- "k8s.io/dynamic-resource-allocation/kubeletplugin"
32
31
"k8s.io/klog/v2"
33
32
"k8s.io/utils/ptr"
34
33
)
@@ -53,7 +52,7 @@ type DB struct {
53
52
store map [string ]resourceapi.Device
54
53
55
54
rateLimiter * rate.Limiter
56
- notifications chan kubeletplugin. Resources
55
+ notifications chan []resourceapi. Device
57
56
}
58
57
59
58
type Device struct {
@@ -65,7 +64,7 @@ func New() *DB {
65
64
return & DB {
66
65
rateLimiter : rate .NewLimiter (rate .Every (minInterval ), 1 ),
67
66
store : map [string ]resourceapi.Device {},
68
- notifications : make (chan kubeletplugin. Resources ),
67
+ notifications : make (chan []resourceapi. Device ),
69
68
}
70
69
}
71
70
@@ -93,7 +92,7 @@ func (db *DB) Run(ctx context.Context) error {
93
92
klog .Error (err , "unexpected rate limited error trying to get system interfaces" )
94
93
}
95
94
96
- resources := kubeletplugin. Resources {}
95
+ devices := []resourceapi. Device {}
97
96
ifaces , err := net .Interfaces ()
98
97
if err != nil {
99
98
klog .Error (err , "unexpected error trying to get system interfaces" )
@@ -117,7 +116,7 @@ func (db *DB) Run(ctx context.Context) error {
117
116
continue
118
117
}
119
118
120
- resources . Devices = append (resources . Devices , * device )
119
+ devices = append (devices , * device )
121
120
klog .V (4 ).Infof ("Found following network interface %s" , iface .Name )
122
121
}
123
122
@@ -136,12 +135,13 @@ func (db *DB) Run(ctx context.Context) error {
136
135
continue
137
136
}
138
137
139
- resources . Devices = append (resources . Devices , * device )
138
+ devices = append (devices , * device )
140
139
klog .V (4 ).Infof ("Found following rdma interface %s" , iface .Attrs .Name )
141
140
}
142
141
143
- if len (resources .Devices ) > 0 {
144
- db .notifications <- resources
142
+ klog .V (4 ).Infof ("Found %d devices" , len (devices ))
143
+ if len (devices ) > 0 {
144
+ db .notifications <- devices
145
145
}
146
146
select {
147
147
// trigger a reconcile
@@ -157,7 +157,7 @@ func (db *DB) Run(ctx context.Context) error {
157
157
}
158
158
}
159
159
160
- func (db * DB ) GetResources (ctx context.Context ) <- chan kubeletplugin. Resources {
160
+ func (db * DB ) GetResources (ctx context.Context ) <- chan []resourceapi. Device {
161
161
return db .notifications
162
162
}
163
163
@@ -187,7 +187,7 @@ func (db *DB) netdevToDRAdev(ifName string) (*resourceapi.Device, error) {
187
187
188
188
if ips , err := netlink .AddrList (link , netlink .FAMILY_ALL ); err == nil && len (ips ) > 0 {
189
189
// TODO assume only one addres by now
190
- ip := ips [0 ].String ()
190
+ ip := ips [0 ].IP . String ()
191
191
device .Basic .Attributes ["ip" ] = resourceapi.DeviceAttribute {StringValue : & ip }
192
192
mac := link .Attrs ().HardwareAddr .String ()
193
193
device .Basic .Attributes ["mac" ] = resourceapi.DeviceAttribute {StringValue : & mac }
0 commit comments