-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: cache: serialize legacy import field #603
fix: cache: serialize legacy import field #603
Conversation
Fixes project-stacker#592 by serializing the `wasLegacyImport` field to ensure that the cache records the correct value when an image has it set. Includes a test based on Serge's description in project-stacker#592. The symptom is an error "cache miss because layer definition was changed" when the definition could not have changed since build. This happens during multi file builds in builds with dependencies, and in build-then-publish flows, where the build will be fine but the publish will fail with the same error. Using `--debug` to show the cache mismatch shows that somewhere along the line, the layer is being serialized with the wrong default value when writing to the cache. Needs to change currentCacheVersion to ensure compatibility, see the TestCacheEntryChanged function comment for more info. Signed-off-by: Michael McCracken <mikmccra@cisco.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #603 +/- ##
==========================================
+ Coverage 57.38% 57.44% +0.06%
==========================================
Files 64 65 +1
Lines 7566 7706 +140
==========================================
+ Hits 4342 4427 +85
- Misses 2481 2522 +41
- Partials 743 757 +14 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Some clarification, in part because I wasn't sure until after this was merged, why the field needed to be serialized to fix the build case - it doesn't: There are two ways this ends up failing: for the single multi file run of To fix this we only need to make it an exported field. In the It might be worth having a publish test case that also exercises this- I'll look into it. |
My clarification was wrong yesterday. The behavior of copying in go structs with non-exported values is not quite that crazy - there are still some sharp edges there but if you just assign a struct, you will get the identical contents. My confusion was that I didn't realize that stacker re-read the cache from disk in between files of multi-file builds. So in fact adding the serialization annotation itself is the fix in both cases - and we have to make the field exported to serialize it. So the fix here is correct and minimal, and as a bonus now I can explain it correctly. |
Fixes #592 by serializing the
wasLegacyImport
field to ensure that the cache records the correct value when an image has it set.Includes a test based on Serge's description in #592.
The symptom is an error "cache miss because layer definition was changed" when the definition could not have changed since build. This happens during multi file builds in builds with dependencies, and in build-then-publish flows, where the build will be fine but the publish will fail with the same error.
Using
--debug
to show the cache mismatch shows that somewhere along the line, the layer is being serialized with the wrong default value when writing to the cache.Needs to change currentCacheVersion to ensure compatibility, see the TestCacheEntryChanged function comment for more info.