From 07701f85e756e31570299f5f56eab51553ab4335 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Thu, 21 Nov 2024 11:03:17 -0500 Subject: [PATCH] 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. --- mantle/platform/api/aws/images.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mantle/platform/api/aws/images.go b/mantle/platform/api/aws/images.go index c465ad4405..4841b5a2fd 100644 --- a/mantle/platform/api/aws/images.go +++ b/mantle/platform/api/aws/images.go @@ -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")