Skip to content

Commit 549e22b

Browse files
committed
mantle/platform/aws: handle missing details fields
Possibly something changed on the AWS side, but we're seeing what looks like `SnapshotTaskDetail` structs coming back with some of the fields empty. Gracefully handle this case.
1 parent 85931e4 commit 549e22b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mantle/platform/api/aws/images.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,21 @@ func (a *API) finishSnapshotTask(snapshotTaskID, imageName string) (*Snapshot, e
194194

195195
details := taskRes.ImportSnapshotTasks[0].SnapshotTaskDetail
196196

197+
if details == nil || details.Status == nil {
198+
plog.Debugf("waiting for import task; no details provided")
199+
return false, "", nil
200+
}
201+
197202
// I dream of AWS specifying this as an enum shape, not string
198203
switch *details.Status {
199204
case "completed":
200205
return true, *details.SnapshotId, nil
201206
case "pending", "active":
202-
plog.Debugf("waiting for import task: %v (%v): %v", *details.Status, *details.Progress, *details.StatusMessage)
207+
if details.Progress != nil && details.StatusMessage != nil {
208+
plog.Debugf("waiting for import task: %v (%v): %v", *details.Status, *details.Progress, *details.StatusMessage)
209+
} else {
210+
plog.Debugf("waiting for import task: %v", *details.Status)
211+
}
203212
return false, "", nil
204213
case "cancelled", "cancelling":
205214
return false, "", fmt.Errorf("import task cancelled")

0 commit comments

Comments
 (0)