Skip to content

feat(checkpoint)!: checkpoint v2 with driver extensions - #8

Open
fishmans-agent wants to merge 9 commits into
Project-HAMi:masterfrom
fishing-agents:checkpoint-v2
Open

fishmans-agent wants to merge 9 commits into
Project-HAMi:masterfrom
fishing-agents:checkpoint-v2

Conversation

@fishmans-agent

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds checkpoint API v2 and makes the store generic over a driver extension.

  • Core v2 (api/checkpoint/v2): only fields backed by DRA KEPs 4381, 4817, 5075 and 5304: claims with status and prepare state (PrepareStarted, PrepareCompleted, PrepareAborted, abortedAt), the kubelet device reference with shareID and metadata, CDI container edits, and nodeBootID.
  • Driver extensions: driver-only state (partitions, AMD and NVIDIA sections) moves out of the core into typed payloads at node, claim and device level. Store[N, C, D] takes an Extension with a name, its own schema version, a codec per level (JSONCodec by default), forward-only migrations, optional legacy readers and an optional Validate. A store without an extension keeps only the core.
  • Forward-only reading: v1 files are read and converted (v2.ConvertFromV1): the vendor sections become payloads of extension version 1, keeping their v1 JSON. The next write is v2; nothing writes v1 again. A newer core or extension version, another extension, or payloads the store cannot decode are refused, and the file is left alone.
  • Legacy files: an extension's own legacy readers run before the built-in one. VerifyLegacyChecksums is exported for them.
  • Testing helpers: checkpointtest.FuzzExtension lets drivers fuzz their codecs, migrations and legacy readers from their own fixtures. A v1 fixture pins the v1 → v2 conversion.

Needed for kubernetes-sigs/dra-driver-nvidia-gpu#1666. Supersedes #3.

Which issue(s) this PR fixes:
None.

Special notes for your reviewer:

  • 9 commits, one concern each. The first three are the content of feat(checkpoint): hold the dra-driver-nvidia-gpu kubelet plugin state #3 (NVIDIA GPU and ComputeDomain state, aborted claims); the rest add v2, the v1 → v2 conversion, the generic store, the fuzz helper, docs, and the exported checksum check.
  • Strict decoding is left off (Strict: false, and JSONCodec ignores unknown fields), pending a benchmark. Newer schemas are still refused by the version checks.
  • Release v0.2.0 after merge; the drivers then bump to it.

Does this PR introduce a user-facing change?:

Checkpoint API v2 with typed driver extensions. The store is generic (`NewStore[N, C, D]`) and writes v2; v1 files are read and converted, and the next write is v2. Breaking: `NewStore`, `Options`, `Read`, `Write` and `Update` change signature.

AI Disclosure: Prepared with an AI assistant, reviewed by me.

The GPU kubelet plugin of dra-driver-nvidia-gpu persists more than v1
could hold: per group timeSliceApplied and mpsApplied (unset means the
checkpoint predates them), the PCI bus ID of vfio devices and of the
parent of a MIG device, and the ShareID and Metadata of the kubelet
device. Add them to the v1 types and read them from the legacy format.

Tests read checkpoints written by the plugin's checkpointmanager code,
in the V1+V2 and V1-only layouts.

Signed-off-by: Reza Jelveh <fishmangit@dynamia.ai>
The ComputeDomain kubelet plugin of dra-driver-nvidia-gpu persists the
IMEX channel and daemon devices with their IDs, the ComputeDomain and
config type of each group, and PrepareAborted claims with the time they
were aborted. Add them to the v1 types.

Read all three layouts the plugin ever wrote: V1+V2, V1 only, and the
25.3.0-rc.2 one, whose v1 claims are lists of device groups with the
kubelet proto device. Tests read checkpoints written by the plugin's
checkpointmanager code.

Signed-off-by: Reza Jelveh <fishmangit@dynamia.ai>
Signed-off-by: Reza Jelveh <fishmangit@dynamia.ai>
v2 is the core checkpoint the store will write: claims by UID with their
status and Prepare/Unprepare lifecycle, the kubelet device reference, CDI
container edits (KEP 4381), ShareID (5075) and device metadata with its
attributes (5304) and network data (4817). Every core field maps to a KEP
of the set; apiVersion, driverName and the extension reference are the
envelope.

Driver-only state is not part of the core. A driver extension stores it as
opaque JSON payloads at node, claim and device level, named and versioned
by ExtensionRef. The payloads are runtime.RawExtension, so the generated
deepcopy needs no driver code.

Register v2 next to v1 in the scheme and generate its deepcopy.

Signed-off-by: Reza Jelveh <fishmangit@dynamia.ai>
ConvertFromV1 keeps the core fields and moves the vendor sections of v1,
which have no KEP, verbatim into the driver payloads with their v1 JSON
keys: the node gets {"partitioning"}, a claim {"nvidia"}, a device
{"partition", "amd", "nvidia"}. That shape is version 1 of every driver
extension, so v1 files from dra-lib v0.1.0 convert without loss. Empty
sections give no payload; a v1 file without vendor state converts to a
core-only v2 checkpoint.

v1 stays decode-only; nothing writes it again.

Signed-off-by: Reza Jelveh <fishmangit@dynamia.ai>
@hami-robot

hami-robot Bot commented Dec 2, 2026

Copy link
Copy Markdown

@fishmans-agent: The label(s) kind/feature cannot be applied, because the repository doesn't have them.

Details

In response to this:

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds checkpoint API v2 and makes the store generic over a driver extension.

  • Core v2 (api/checkpoint/v2): only fields backed by DRA KEPs 4381, 4817, 5075 and 5304: claims with status and prepare state (PrepareStarted, PrepareCompleted, PrepareAborted, abortedAt), the kubelet device reference with shareID and metadata, CDI container edits, and nodeBootID.
  • Driver extensions: driver-only state (partitions, AMD and NVIDIA sections) moves out of the core into typed payloads at node, claim and device level. Store[N, C, D] takes an Extension with a name, its own schema version, a codec per level (JSONCodec by default), forward-only migrations, optional legacy readers and an optional Validate. A store without an extension keeps only the core.
  • Forward-only reading: v1 files are read and converted (v2.ConvertFromV1): the vendor sections become payloads of extension version 1, keeping their v1 JSON. The next write is v2; nothing writes v1 again. A newer core or extension version, another extension, or payloads the store cannot decode are refused, and the file is left alone.
  • Legacy files: an extension's own legacy readers run before the built-in one. VerifyLegacyChecksums is exported for them.
  • Testing helpers: checkpointtest.FuzzExtension lets drivers fuzz their codecs, migrations and legacy readers from their own fixtures. A v1 fixture pins the v1 → v2 conversion.

Needed for kubernetes-sigs/dra-driver-nvidia-gpu#1666. Supersedes #3.

Which issue(s) this PR fixes:
None.

Special notes for your reviewer:

  • 9 commits, one concern each. The first three are the content of feat(checkpoint): hold the dra-driver-nvidia-gpu kubelet plugin state #3 (NVIDIA GPU and ComputeDomain state, aborted claims); the rest add v2, the v1 → v2 conversion, the generic store, the fuzz helper, docs, and the exported checksum check.
  • Strict decoding is left off (Strict: false, and JSONCodec ignores unknown fields), pending a benchmark. Newer schemas are still refused by the version checks.
  • Release v0.2.0 after merge; the drivers then bump to it.

Does this PR introduce a user-facing change?:

Checkpoint API v2 with typed driver extensions. The store is generic (`NewStore[N, C, D]`) and writes v2; v1 files are read and converted, and the next write is v2. Breaking: `NewStore`, `Options`, `Read`, `Write` and `Update` change signature.

AI Disclosure: Prepared with an AI assistant, reviewed by me.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hami-robot
hami-robot Bot requested a review from fishman December 2, 2026 17:49
@hami-robot

hami-robot Bot commented Dec 2, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fishmans-agent
Once this PR has been reviewed and has the lgtm label, please assign fishman for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7694939-86ad-484d-b56c-d3ce3bbf4406
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

The store now writes api/checkpoint/v2 and is generic over a driver
extension: Store[N, C, D] keeps the KEP-set core plus the driver's typed
node, claim and device state. The extension, passed in Options at store
creation, has a name, its own schema version, a Codec per level
(JSONCodec is the default), forward-only migrations, optional legacy
readers and an optional Validate. Payloads are stored per level, so a
claim's driver state is dropped with its core claim. A store without an
extension (None types) keeps only the core.

Reading is forward-only: a v1 file is converted with ConvertFromV1, its
vendor sections becoming payloads of extension version 1, and the
migrations bring them to the extension's version; the next Write writes
v2. Legacy checkpointmanager files go through the extension's legacy
readers first, then the built-in reader through v1. Anything the store
cannot read completely is refused and the file left alone: an unknown core
version, a newer extension version, another extension, payloads without an
extension reference or in a core-only store, a payload at a level without
a codec, duplicate claim UIDs.

testdata/v2-from-v1-checkpoint.json pins what the v1 fixture is written as.
The fuzz targets and benchmarks move to v2; FuzzDecodeV1 is FuzzDecode,
reading both versions. Decoding stays non-strict.

BREAKING CHANGE: NewStore, Options, Read, Write and Update are generic and
return or take a Checkpoint[N, C, D] with the v2 core.

Signed-off-by: Reza Jelveh <fishmangit@dynamia.ai>
checkpointtest.FuzzExtension fuzzes a driver's Extension from its own
fixtures: each codec must not panic and must round-trip what it decodes,
the migrations from every older version must not panic and must keep the
number of device payloads, and the legacy readers must not panic and must
return state the codecs encode and round-trip.

FuzzTestExtension runs it on an example extension with a migration and a
legacy reader; CI fuzzes it like the store targets.

Signed-off-by: Reza Jelveh <fishmangit@dynamia.ai>
Changelog, README and the v1 package doc describe the v2 core, the typed
driver extension, the forward-only reading of v1 files and the
checkpointtest helper. Strict decoding stays off and is noted as an open
question.

Signed-off-by: Reza Jelveh <fishmangit@dynamia.ai>
Drivers move their checkpointmanager layouts into Extension.Legacy. The
checksum check is shared, so dra-lib exports it instead of each driver
copying it.

Signed-off-by: Reza Jelveh <fishmangit@dynamia.ai>
@fishman

fishman commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@FouoF @moezdil I feel like the previous version might have been merged a bit prematurely. @archlitchi pointed me to the upstream nvidia driver which made me reconsider the checkpoint a bit. I versioned it at v2 because we already merged it in the other repos, but since they are not yet released i could leave it at v1 and skip the migration. fundamentally, currently driver specific state lives in the dra-lib which means other driver extensions influence the dra-lib releases which is not something we want.

@fishman

fishman commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@Shouren i address the issues needed for upstream nvidia dra here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants