From ed447fd8f2c9742f9435d1262407b4e2bf3fee06 Mon Sep 17 00:00:00 2001 From: Magnus Henoch Date: Wed, 30 Oct 2024 12:23:56 +0000 Subject: [PATCH] Log when skipping instance stop for spot instances This should make it clearer what's going on. Also update the documentation to mention this behavior. Closes #448. --- .web-docs/components/builder/ebs/README.md | 4 ++++ .web-docs/components/builder/ebssurrogate/README.md | 4 ++++ .web-docs/components/builder/ebsvolume/README.md | 4 ++++ .web-docs/components/builder/instance/README.md | 4 ++++ builder/common/run_config.go | 4 ++++ builder/common/step_stop_ebs_instance.go | 1 + docs-partials/builder/common/RunConfig-not-required.mdx | 4 ++++ 7 files changed, 25 insertions(+) diff --git a/.web-docs/components/builder/ebs/README.md b/.web-docs/components/builder/ebs/README.md index a089c6a9a..0bfb1cc49 100644 --- a/.web-docs/components/builder/ebs/README.md +++ b/.web-docs/components/builder/ebs/README.md @@ -581,6 +581,10 @@ JSON example: -> Note: The double quotation marks in the command are not required if your CMD shell is already in the `C:\Program Files\Amazon\EC2ConfigService\` directory. + + Note that when using a spot instance, Packer doesn't stop the instance, + regardless of the value of this setting. Instead, it relies on the CreateImage + call to stop and restart the instance. - `ebs_optimized` (bool) - Mark instance as [EBS Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). diff --git a/.web-docs/components/builder/ebssurrogate/README.md b/.web-docs/components/builder/ebssurrogate/README.md index 3e9ffc119..3ba75ae09 100644 --- a/.web-docs/components/builder/ebssurrogate/README.md +++ b/.web-docs/components/builder/ebssurrogate/README.md @@ -594,6 +594,10 @@ JSON example: -> Note: The double quotation marks in the command are not required if your CMD shell is already in the `C:\Program Files\Amazon\EC2ConfigService\` directory. + + Note that when using a spot instance, Packer doesn't stop the instance, + regardless of the value of this setting. Instead, it relies on the CreateImage + call to stop and restart the instance. - `ebs_optimized` (bool) - Mark instance as [EBS Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). diff --git a/.web-docs/components/builder/ebsvolume/README.md b/.web-docs/components/builder/ebsvolume/README.md index d3b534b79..5415b1284 100644 --- a/.web-docs/components/builder/ebsvolume/README.md +++ b/.web-docs/components/builder/ebsvolume/README.md @@ -546,6 +546,10 @@ https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concept -> Note: The double quotation marks in the command are not required if your CMD shell is already in the `C:\Program Files\Amazon\EC2ConfigService\` directory. + + Note that when using a spot instance, Packer doesn't stop the instance, + regardless of the value of this setting. Instead, it relies on the CreateImage + call to stop and restart the instance. - `ebs_optimized` (bool) - Mark instance as [EBS Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). diff --git a/.web-docs/components/builder/instance/README.md b/.web-docs/components/builder/instance/README.md index f892dc1f2..4b0cec328 100644 --- a/.web-docs/components/builder/instance/README.md +++ b/.web-docs/components/builder/instance/README.md @@ -579,6 +579,10 @@ JSON example: -> Note: The double quotation marks in the command are not required if your CMD shell is already in the `C:\Program Files\Amazon\EC2ConfigService\` directory. + + Note that when using a spot instance, Packer doesn't stop the instance, + regardless of the value of this setting. Instead, it relies on the CreateImage + call to stop and restart the instance. - `ebs_optimized` (bool) - Mark instance as [EBS Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). diff --git a/builder/common/run_config.go b/builder/common/run_config.go index 038aa62b3..4fd875e44 100644 --- a/builder/common/run_config.go +++ b/builder/common/run_config.go @@ -178,6 +178,10 @@ type RunConfig struct { // -> Note: The double quotation marks in the command are not required if // your CMD shell is already in the // `C:\Program Files\Amazon\EC2ConfigService\` directory. + // + // Note that when using a spot instance, Packer doesn't stop the instance, + // regardless of the value of this setting. Instead, it relies on the CreateImage + // call to stop and restart the instance. DisableStopInstance bool `mapstructure:"disable_stop_instance" required:"false"` // Mark instance as [EBS // Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). diff --git a/builder/common/step_stop_ebs_instance.go b/builder/common/step_stop_ebs_instance.go index b42b1f30f..0591ae8d4 100644 --- a/builder/common/step_stop_ebs_instance.go +++ b/builder/common/step_stop_ebs_instance.go @@ -28,6 +28,7 @@ func (s *StepStopEBSBackedInstance) Run(ctx context.Context, state multistep.Sta // Skip when it is a spot instance if s.Skip { + ui.Say("Skipping instance stop, since this is a spot instance.") return multistep.ActionContinue } diff --git a/docs-partials/builder/common/RunConfig-not-required.mdx b/docs-partials/builder/common/RunConfig-not-required.mdx index 0b758f82f..638ea5f4a 100644 --- a/docs-partials/builder/common/RunConfig-not-required.mdx +++ b/docs-partials/builder/common/RunConfig-not-required.mdx @@ -62,6 +62,10 @@ -> Note: The double quotation marks in the command are not required if your CMD shell is already in the `C:\Program Files\Amazon\EC2ConfigService\` directory. + + Note that when using a spot instance, Packer doesn't stop the instance, + regardless of the value of this setting. Instead, it relies on the CreateImage + call to stop and restart the instance. - `ebs_optimized` (bool) - Mark instance as [EBS Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html).