Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions builder/openstack/builder.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions builder/openstack/run_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ type RunConfig struct {
OpenstackProvider string `mapstructure:"openstack_provider"`
// *Deprecated* use `floating_ip` or `floating_ip_pool` instead.
UseFloatingIp bool `mapstructure:"use_floating_ip" required:"false"`
// 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"`

sourceImageOpts images.ListOpts
}
Expand Down
8 changes: 6 additions & 2 deletions builder/openstack/step_create_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul

// Wait for the image to become ready
ui.Say(fmt.Sprintf("Waiting for image %s (image id: %s) to become ready...", config.ImageName, imageId))
if err := WaitForImage(ctx, imageClient, imageId); err != nil {
if err := WaitForImage(ctx, imageClient, imageId, config.ImageCreationWait); err != nil {
err := fmt.Errorf("Error waiting for image: %s", err)
state.Put("error", err)
ui.Error(err.Error())
Expand All @@ -120,7 +120,7 @@ func (s *stepCreateImage) Cleanup(multistep.StateBag) {
}

// WaitForImage waits for the given Image ID to become ready.
func WaitForImage(ctx context.Context, client *gophercloud.ServiceClient, imageId string) error {
func WaitForImage(ctx context.Context, client *gophercloud.ServiceClient, imageId string, imageCreationWait int) error {
maxNumErrors := 10
numErrors := 0

Expand All @@ -146,6 +146,10 @@ func WaitForImage(ctx context.Context, client *gophercloud.ServiceClient, imageI
}

if image.Status == "active" {
if imageCreationWait > 0 {
log.Printf("Additional wait (%d seconds) after image status has changed to active...", imageCreationWait)
time.Sleep(time.Duration(imageCreationWait) * time.Second)
}
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions docs-partials/builder/openstack/RunConfig-not-required.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@

- `use_floating_ip` (bool) - *Deprecated* use `floating_ip` or `floating_ip_pool` instead.

- `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.

<!-- End of code generated from the comments of the RunConfig struct in builder/openstack/run_config.go; -->