Skip to content

Commit

Permalink
add wait for snapshot (#15)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Cyvoct <[email protected]>
  • Loading branch information
Sh4d1 authored Sep 13, 2021
1 parent 5afae6a commit ad44180
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions builder/scaleway/step_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ func (s *stepSnapshot) Run(ctx context.Context, state multistep.StateBag) multis
return multistep.ActionHalt
}

snapshot, err := instanceAPI.WaitForSnapshot(&instance.WaitForSnapshotRequest{
SnapshotID: createSnapshotResp.Snapshot.ID,
})
if err != nil {
err := fmt.Errorf("Snapshot is not available: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}

if snapshot.State != instance.SnapshotStateAvailable {
err := fmt.Errorf("Snapshot is in error state")
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}

log.Printf("Snapshot ID: %s", createSnapshotResp.Snapshot.ID)
state.Put("snapshot_id", createSnapshotResp.Snapshot.ID)
state.Put("snapshot_name", c.SnapshotName)
Expand Down

0 comments on commit ad44180

Please sign in to comment.