From 2200cb14ce8c957334c2b429c084e08a5afac638 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 21 Dec 2022 16:19:23 -0500 Subject: [PATCH] hcp: set the status to CANCELLED when a build is Related to the previous behaviour problem, this changes how the status of a build is set on HCP Packer, as a cancelled build is different from a failed one, we can set it to the appropriate state on cancellation. --- internal/hcp/registry/types.bucket.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/hcp/registry/types.bucket.go b/internal/hcp/registry/types.bucket.go index e3f3895f2..597128dac 100644 --- a/internal/hcp/registry/types.bucket.go +++ b/internal/hcp/registry/types.bucket.go @@ -569,7 +569,11 @@ func (b *Bucket) completeBuild( } if buildErr != nil { - err := b.UpdateBuildStatus(ctx, buildName, models.HashicorpCloudPackerBuildStatusFAILED) + status := models.HashicorpCloudPackerBuildStatusFAILED + if ctx.Err() != nil { + status = models.HashicorpCloudPackerBuildStatusCANCELLED + } + err := b.UpdateBuildStatus(context.Background(), buildName, status) if err != nil { log.Printf("[ERROR] failed to update build %q status to FAILED: %s", buildName, err) }