Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws: fix nil pointer exception #568

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
krnowak marked this conversation as resolved.
Show resolved Hide resolved
return false, "", nil
case "cancelled", "cancelling":
return false, "", fmt.Errorf("import task cancelled")
Expand Down