From db2a9b1abb8cae521c90ca5f95ec2fc36a742def Mon Sep 17 00:00:00 2001 From: Mathieu Tortuyaux Date: Fri, 29 Nov 2024 15:47:34 +0100 Subject: [PATCH 1/2] api/aws: makes import more robust again nil pointer exception Signed-off-by: Mathieu Tortuyaux --- platform/api/aws/images.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/platform/api/aws/images.go b/platform/api/aws/images.go index 143c0c773..af1916bda 100644 --- a/platform/api/aws/images.go +++ b/platform/api/aws/images.go @@ -207,7 +207,16 @@ 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 { From beec48dd0a588fcf7a14eb9e61e3e5c86186df4a Mon Sep 17 00:00:00 2001 From: Mathieu Tortuyaux Date: Fri, 29 Nov 2024 15:53:10 +0100 Subject: [PATCH 2/2] api/aws: remove details during the import task status The details (progress and status message) are not provided by AWS at the beginning of the import. Here's the details: ```json { DiskImageSize: 0, Format: "RAW", SnapshotId: "", Status: "active", UserBucket: { S3Bucket: "flatcar-kola-ami-import-us-east-1", S3Key: "tormath1/amd64-usr/tormath1-flatcar-stable/flatcar_production_ami_image.bin" } } ``` Let's just drop it as we don't use it, this does not impact the execution of the program. If required, we can still access to the task via its ID using the AWS CLI. Signed-off-by: Mathieu Tortuyaux --- platform/api/aws/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/api/aws/images.go b/platform/api/aws/images.go index af1916bda..7ae37a7dd 100644 --- a/platform/api/aws/images.go +++ b/platform/api/aws/images.go @@ -223,7 +223,7 @@ func (a *API) finishSnapshotTask(snapshotTaskID, imageName string) (*Snapshot, e 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")