Skip to content

Commit

Permalink
Merge pull request #568 from flatcar/tormath1/aws
Browse files Browse the repository at this point in the history
aws: fix nil pointer exception
  • Loading branch information
tormath1 authored Dec 2, 2024
2 parents a3ee855 + beec48d commit 28a2bfa
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion platform/api/aws/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,23 @@ func (a *API) finishSnapshotTask(snapshotTaskID, imageName string) (*Snapshot, e
return false, "", err
}

if len(taskRes.ImportSnapshotTasks) == 0 {
plog.Debugf("no import snapshot tasks in progress")
return false, "", nil
}

details := taskRes.ImportSnapshotTasks[0].SnapshotTaskDetail
if details == nil {
plog.Debugf("no details on the import snapshot task")
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)
plog.Debugf("waiting for import task")
return false, "", nil
case "cancelled", "cancelling":
return false, "", fmt.Errorf("import task cancelled")
Expand Down

0 comments on commit 28a2bfa

Please sign in to comment.