feat(packer): restore packer-manifest.json state across blueprint regenerations#5847
feat(packer): restore packer-manifest.json state across blueprint regenerations#5847kadupoornima wants to merge 2 commits into
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where Packer image state was lost during blueprint regeneration, causing unnecessary and time-consuming rebuilds. By implementing the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request implements the restoration of packer-manifest.json files from previous deployment groups in PackerWriter.restoreState and adds a corresponding unit test. The review feedback points out that checking err == nil on os.Stat silently ignores unexpected system errors (like permission issues); it suggests explicitly checking for os.ErrNotExist to skip restoration and returning other errors.
Implement State Restoration for Packer Images (
restoreState)The Problem
The
moduleWriterinterface defines arestoreStatemethod, which is intended to transfer state files from a previous deployment run when a user regenerates their blueprint (preventing state loss).While
TFWriter.restoreStateis fully implemented and restores.tfstateand.tfstate.backupfiles,PackerWriter.restoreStateis currently a no-op:When a user modifies their blueprint and runs
ghpc createagain, the toolkit rewrites the deployment directories. Because Packer's state (packer-manifest.json, which tracks built image IDs) is not restored, the toolkit loses track of the images built in the previous run. This forces the toolkit to rebuild the Packer images from scratch, even if their configuration did not change.The Solution
Implement
PackerWriter.restoreStateto copy thepacker-manifest.jsonfile from the backup directory (.ghpc/previous_system/or equivalent) into the newly generated Packer deployment directory.The Impact