Repository navigation
fix(kms): clear measurement cache entries by their .json file name - #1471
Merged
Merged
Conversation
Signed-off-by: Leechael Yim <yanleech@gmail.com>
Leechael
force-pushed
the
fix/kms-clear-measurement-cache
branch
from
October 24, 2026 06:16
bc21e19 to
25655b5
Compare
The image and measurement cache layout is owned by CvmVerifier, so move cache clearing there and drop the exported MEASUREMENT_CACHE_SUFFIX. KMS no longer hard-codes the images/ and measurements/ paths, which is how the .json suffix got out of sync in the first place. Signed-off-by: Kevin Wang <wy721@qq.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Admin.ClearImageCachewith a specificconfig_hashreturns success but deletes nothing.The verifier stores measurement cache entries as
measurements/<key>.json(CvmVerifier::measurement_cache_path), butKmsState::clear_image_cacheremovesmeasurements/<config_hash>, without the suffix.remove_cachefinds neither a dir nor a file at that path and returnsOk(()). Passing<key>.jsonas the key does not work either, because the key must be pure hex.So only
config_hash = "all"actually clears measurements. Clearing one image with{"image_hash": "<hash>", "config_hash": "<key>"}leaves its cached MRs behind, and the next legacy TDX verification re-downloads the image but reuses the stale measurements. The mismatch has existed since the measurement cache moved to<key>.jsonfiles (already the case in v0.5.6).Fix
Cache clearing moves into
CvmVerifier::clear_cache, which owns the cache layout and builds paths withimages_dir()andmeasurement_cache_path().KmsState::clear_image_cachenow just delegates to it, so KMS no longer hard-codesimages/,measurements/, or the.jsonsuffix. The hex-key guard, the empty-key no-op, and the"all"behavior are unchanged.Verification
Run in
rust:1.92-bookworm(sev-snp-attestdoes not build on macOS):clear_cache_only_deletes_the_named_entries(verifier) covers named, empty, non-hex, and"all"keys for both caches.cargo test -p dstack-kms: 57 passed.cargo test -p dstack-verifier --lib: 40 passed.cargo clippy -p dstack-kms -p dstack-verifier -- -D warnings --allow unused_variables: clean.cargo fmt --all --check: clean.Not covered: a live
ClearImageCachecall against a running KMS.