Skip to content

Commit

Permalink
mantle/platform/aws: handle missing details fields
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jlebon committed Nov 21, 2024
1 parent 8c54e2e commit f3bef57
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mantle/platform/api/aws/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,21 @@ func (a *API) finishSnapshotTask(snapshotTaskID, imageName string) (*Snapshot, e

details := taskRes.ImportSnapshotTasks[0].SnapshotTaskDetail

if details == nil || details.Status == nil {
plog.Debugf("waiting for import task; no details provided")
return false, "", nil
}

// I dream of AWS specifying this as an enum shape, not string
switch *details.Status {
case "completed":
return true, *details.SnapshotId, nil
case "pending", "active":
plog.Debugf("waiting for import task: %v (%v): %v", *details.Status, *details.Progress, *details.StatusMessage)
if details.Progress != nil && details.StatusMessage != nil {
plog.Debugf("waiting for import task: %v (%v): %v", *details.Status, *details.Progress, *details.StatusMessage)
} else {
plog.Debugf("waiting for import task: %v", *details.Status)
}
return false, "", nil
case "cancelled", "cancelling":
return false, "", fmt.Errorf("import task cancelled")
Expand Down

0 comments on commit f3bef57

Please sign in to comment.