Skip to content

Commit 98dc2d9

Browse files
zhenggulbajolet-hashicorp
authored andcommitted
Set volume ID after create up
1 parent ff1545c commit 98dc2d9

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

builder/openstack/step_create_volume.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu
7575
return multistep.ActionHalt
7676
}
7777

78+
// Put volume ID here for clean up
79+
s.volumeID = volume.ID
80+
7881
// Wait for volume to become available.
7982
ui.Say(fmt.Sprintf("Waiting for volume %s (volume id: %s) to become available...", config.VolumeName, volume.ID))
8083
if err := WaitForVolume(blockStorageClient, volume.ID); err != nil {
81-
// Put the error volume here for cleanup.
82-
s.volumeID = volume.ID
8384
err := fmt.Errorf("Error waiting for volume: %s", err)
8485
state.Put("error", err)
8586
ui.Error(err.Error())
@@ -89,7 +90,6 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu
8990
// Set the Volume ID in the state.
9091
ui.Message(fmt.Sprintf("Volume ID: %s", volume.ID))
9192
state.Put("volume_id", volume.ID)
92-
s.volumeID = volume.ID
9393

9494
return multistep.ActionContinue
9595
}
@@ -115,6 +115,5 @@ func (s *StepCreateVolume) Cleanup(state multistep.StateBag) {
115115
err = volumes.Delete(blockStorageClient, s.volumeID, volumes.DeleteOpts{}).ExtractErr()
116116
if err != nil {
117117
ui.Error(fmt.Sprintf("Error cleaning up volume %q: %s. This may need manual deletion.", s.volumeID, err))
118-
"Error cleaning up volume. Please delete the volume manually: %s", s.volumeID))
119118
}
120119
}

0 commit comments

Comments
 (0)