Skip to content

Commit 77ab291

Browse files
carloryalaypatel07
andcommitted
Enable DRA device metadata and bump dependencies to v0.36.0-rc.1
Add support for KEP-5304 in-container device metadata by passing device attributes from the allocatable device pool through to prepared devices. This includes a new --enable-device-metadata flag and corresponding Helm chart value. Also bumps Go to 1.26.0 and updates all k8s.io dependencies to v0.36.0-rc.1. Co-authored-by: alaypatel07 <alayp@nvidia.com> Signed-off-by: carlory <baofa.fan@daocloud.io>
1 parent 0489b2b commit 77ab291

10 files changed

Lines changed: 102 additions & 92 deletions

File tree

.github/workflows/e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Install Go
1313
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
1414
with:
15-
go-version: 1.25.5
15+
go-version: 1.26.0
1616
- name: Checkout code
1717
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1818
- name: Build

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
test:
1010
strategy:
1111
matrix:
12-
version: ['1.25.5' ]
12+
version: ['1.26.0' ]
1313
platform: [ ubuntu-latest, macos-latest ]
1414
runs-on: ${{ matrix.platform }}
1515
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.cache/
2+
.config/
23
vendor/
34
[._]*.sw[a-p]
45

cmd/dra-example-kubeletplugin/driver.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"k8s.io/apimachinery/pkg/types"
2626
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2727
coreclientset "k8s.io/client-go/kubernetes"
28+
"k8s.io/dynamic-resource-allocation/api/metadata/v1alpha1"
2829
"k8s.io/dynamic-resource-allocation/kubeletplugin"
2930
"k8s.io/klog/v2"
3031
)
@@ -57,6 +58,8 @@ func NewDriver(ctx context.Context, config *Config) (*driver, error) {
5758
kubeletplugin.DriverName(config.flags.driverName),
5859
kubeletplugin.RegistrarDirectoryPath(config.flags.kubeletRegistrarDirectoryPath),
5960
kubeletplugin.PluginDataDirectoryPath(config.DriverPluginPath()),
61+
kubeletplugin.EnableDeviceMetadata(config.flags.enableDeviceMetadata),
62+
kubeletplugin.MetadataVersions(v1alpha1.SchemeGroupVersion),
6063
)
6164
if err != nil {
6265
return nil, err
@@ -107,12 +110,20 @@ func (d *driver) prepareResourceClaim(ctx context.Context, claim *resourceapi.Re
107110
}
108111
var prepared []kubeletplugin.Device
109112
for _, preparedPB := range preparedPBs {
110-
prepared = append(prepared, kubeletplugin.Device{
113+
dev := kubeletplugin.Device{
111114
Requests: preparedPB.GetRequestNames(),
112115
PoolName: preparedPB.GetPoolName(),
113116
DeviceName: preparedPB.GetDeviceName(),
114117
CDIDeviceIDs: preparedPB.GetCdiDeviceIds(),
115-
})
118+
}
119+
if allocDev, ok := d.state.allocatable[preparedPB.GetDeviceName()]; ok && len(allocDev.Attributes) > 0 {
120+
attrs := make(map[string]resourceapi.DeviceAttribute, len(allocDev.Attributes))
121+
for k, v := range allocDev.Attributes {
122+
attrs[string(k)] = v
123+
}
124+
dev.Metadata = &kubeletplugin.DeviceMetadata{Attributes: attrs}
125+
}
126+
prepared = append(prepared, dev)
116127
}
117128

118129
logger.Info("Returning newly prepared devices for claim", "uid", claim.UID, "devices", prepared)

cmd/dra-example-kubeletplugin/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type Flags struct {
5252
healthcheckPort int
5353
profile string
5454
driverName string
55+
enableDeviceMetadata bool
5556
}
5657

5758
type Config struct {
@@ -147,6 +148,13 @@ func newApp() *cli.App {
147148
Destination: &flags.driverName,
148149
EnvVars: []string{"DRIVER_NAME"},
149150
},
151+
&cli.BoolFlag{
152+
Name: "enable-device-metadata",
153+
Usage: "Enable DRA in-container device metadata files for prepared devices.",
154+
Value: false,
155+
Destination: &flags.enableDeviceMetadata,
156+
EnvVars: []string{"ENABLE_DEVICE_METADATA"},
157+
},
150158
}
151159
cliFlags = append(cliFlags, flags.kubeClientConfig.Flags()...)
152160
cliFlags = append(cliFlags, flags.loggingConfig.Flags()...)

common.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
GOLANG_VERSION ?= 1.25.5
15+
GOLANG_VERSION ?= 1.26.0
1616

1717
DRIVER_NAME := dra-example-driver
1818
MODULE := sigs.k8s.io/$(DRIVER_NAME)

deployments/helm/dra-example-driver/templates/kubeletplugin.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ spec:
8484
- name: HEALTHCHECK_PORT
8585
value: {{ .Values.kubeletPlugin.containers.plugin.healthcheckPort | quote }}
8686
{{- end }}
87+
{{- if .Values.kubeletPlugin.enableDeviceMetadata }}
88+
- name: ENABLE_DEVICE_METADATA
89+
value: {{ .Values.kubeletPlugin.enableDeviceMetadata | quote }}
90+
{{- end }}
8791
volumeMounts:
8892
- name: plugins-registry
8993
mountPath: {{ .Values.kubeletPlugin.kubeletRegistrarDirectoryPath | quote }}

deployments/helm/dra-example-driver/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ kubeletPlugin:
4848
affinity: {}
4949
kubeletRegistrarDirectoryPath: /var/lib/kubelet/plugins_registry
5050
kubeletPluginsDirectoryPath: /var/lib/kubelet/plugins
51+
enableDeviceMetadata: false
5152
containers:
5253
init:
5354
securityContext: {}

go.mod

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
module sigs.k8s.io/dra-example-driver
22

3-
go 1.25.0
3+
go 1.26.0
44

55
require (
66
github.com/google/uuid v1.6.0
77
github.com/spf13/pflag v1.0.10
88
github.com/stretchr/testify v1.11.1
99
github.com/urfave/cli/v2 v2.27.7
1010
google.golang.org/grpc v1.80.0
11-
k8s.io/api v0.35.4
12-
k8s.io/apimachinery v0.35.4
13-
k8s.io/client-go v0.35.4
14-
k8s.io/component-base v0.35.4
15-
k8s.io/dynamic-resource-allocation v0.35.4
11+
k8s.io/api v0.36.0-rc.1
12+
k8s.io/apimachinery v0.36.0-rc.1
13+
k8s.io/client-go v0.36.0-rc.1
14+
k8s.io/component-base v0.36.0-rc.1
15+
k8s.io/dynamic-resource-allocation v0.36.0-rc.1
1616
k8s.io/klog/v2 v2.140.0
17-
k8s.io/kubelet v0.35.4
18-
k8s.io/kubernetes v1.35.4
19-
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
17+
k8s.io/kubelet v0.36.0-rc.1
18+
k8s.io/kubernetes v1.36.0-rc.1
19+
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2
2020
tags.cncf.io/container-device-interface v1.1.0
2121
tags.cncf.io/container-device-interface/specs-go v1.1.0
2222
)
@@ -27,7 +27,7 @@ require (
2727
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2828
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
2929
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
30-
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
30+
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
3131
github.com/fsnotify/fsnotify v1.9.0 // indirect
3232
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
3333
github.com/go-logr/logr v1.4.3 // indirect
@@ -36,7 +36,6 @@ require (
3636
github.com/go-openapi/jsonreference v0.20.2 // indirect
3737
github.com/go-openapi/swag v0.23.0 // indirect
3838
github.com/google/gnostic-models v0.7.0 // indirect
39-
github.com/google/go-cmp v0.7.0 // indirect
4039
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4140
github.com/josharian/intern v1.0.0 // indirect
4241
github.com/json-iterator/go v1.1.12 // indirect
@@ -50,34 +49,34 @@ require (
5049
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
5150
github.com/prometheus/client_golang v1.23.2 // indirect
5251
github.com/prometheus/client_model v0.6.2 // indirect
53-
github.com/prometheus/common v0.66.1 // indirect
54-
github.com/prometheus/procfs v0.16.1 // indirect
52+
github.com/prometheus/common v0.67.5 // indirect
53+
github.com/prometheus/procfs v0.19.2 // indirect
5554
github.com/russross/blackfriday/v2 v2.1.0 // indirect
56-
github.com/spf13/cobra v1.10.0 // indirect
55+
github.com/spf13/cobra v1.10.2 // indirect
5756
github.com/x448/float16 v0.8.4 // indirect
5857
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
59-
go.etcd.io/etcd/client/pkg/v3 v3.6.5 // indirect
58+
go.etcd.io/etcd/client/pkg/v3 v3.6.8 // indirect
6059
go.opentelemetry.io/otel v1.41.0 // indirect
6160
go.opentelemetry.io/otel/trace v1.41.0 // indirect
6261
go.uber.org/multierr v1.11.0 // indirect
63-
go.uber.org/zap v1.27.0 // indirect
62+
go.uber.org/zap v1.27.1 // indirect
6463
go.yaml.in/yaml/v2 v2.4.3 // indirect
6564
go.yaml.in/yaml/v3 v3.0.4 // indirect
66-
golang.org/x/mod v0.31.0 // indirect
65+
golang.org/x/mod v0.32.0 // indirect
6766
golang.org/x/net v0.49.0 // indirect
6867
golang.org/x/oauth2 v0.34.0 // indirect
6968
golang.org/x/sys v0.40.0 // indirect
7069
golang.org/x/term v0.39.0 // indirect
7170
golang.org/x/text v0.33.0 // indirect
72-
golang.org/x/time v0.9.0 // indirect
73-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516 // indirect
74-
google.golang.org/protobuf v1.36.11 // indirect
71+
golang.org/x/time v0.14.0 // indirect
72+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
73+
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect
7574
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
7675
gopkg.in/inf.v0 v0.9.1 // indirect
7776
gopkg.in/yaml.v3 v3.0.1 // indirect
78-
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
77+
k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect
7978
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
8079
sigs.k8s.io/randfill v1.0.0 // indirect
81-
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
80+
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
8281
sigs.k8s.io/yaml v1.6.0 // indirect
8382
)

0 commit comments

Comments
 (0)