Skip to content

fix: add wait to image creation#137

Open
michaelw777 wants to merge 1 commit into
hashicorp:mainfrom
michaelw777:fix-add-wait-to-image-creation
Open

fix: add wait to image creation#137
michaelw777 wants to merge 1 commit into
hashicorp:mainfrom
michaelw777:fix-add-wait-to-image-creation

Conversation

@michaelw777

@michaelw777 michaelw777 commented Jun 25, 2025

Copy link
Copy Markdown

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

@michaelw777 michaelw777 requested a review from a team as a code owner June 25, 2025 16:38
@hashicorp-cla-app

hashicorp-cla-app Bot commented Jun 25, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@michaelw777

Copy link
Copy Markdown
Author

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

@michaelw777

Copy link
Copy Markdown
Author

HI @kvliangdev
Would you be able to review this PR?

Thanks

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_wait to delay (in practice, seconds) after the image becomes active.
  • 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.

Comment on lines +149 to +152
if imageCreationWait > 0 {
log.Printf("Additional wait (%d seconds) after image status has changed to active...", imageCreationWait)
time.Sleep(time.Duration(imageCreationWait) * time.Second)
}
Comment on lines +180 to +182
// 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"`
Comment on lines +99 to +100
- `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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Openstack image gets deleted after their creation with packer

2 participants