Skip to content

Commit 6bb54c3

Browse files
committed
use kube 1.32
Change-Id: Id49de2c9406cc9133a6045b573eb484f956e965c
1 parent 31535cc commit 6bb54c3

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

kind.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ containerdConfigPatches:
2020
disable = false
2121
nodes:
2222
- role: control-plane
23+
image: kindest/node:v1.32.0
2324
kubeadmConfigPatches:
2425
# Enable the corresponding version of the resource.k8s.io API
2526
- |
@@ -37,13 +38,15 @@ nodes:
3738
kubeletExtraArgs:
3839
v: "5"
3940
- role: worker
41+
image: kindest/node:v1.32.0
4042
kubeadmConfigPatches:
4143
- |
4244
kind: JoinConfiguration
4345
nodeRegistration:
4446
kubeletExtraArgs:
4547
v: "5"
4648
- role: worker
49+
image: kindest/node:v1.32.0
4750
kubeadmConfigPatches:
4851
- |
4952
kind: JoinConfiguration
@@ -54,4 +57,4 @@ featureGates:
5457
# Enable the corresponding DRA feature gates
5558
DynamicResourceAllocation: true
5659
runtimeConfig:
57-
api/all : true
60+
api/beta : true

pkg/driver/driver.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type NetworkDriver struct {
8080

8181
podAllocations storage
8282
claimAllocations storage
83-
netdb inventory.DB
83+
netdb *inventory.DB
8484
}
8585

8686
type Option func(*NetworkDriver)
@@ -149,9 +149,9 @@ func Start(ctx context.Context, driverName string, kubeClient kubernetes.Interfa
149149
}()
150150

151151
// register the host network interfaces
152-
netdb := inventory.New()
152+
plugin.netdb = inventory.New()
153153
go func() {
154-
err = netdb.Run(ctx)
154+
err = plugin.netdb.Run(ctx)
155155
if err != nil {
156156
klog.Infof("Network Device DB failed with error %v", err)
157157
}
@@ -296,7 +296,11 @@ func (np *NetworkDriver) PublishResources(ctx context.Context) {
296296
klog.V(2).Infof("Publishing resources")
297297
for {
298298
select {
299-
case resources := <-np.netdb.GetResources(ctx):
299+
case devices := <-np.netdb.GetResources(ctx):
300+
klog.V(4).Infof("Received %d devices", len(devices))
301+
resources := kubeletplugin.Resources{
302+
Devices: devices,
303+
}
300304
err := np.draPlugin.PublishResources(ctx, resources)
301305
if err != nil {
302306
klog.Error(err, "unexpected error trying to publish resources")

pkg/inventory/db.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"golang.org/x/time/rate"
2929
resourceapi "k8s.io/api/resource/v1beta1"
3030
"k8s.io/apimachinery/pkg/util/validation"
31-
"k8s.io/dynamic-resource-allocation/kubeletplugin"
3231
"k8s.io/klog/v2"
3332
"k8s.io/utils/ptr"
3433
)
@@ -53,7 +52,7 @@ type DB struct {
5352
store map[string]resourceapi.Device
5453

5554
rateLimiter *rate.Limiter
56-
notifications chan kubeletplugin.Resources
55+
notifications chan []resourceapi.Device
5756
}
5857

5958
type Device struct {
@@ -65,7 +64,7 @@ func New() *DB {
6564
return &DB{
6665
rateLimiter: rate.NewLimiter(rate.Every(minInterval), 1),
6766
store: map[string]resourceapi.Device{},
68-
notifications: make(chan kubeletplugin.Resources),
67+
notifications: make(chan []resourceapi.Device),
6968
}
7069
}
7170

@@ -93,7 +92,7 @@ func (db *DB) Run(ctx context.Context) error {
9392
klog.Error(err, "unexpected rate limited error trying to get system interfaces")
9493
}
9594

96-
resources := kubeletplugin.Resources{}
95+
devices := []resourceapi.Device{}
9796
ifaces, err := net.Interfaces()
9897
if err != nil {
9998
klog.Error(err, "unexpected error trying to get system interfaces")
@@ -117,7 +116,7 @@ func (db *DB) Run(ctx context.Context) error {
117116
continue
118117
}
119118

120-
resources.Devices = append(resources.Devices, *device)
119+
devices = append(devices, *device)
121120
klog.V(4).Infof("Found following network interface %s", iface.Name)
122121
}
123122

@@ -136,12 +135,13 @@ func (db *DB) Run(ctx context.Context) error {
136135
continue
137136
}
138137

139-
resources.Devices = append(resources.Devices, *device)
138+
devices = append(devices, *device)
140139
klog.V(4).Infof("Found following rdma interface %s", iface.Attrs.Name)
141140
}
142141

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
145145
}
146146
select {
147147
// trigger a reconcile
@@ -157,7 +157,7 @@ func (db *DB) Run(ctx context.Context) error {
157157
}
158158
}
159159

160-
func (db *DB) GetResources(ctx context.Context) <-chan kubeletplugin.Resources {
160+
func (db *DB) GetResources(ctx context.Context) <-chan []resourceapi.Device {
161161
return db.notifications
162162
}
163163

@@ -187,7 +187,7 @@ func (db *DB) netdevToDRAdev(ifName string) (*resourceapi.Device, error) {
187187

188188
if ips, err := netlink.AddrList(link, netlink.FAMILY_ALL); err == nil && len(ips) > 0 {
189189
// TODO assume only one addres by now
190-
ip := ips[0].String()
190+
ip := ips[0].IP.String()
191191
device.Basic.Attributes["ip"] = resourceapi.DeviceAttribute{StringValue: &ip}
192192
mac := link.Attrs().HardwareAddr.String()
193193
device.Basic.Attributes["mac"] = resourceapi.DeviceAttribute{StringValue: &mac}

0 commit comments

Comments
 (0)