fix: prevent model re-download of cached models after helm upgrade#203
Merged
fix: prevent model re-download of cached models after helm upgrade#203
Conversation
) Add early return when model status is already Ready and the cached file exists on disk, avoiding unnecessary status updates that trigger re-reconcile loops. Rewrite downloadModel and copyLocalModel to use atomic temp-file-then-rename writes so a crash mid-download never leaves a partial file at the final path. Validate HTTP Content-Length against received bytes to detect truncated downloads. Signed-off-by: Christopher Maher <chris@defilan.com> Signed-off-by: Christopher Maher <chris@mahercode.io>
Signed-off-by: Christopher Maher <chris@defilan.com> Signed-off-by: Christopher Maher <chris@mahercode.io>
Add an e2e test that restarts the controller after a model reaches Ready, then verifies no re-download occurs by checking controller logs for the early-return cache-hit path. Signed-off-by: Christopher Maher <chris@mahercode.io>
3aafc85 to
353855c
Compare
The Kind cluster uses emptyDir for model cache, so the file is lost on pod restart. Update the test to verify the controller detects the missing file and re-downloads cleanly, returning the model to Ready. Signed-off-by: Christopher Maher <chris@mahercode.io>
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.
Summary
Fixes #193 — After
helm upgrade, the model controller re-downloads cached models despite them existing in the PVC.Readyand the file exists on disk, return immediately without updating status, preventing reconcile-loop storms after restartsdownloadModel()andcopyLocalModel()now write to a temp file thenos.Renameto the final path, so a crash mid-download never leaves a partial file thatos.Statwould later find and mark ReadyContent-Length, catching truncated downloadsTest plan
make test— 132/132 specs pass (4 new)make vet && make fmt— cleanmake test-e2e)