From b7317cc6c9c2e70173f248d4bcab79b72b08e0c1 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 21 Dec 2022 16:16:43 -0500 Subject: [PATCH] core: CoreBuild.Run error on cancelled builds When a build is cancelled by a user, the current implementation of CoreBuild.Run does not return an error signifying that there was a problem with the build. This in turn causes the HCP code to attempt to update the status of the build to DONE, but fails because there are no artifacts to push. This commit changes this behaviour by returning the error provoked by the cancellation to the caller, so it can be taken into account when setting the status of the build. --- packer/build.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer/build.go b/packer/build.go index c5f2b1383..e5ff54b72 100644 --- a/packer/build.go +++ b/packer/build.go @@ -238,7 +238,7 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packers select { case <-ctx.Done(): log.Println("Build was cancelled. Skipping post-processors.") - return nil, nil + return nil, ctx.Err() default: }