Skip to content

Commit

Permalink
use openstack volume_size option on creation
Browse files Browse the repository at this point in the history
if present. Otherwise fallback to to source image min disk value (if
set) or calculated from the source image bytes size.

Note that in some cases this needs to be specified, if
`use_blockstorage_volume` is true. See hashicorp#6957 for the discussion.
  • Loading branch information
jo committed Dec 18, 2018
1 parent 336c11c commit a545caa
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions builder/openstack/step_create_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,25 @@ func (s *StepCreateVolume) Run(_ context.Context, state multistep.StateBag) mult
state.Put("error", err)
return multistep.ActionHalt
}
imageClient, err := config.imageV2Client()
if err != nil {
err = fmt.Errorf("Error initializing image client: %s", err)
state.Put("error", err)
return multistep.ActionHalt
}

volumeSize := config.VolumeSize

// Get needed volume size from the source image.
volumeSize, err := GetVolumeSize(imageClient, sourceImage)
if err != nil {
err := fmt.Errorf("Error creating volume: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
if volumeSize == 0 {
imageClient, err := config.imageV2Client()
if err != nil {
err = fmt.Errorf("Error initializing image client: %s", err)
state.Put("error", err)
return multistep.ActionHalt
}

volumeSize, err = GetVolumeSize(imageClient, sourceImage)
if err != nil {
err := fmt.Errorf("Error creating volume: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
}

ui.Say("Creating volume...")
Expand Down

0 comments on commit a545caa

Please sign in to comment.