fix: add wait to image creation#137
Conversation
|
Hi @anurag5sh @anshulsharma-hashicorp @JenGoldstrich Would it be possible for someone in the team to review this PR? Or let me know if I need to do something else? It would be great for my team if we could get this feature added. Thanks |
|
HI @kvliangdev Thanks |
There was a problem hiding this comment.
Pull request overview
This PR introduces a configurable delay after an OpenStack image transitions to active, intended to mitigate a race condition where the source VM (and resulting image) may be deleted before backend image creation has fully settled (as described in issue #37).
Changes:
- Add a new builder option
image_creation_waitto delay (in practice, seconds) after the image becomesactive. - Thread the new config value into the image-wait logic and apply the delay during
WaitForImage. - Document the new configuration option in the generated RunConfig docs partial.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| docs-partials/builder/openstack/RunConfig-not-required.mdx | Documents the new image_creation_wait option. |
| builder/openstack/step_create_image.go | Passes the new config into WaitForImage and adds a post-active delay. |
| builder/openstack/run_config.go | Adds ImageCreationWait to RunConfig for configuration/decoding. |
| builder/openstack/builder.hcl2spec.go | Extends HCL2 schema/flat config to support image_creation_wait. |
Files not reviewed (1)
- builder/openstack/builder.hcl2spec.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if imageCreationWait > 0 { | ||
| log.Printf("Additional wait (%d seconds) after image status has changed to active...", imageCreationWait) | ||
| time.Sleep(time.Duration(imageCreationWait) * time.Second) | ||
| } |
| // Delay to apply once image has been marked as `active` to ensure Openstack has had time | ||
| // to finish creating the image. | ||
| ImageCreationWait int `mapstructure:"image_creation_wait" required:"false"` |
| - `image_creation_wait` (int) - Delay to apply once image has been marked as `active` to ensure Openstack has had time | ||
| to finish creating the image. |
Description
In our OpenStack environment we had issues where the image that was being built by this plugin was deleted by the end of the process. A colleague narrowed the issue down to the possibility that image hadn't completely finished saving when packer had received the notification that it had saved which caused the VM to be deleted and also the image to be deleted too.
This PR adds a configurable wait to the image saving process in order to allow the underlying processes to finish. In our testing 5 seconds is enough for the image to be saved correctly.
Resolved Issues
If your PR resolves any open issue(s), please indicate them like this so they will be closed when your PR is merged:
Closes #37