Where the applied config comes from
Prepare turns several inputs into one stored DeviceConfig. On a conflict, your config wins, then the provider config, then the profile. A later stage only fills fields that are not set and adds list entries.
-
Pick one opaque config
From
dra_hooks.go:241status.allocation.devices.config, keep entries for driverdra.netthat match the request. Kubernetes lists DeviceClass entries before claim entries. The first non-empty entry is used, and later entries are not read. An invalid entry before it fails the claim. -
Merge onto the provider config
The provider config is the base. User values win for single fields. Lists are appended and de-duplicated with the user entry kept. Routes are keyed by destination and table.
config_merge.go:30 -
Resolve the profile
If the result names a
dra_hooks.go:772profile, the profile provider (cloud or webhook) returns more config. It fills fields that are still not set and adds list entries. Without a profile provider, the inventory drops a profile that the cloud provider advertised. -
Validate again
Provider and profile output is external input. The merged result is defaulted and validated before use. A failure releases the profile, so a retry cannot leak it.
dra_hooks.go:786 -
Add the host snapshot
Host addresses, routes, rules, permanent neighbors, and RDMA device files are added. Then the DeviceConfig is saved for the Pod and device.
dra_hooks.go:381
Passthrough or IPvlan child
The interface.type field picks one of two attach models. Passthrough is the default. The OKE provider selects IPVLAN for Ethernet RDMA NICs.
| Passthrough | IPvlan child (type: IPVLAN) | |
|---|---|---|
| Host interface while the Pod runs | Gone from the host | Stays on the host with its address |
| Pod addresses | Host global addresses copied, or set in config, or DHCP | Set in config or by a profile, or addressing: Unnumbered |
| Routes and rules | Host routes of that interface and their table rules are copied | Only from config or a profile |
| MTU and MAC | Both can be set. A VF MTU cannot exceed its PF. | MTU up to the parent MTU. MAC is the parent MAC and cannot be set. |
| RDMA namespace mode | Shared or exclusive | Shared only, when the parent has an RDMA device |
| On Pod stop | Moved back under its host name and set up. dranet does not restore the host addresses. | Child deleted |
| Code | nsAttachNetdev | addIPVlan |
RDMA modes
The RDMA subsystem has a network namespace mode for the whole node. dranet reads it once at start (rdma system show prints it). If the read fails, dranet assumes shared mode.
Shared (ib_core netns_mode=1) | Exclusive (netns_mode=0) | |
|---|---|---|
Device files (rdma_cm, uverbsN, and umadN, issmN, ucmN when present) | Added to every container of the Pod | Added to every container of the Pod |
| Netdev | Moved (passthrough) or IPvlan child | Moved (passthrough). IPvlan claims fail at Prepare. |
RDMA link device (mlx5_N) | Stays on the host, shared by all namespaces | Moved into the Pod. On stop it returns before the netdev. |
| RDMA-only device (no netdev) | Device files only. Condition Ready (RDMAOnlyDeviceReady). | RDMA link moved. Conditions RDMALinkReady and Ready. |
| Code | runPodSandbox blocks 2 and 3 · IPvlan check in prepareDevice | |
Restart and shutdown
After a restart
- The bbolt file reloads every stored device config. Netns paths are not stored.
Synchronizegets them again from the runtime. - Prepare is idempotent. A device already stored for the Pod is reused, so a second profile allocation cannot leak.
- NRI hooks must be idempotent too. The runtime can retry a Pod start many times, and each retry calls the hooks again.
- A save goes to bbolt before memory. If the disk write fails, Prepare fails and memory does not change.
Graceful stop
- Stop the kubelet plugin. No new Prepare calls arrive.
- Wait until each prepared Pod has had no NRI activity for 10 s. Poll every 5 s. Give up after 5 min. The Pod termination grace period (30 s by default) usually ends first.
- Cancel the context and stop the NRI plugin.
This order stops a Pod from starting without its devices when dranet is upgraded while Pods are being created.
Code map
| Package | What it does | Start reading at |
|---|---|---|
cmd/dranet | Process wiring: flags, health server, store, filter, providers, driver start | main app.go:101 |
pkg/driver | DRA hooks, NRI hooks, netns moves, L3 config (routes, rules, VRF, neighbors), ethtool, eBPF, DHCP, PodConfigStore | prepareDevice dra_hooks.go:230runPodSandbox nri_hooks.go:147 |
pkg/inventory | Device discovery, attributes, rescan loop, provider calls | scan db.go:214 |
pkg/apis | NetworkConfig types, defaults, validation, merge | NetworkConfig types.go:21 |
pkg/cloudprovider | Provider interfaces, detection, and the GCE, AWS, Azure, Alibaba, CoreWeave, OKE, and webhook providers | CloudInstance cloud.go:35 |
pkg/filter | CEL filter applied at publish time | FilterDevices filter.go:27 |
pkg/names | Device names from PCI addresses and interface names | NormalizePCIAddress names.go:60 |
internal/nlwrap | netlink wrapper from moby that retries interrupted dumps | retryOnIntr netlink.go:75 |