You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
driver: restore the allocation checkpoint on startup - #401
#367 writes the allocation checkpoint but nothing reads it. So after a driver restart the first Synchronize still rebuilds prepared claims from container env + CDI, and a claim that was unprepared before the restart can come back if the runtime still has its env and CDI spec around.
This wires the load in:
New loads the checkpoint right after creating the allocation state, before the DRA and NRI plugins start. If it can't be loaded (corrupt, other node, other topology) the driver fails to start instead of guessing.
If a checkpoint was restored, the first Synchronize uses the same rules a warm one already does: the checkpoint is the source of truth for prepared claims. Env can't re-prepare a claim that isn't in it, and prepared claims without a running container stay reserved until Unprepare.
No usable checkpoint (first start, upgrade, or one from a previous boot) keeps today's behavior: rebuild from env.
LoadState now returns whether it restored something, so the driver can tell "no checkpoint" from "empty checkpoint". An empty checkpoint means nothing is prepared, a missing one means we don't know.
The driver now restores its allocation state checkpoint on startup and uses it to recover prepared claims after a restart. A checkpoint that can't be loaded makes the driver fail to start.
AI usage disclosure
YES. An AI assistant helped draft the tests and this description; I reviewed and tested the changes.
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The driver now loads allocation checkpoints during construction. The first synchronization uses restored prepared-claim state as trusted state. Documentation and tests describe checkpoint loading, restoration status, and synchronization behavior.
Changes: Allocation checkpoint restoration
Layer / File(s)
Summary
Checkpoint restoration status pkg/store/allocation_state_checkpoint.go, pkg/store/allocation_state_checkpoint_test.go
LoadState returns whether it restored state. Tests check this result for successful loads, missing checkpoints, and checkpoints from another boot.
New loads allocation state and returns an error if loading fails. Driver tests cover restored state and corrupted checkpoint data.
First synchronization with restored state pkg/driver/nri_hooks.go, pkg/driver/checkpoint_restore_test.go, docs/dev/persistence.md, docs/user/configuration.md
Synchronization trusts prepared claims after restoration. Tests and documentation describe the first synchronization and checkpoint startup behavior.
sequenceDiagram
participant CPUDriver
participant AllocationState
participant Synchronize
participant RuntimeCDIAndEnvironment
CPUDriver->>AllocationState: LoadState from checkpoint
AllocationState-->>CPUDriver: restored status or load error
CPUDriver->>Synchronize: use restored status on first synchronization
Synchronize->>RuntimeCDIAndEnvironment: inspect runtime claim data
Synchronize-->>Synchronize: trust restored prepared claims
kubernetes-sigs/dra-driver-cpu#367: This PR builds on the checkpoint format and loading logic introduced there by loading the checkpoint during driver startup and using restored state during synchronization.
Merge Risk: Minimal · previous review a78d7
The driver now restores its allocation checkpoint at startup, so a claim that was unprepared before a restart is not re-prepared from stale container state. A corrupt or mismatched checkpoint now stops startup, which is documented. No concrete defect was found, and merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the driver now loads the allocation checkpoint during startup (in New). The raw summary shows CPUDriver.New loading the checkpoint, LoadState reporting restoration, Sy…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title names the main change: the driver now loads the allocation checkpoint during startup (in New). The raw summary shows CPUDriver.New loading the checkpoint, LoadState reporting restoration, Synchronize trusting restored prepared state, and tests for restart restoration. The title matches the PR objective. It is short, specific, and uses the repository's scope-prefix style ('driver:').
Reviewing files that changed from the base of the PR and between 3df2de3 and a78d758.
Files selected for processing: 7
docs/dev/persistence.md
docs/user/configuration.md
pkg/driver/checkpoint_restore_test.go
pkg/driver/driver.go
pkg/driver/nri_hooks.go
pkg/store/allocation_state_checkpoint.go
pkg/store/allocation_state_checkpoint_test.go
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
I am pretending that if someone changes the reserved CPU to overlap with the prepared declaration, it will now cause the New to fail ("CPU exceeds available set"), so the pod crash loop and kubelet cannot undo any preparation on that node. Is this the expected result? Should we keep this abnormal operational behavior that leads to blocking
The reason will be displayed to describe this comment to others. Learn more.
This is a very good point. For now I'd implement the simplistic solution - crashloop and brick the node. But we should file a followup issue, discuss it deeply and reach (and document) a consensus before 0.4.0. (reaching a consensus and documenting it should be a blocker for 0.4.0).
I think an appealing alternative would be to degrade the driver state and allow only Unprepare of the conflicting allocations, until there are conflicting allocations. While this seems an interesting way forward, how would the driver advertise its degraded state? can we (ab) use the DRA health mechanism to detect and report this state? how well would this work in practice? this is why I'd defer to a targeted conversation this topic.
The reason will be displayed to describe this comment to others. Learn more.
With a restored checkpoint, a single owned claim whose CDI spec is gone now fails the first Synchronize after restart, while before it was just skipped. #258 said one bad container shouldn’t block recovery for the whole node. Do we want to keep the warm-path behavior here, or skip and report it?
The reason will be displayed to describe this comment to others. Learn more.
log them is the bare minimum but once again we should surface this information somehow, preferably using kubernetes objects. Again unfortunately I don't have a good solution atm. Worth another separate issue.
[EDIT] I managed to answer to everything but your actual question, sorry about that. Re: I think skipping and continuing recovery is the best (less worst?) thing we can do now. THis will need tightening though, as it is likely to create an inconsistent state.
The reason will be displayed to describe this comment to others. Learn more.
Done!it now skips and keeps going. I applied it to the warm path too, since that hard failure came from #360 and pravk03’s concern there was the same one. A skipped container ends up treated as shared while its checkpointed CPUs stay reserved, so that’s the inconsistency you mentioned. I’ll put the tightening and the “surface it via k8s objects” part in a follow-up issue. The no-checkpoint path still fails on these, since env is the only record there.
The reason will be displayed to describe this comment to others. Learn more.
overall LGTM with some minor nits and a couple more tests I'd like to add.
The points you raised are very good and I think do deserve separate and careful evaluation. Resolution (whatever it is) of them should be a blocker for 0.4.0
The reason will be displayed to describe this comment to others. Learn more.
Actually not. This is what we do in practice today with kubelet, and it's another bad habit leaking. We would need a more precise treatment. E.g, recommendation by failure type. Reserved CPUs for example deserves a separate treatment than generic checkpoint file corruption. Probably better to defer this elaboration to another followup
The reason will be displayed to describe this comment to others. Learn more.
This is a very good point. For now I'd implement the simplistic solution - crashloop and brick the node. But we should file a followup issue, discuss it deeply and reach (and document) a consensus before 0.4.0. (reaching a consensus and documenting it should be a blocker for 0.4.0).
I think an appealing alternative would be to degrade the driver state and allow only Unprepare of the conflicting allocations, until there are conflicting allocations. While this seems an interesting way forward, how would the driver advertise its degraded state? can we (ab) use the DRA health mechanism to detect and report this state? how well would this work in practice? this is why I'd defer to a targeted conversation this topic.
The reason will be displayed to describe this comment to others. Learn more.
log them is the bare minimum but once again we should surface this information somehow, preferably using kubernetes objects. Again unfortunately I don't have a good solution atm. Worth another separate issue.
[EDIT] I managed to answer to everything but your actual question, sorry about that. Re: I think skipping and continuing recovery is the best (less worst?) thing we can do now. THis will need tightening though, as it is likely to create an inconsistent state.
The reason will be displayed to describe this comment to others. Learn more.
Do we have a test which reproduces an (hopefully) impossible scenario: runtime data (CDI, env) consistent but disagreeing with the checkpointed data? This test would also document and embody our current expectations in this case.
I'm thinking about the very important edge (as in hopefully rare) cases emerged from this PR and your self-review @AutuSnow . I think as starting point a fail-close behavior is a good step forward and it delivers incremental improvement. I'm inclined to track the hard questions emerged here into separate issues and block 0.4.0 on resolution+documentation of these.
We may decide to tolerate some risks (like the kubelet does) but we need to carefully evaluate them anyway.
kubernetes-sigs#367 writes the allocation state checkpoint but nothing reads it back,
so after a driver restart the first Synchronize rebuilds prepared claims
from container env and CDI specs. That lets stale runtime state bring
back a claim that was unprepared before the restart.
Load the checkpoint in New, before the DRA and NRI plugins start, and
fail to start if it can't be loaded. When it was restored, the first
Synchronize applies the same rules as a warm one: the checkpoint is the
source of truth for prepared claims, so runtime env can't re-prepare a
claim missing from it, and prepared claims with no running container
stay reserved. Without a usable checkpoint (first start, upgrade, or a
checkpoint from a previous boot) Synchronize keeps rebuilding from env.
When the prepared claims are known (restored checkpoint or an earlier
Synchronize), a container whose runtime state disagrees with them is
logged and skipped instead of failing the whole Synchronize: missing
CDI, env/CDI mismatch, different CPUs or a different owner. The
prepared allocation and owner win, and the container is tracked as
shared. Without a checkpoint the env is the only record, so those
errors still fail recovery there.
LoadState now reports whether a checkpoint was restored, so the driver
can tell "no checkpoint" from "empty checkpoint".
Refs kubernetes-sigs#258
* [Decide how the driver handles a checkpoint it can't load #402](https://github.com/kubernetes-sigs/dra-driver-cpu/issues/402): decide how the driver handles a checkpoint it can't load
* [Document remediation for checkpoint load failures, per failure type #403](https://github.com/kubernetes-sigs/dra-driver-cpu/issues/403): document remediation for each load-failure type (depends on [Decide how the driver handles a checkpoint it can't load #402](https://github.com/kubernetes-sigs/dra-driver-cpu/issues/402))
* [Surface and tighten claims skipped during Synchronize #404](https://github.com/kubernetes-sigs/dra-driver-cpu/issues/404): surface and tighten claims skipped during Synchronize
The reason will be displayed to describe this comment to others. Learn more.
/approve
/lgtm
thanks for addressing my comments. It seems good enough to move forward and close #258. Let's move on towards the 3 thorny and interesting issues raised during the review of this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
approvedIndicates a PR has been approved by an approver from all required OWNERS files.cncf-cla: yesIndicates the PR's author has signed the CNCF CLA.kind/featureCategorizes issue or PR as related to a new feature.lgtm"Looks good to me", indicates that a PR is ready to be merged.size/LDenotes a PR that changes 100-499 lines, ignoring generated files.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind feature
What this PR does / why we need it
#367 writes the allocation checkpoint but nothing reads it. So after a driver restart the first
Synchronizestill rebuilds prepared claims from container env + CDI, and a claim that was unprepared before the restart can come back if the runtime still has its env and CDI spec around.This wires the load in:
Newloads the checkpoint right after creating the allocation state, before the DRA and NRI plugins start. If it can't be loaded (corrupt, other node, other topology) the driver fails to start instead of guessing.Synchronizeuses the same rules a warm one already does: the checkpoint is the source of truth for prepared claims. Env can't re-prepare a claim that isn't in it, and prepared claims without a running container stay reserved until Unprepare.LoadStatenow returns whether it restored something, so the driver can tell "no checkpoint" from "empty checkpoint". An empty checkpoint means nothing is prepared, a missing one means we don't know.Which issue(s) this PR is related to
Refs #258
Special notes for reviewers
Release note
AI usage disclosure
YES. An AI assistant helped draft the tests and this description; I reviewed and tested the changes.