From 3b8aba2d24130cce261bac6f4a9b6bf1e144e289 Mon Sep 17 00:00:00 2001 From: Daisuke Takahashi Date: Thu, 13 Sep 2018 18:29:24 +0900 Subject: [PATCH 1/9] OpenStack: wait for volume availability when cleaning up --- builder/openstack/step_create_volume.go | 17 +++++++++++++++++ builder/openstack/volume.go | 15 ++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/builder/openstack/step_create_volume.go b/builder/openstack/step_create_volume.go index a188012f9..a8bc13c95 100644 --- a/builder/openstack/step_create_volume.go +++ b/builder/openstack/step_create_volume.go @@ -102,6 +102,23 @@ func (s *StepCreateVolume) Cleanup(state multistep.StateBag) { return } + // Wait for volume to become available. + status, err := GetVolumeStatus(blockStorageClient, s.volumeID) + if err != nil { + ui.Error(fmt.Sprintf( + "Error getting the volume information. Please delete the volume manually: %s", s.volumeID)) + return + } + + if status != "available" { + ui.Say(fmt.Sprintf( + "Waiting for volume %s (volume id: %s) to become available...", s.VolumeName, s.volumeID)) + if err := WaitForVolume(blockStorageClient, s.volumeID); err != nil { + ui.Error(fmt.Sprintf( + "Error getting the volume information. Please delete the volume manually: %s", s.volumeID)) + return + } + } ui.Say(fmt.Sprintf("Deleting volume: %s ...", s.volumeID)) err = volumes.Delete(blockStorageClient, s.volumeID).ExtractErr() if err != nil { diff --git a/builder/openstack/volume.go b/builder/openstack/volume.go index 5eba12578..162ed59c4 100644 --- a/builder/openstack/volume.go +++ b/builder/openstack/volume.go @@ -15,7 +15,7 @@ func WaitForVolume(blockStorageClient *gophercloud.ServiceClient, volumeID strin numErrors := 0 for { - volume, err := volumes.Get(blockStorageClient, volumeID).Extract() + status, err := GetVolumeStatus(blockStorageClient, volumeID) if err != nil { errCode, ok := err.(*gophercloud.ErrUnexpectedResponseCode) if ok && (errCode.Actual == 500 || errCode.Actual == 404) { @@ -32,11 +32,11 @@ func WaitForVolume(blockStorageClient *gophercloud.ServiceClient, volumeID strin return err } - if volume.Status == "available" { + if status == "available" { return nil } - log.Printf("Waiting for volume creation status: %s", volume.Status) + log.Printf("Waiting for volume creation status: %s", status) time.Sleep(2 * time.Second) } } @@ -65,3 +65,12 @@ func GetVolumeSize(imageClient *gophercloud.ServiceClient, imageID string) (int, return volumeSizeGB, nil } + +func GetVolumeStatus(blockStorageClient *gophercloud.ServiceClient, volumeID string) (string, error) { + volume, err := volumes.Get(blockStorageClient, volumeID).Extract() + if err != nil { + return "", err + } + + return volume.Status, nil +} From 9e0fae9db3f8353a9a3e6d90f87d07c7fbe3116d Mon Sep 17 00:00:00 2001 From: Matt Dainty Date: Wed, 17 Oct 2018 14:34:36 +0100 Subject: [PATCH 2/9] Add support to explicitly disable ENA support If `ena_support` is set to false then it previously didn't do anything whereas now it will explicitly disable ENA support. Fixes #6852 --- .../amazon/common/step_modify_ebs_instance.go | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/builder/amazon/common/step_modify_ebs_instance.go b/builder/amazon/common/step_modify_ebs_instance.go index c2c454e06..806417548 100644 --- a/builder/amazon/common/step_modify_ebs_instance.go +++ b/builder/amazon/common/step_modify_ebs_instance.go @@ -3,6 +3,7 @@ package common import ( "context" "fmt" + "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" @@ -37,20 +38,24 @@ func (s *StepModifyEBSBackedInstance) Run(_ context.Context, state multistep.Sta } } - // Set EnaSupport to true. + // Handle EnaSupport flag. // As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge + var prefix string if s.EnableAMIENASupport { - ui.Say("Enabling Enhanced Networking (ENA)...") - _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ - InstanceId: instance.InstanceId, - EnaSupport: &ec2.AttributeBooleanValue{Value: aws.Bool(true)}, - }) - if err != nil { - err := fmt.Errorf("Error enabling Enhanced Networking (ENA) on %s: %s", *instance.InstanceId, err) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt - } + prefix = "En" + } else { + prefix = "Dis" + } + ui.Say(fmt.Sprintf("%sabling Enhanced Networking (ENA)...", prefix)) + _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ + InstanceId: instance.InstanceId, + EnaSupport: &ec2.AttributeBooleanValue{Value: aws.Bool(s.EnableAMIENASupport)}, + }) + if err != nil { + err := fmt.Errorf("Error %sabling Enhanced Networking (ENA) on %s: %s", strings.ToLower(prefix), *instance.InstanceId, err) + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt } return multistep.ActionContinue From 03f8680c3c734dd52efde3797c38f1a287f4b2c0 Mon Sep 17 00:00:00 2001 From: Kevin Hicks Date: Thu, 18 Oct 2018 16:53:57 -0500 Subject: [PATCH 3/9] Remove json specifier from doc code block --- website/source/docs/builders/amazon.html.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/source/docs/builders/amazon.html.md b/website/source/docs/builders/amazon.html.md index b1119f607..5a438894d 100644 --- a/website/source/docs/builders/amazon.html.md +++ b/website/source/docs/builders/amazon.html.md @@ -180,7 +180,7 @@ for Packer to work: Note that if you'd like to create a spot instance, you must also add: -``` json +``` ec2:RequestSpotInstances, ec2:CancelSpotInstanceRequests, ec2:DescribeSpotInstanceRequests @@ -188,7 +188,7 @@ ec2:DescribeSpotInstanceRequests If you have the `spot_price` parameter set to `auto`, you must also add: -``` json +``` ec2:DescribeSpotPriceHistory ``` @@ -247,4 +247,4 @@ Excepting tasks that we know can take an extremely long time, this defaults to 40tries. `AWS_POLL_DELAY_SECONDS` - How many seconds to wait in between status update -requests. Generally defaults to 2 or 5 seconds, depending on the task. \ No newline at end of file +requests. Generally defaults to 2 or 5 seconds, depending on the task. From 207b4f2915054fc1f3b56d82d977cdb27e04c873 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 18 Oct 2018 16:43:10 -0700 Subject: [PATCH 4/9] update changelog --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3689d714..dec654656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,45 @@ +## 1.3.2 (upcoming) +### IMPROVEMENTS: +* builder/amazon: Clean up security group wait code. [GH-6843] +* builder/qemu: Add `disk_detect_zeroes` option. [GH-6827] +* builder/hcloud: Add Hetzner Cloud builder. [GH-6871] +* builder/amazon: Add suppport for `vpc_filter`, `subnet_filter`, and `security_group_filter`. [GH-6374] +* provisioner/powershell: Provide better error when Packer can't find Powershell executable. [GH-6817] +* builder/amazon: Update aws-sdk-go to v1.15.54, adding support for `credential_source`. [GH-6849] +* builder/googlecompute: Return an error if `startup_script_file` is specified, but file does not exist. [GH-6848] +* builder/amazon: Add validation for required `device_name` paramater in `block_device_mappings`. [GH-6845] +* builder/scaleway: Add `boottype` parameter to config. [GH-6772] +* core: New option to add timestamps to UI output. [GH-6784] +* builder/azure: Add new `shared_image_gallery` option. [GH-6798] +* builder/openstack: Add new `disk_format` option. [GH-6702] +* builder/openstack: Fix bug where `source_image_name` wasn't being used to properly find a UUID. [GH-6751] +* provisioner/file: Improve error messaging when file destination is a directory with no trailing slash. [GH-6756] +* builder/alicloud: Add new `disable_stop_instance` option. [GH-6764] +* builder/scaleway: Update scaleway-cli vendor. [GH-6771] + +### BUG FIXES: +* builder/amazon: Error validating credentials is no longer obscured by a region validation error. [GH-6865] +* core: Fix race conditions in progress bar code [GH-6858], [GH-6788], [GH-6851] +* post-processor/manifest: No longer provides an empty ID string for Azure's managed image artifact [GH-6822] +* provisioner/powershell: Fix a bug in the way we set the ProgressPreference variable in the default `execute_command` [GH-6838] +* builder/amazon: Fix error calculating defaults in AWS waiters. [GH-6727] +* provisioner/windows-restart: Fix extraneous break which forced early exit from our wait loop. [GH-6792] +* builder/azure: Updated Azure/go-ntlmssp dependency to resolve an issue with the winrm communicator not connecting to Windows machines requiring NTLMv2 session security +* builder/amazon: Waiter now fails rather than hanging for extra time when an image import fails. [GH-6747] +* core: Fix logger so it doesn't accidentally try to format unescaped strings. [GH-6824] +* builder/amazon: Increase default wait for image import to one hour. [GH-6818] +* core: Fix error where logging was always enabled when Packer was run from inside Terraform. [GH-6758] +* builder/alicloud: Fix type error in step_create_tags [GH-6763] +* builder/scaleway: Fix issues with ssh keys. [GH-6768] +* core: Fix various places in multiple builders where config was not being passed as a pointer. [GH-6739] + ## 1.3.1 (September 13, 2018) + ### IMPROVEMENTS: * builder/amazon: automatically decode encoded authorization messages if possible [GH-5415] * builder:amazon: Optional cleanup of the authorized keys file [GH-6713] +* builder/qemu: Fixed bug where a -device in the qemuargs would override the default network settings, resulting in no network [GH-6807] ### BUG FIXES: * builder/amazon: fix bugs relating to spot instances provisioning [GH-6697] From 556e26c093233773418a6494ffc130409b634bab Mon Sep 17 00:00:00 2001 From: Matt Dainty Date: Thu, 18 Oct 2018 11:42:08 +0100 Subject: [PATCH 5/9] Update docs regarding disabling ENA support --- website/source/docs/builders/amazon-chroot.html.md | 8 +++++--- website/source/docs/builders/amazon-ebs.html.md | 8 +++++--- website/source/docs/builders/amazon-ebssurrogate.html.md | 8 +++++--- website/source/docs/builders/amazon-ebsvolume.html.md | 8 +++++--- website/source/docs/builders/amazon-instance.html.md | 8 +++++--- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/website/source/docs/builders/amazon-chroot.html.md b/website/source/docs/builders/amazon-chroot.html.md index 8f84b49b6..572d97b6d 100644 --- a/website/source/docs/builders/amazon-chroot.html.md +++ b/website/source/docs/builders/amazon-chroot.html.md @@ -131,9 +131,11 @@ each category, the available configuration keys are alphabetized. forces Packer to find an open device automatically. - `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) - on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy. - Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's - documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`. + on HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy. + If false, this will disable enhanced networking in the final AMI as opposed to passing + the setting through unchanged from the source. Note: you must make sure enhanced + networking is enabled on your instance. See [Amazon's documentation on enabling enhanced + networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). - `force_deregister` (boolean) - Force Packer to first deregister an existing AMI if one with the same name already exists. Default `false`. diff --git a/website/source/docs/builders/amazon-ebs.html.md b/website/source/docs/builders/amazon-ebs.html.md index 8217fc714..7cc93e08c 100644 --- a/website/source/docs/builders/amazon-ebs.html.md +++ b/website/source/docs/builders/amazon-ebs.html.md @@ -182,9 +182,11 @@ builder. Default `false`. - `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) - on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy. - Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's - documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`. + on HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy. + If false, this will disable enhanced networking in the final AMI as opposed to passing + the setting through unchanged from the source. Note: you must make sure enhanced + networking is enabled on your instance. See [Amazon's documentation on enabling enhanced + networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). - `enable_t2_unlimited` (boolean) - Enabling T2 Unlimited allows the source instance to burst additional CPU beyond its available [CPU Credits] diff --git a/website/source/docs/builders/amazon-ebssurrogate.html.md b/website/source/docs/builders/amazon-ebssurrogate.html.md index d592b9805..0b91e7e3e 100644 --- a/website/source/docs/builders/amazon-ebssurrogate.html.md +++ b/website/source/docs/builders/amazon-ebssurrogate.html.md @@ -175,9 +175,11 @@ builder. Default `false`. - `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) - on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy. - Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's - documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`. + on HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy. + If false, this will disable enhanced networking in the final AMI as opposed to passing + the setting through unchanged from the source. Note: you must make sure enhanced + networking is enabled on your instance. See [Amazon's documentation on enabling enhanced + networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). - `enable_t2_unlimited` (boolean) - Enabling T2 Unlimited allows the source instance to burst additional CPU beyond its available [CPU Credits] diff --git a/website/source/docs/builders/amazon-ebsvolume.html.md b/website/source/docs/builders/amazon-ebsvolume.html.md index 7309ff6c5..65fbdc489 100644 --- a/website/source/docs/builders/amazon-ebsvolume.html.md +++ b/website/source/docs/builders/amazon-ebsvolume.html.md @@ -147,9 +147,11 @@ builder. Default `false`. - `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) - on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy. - Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's - documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`. + on HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy. + If false, this will disable enhanced networking in the final AMI as opposed to passing + the setting through unchanged from the source. Note: you must make sure enhanced + networking is enabled on your instance. See [Amazon's documentation on enabling enhanced + networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). - `enable_t2_unlimited` (boolean) - Enabling T2 Unlimited allows the source instance to burst additional CPU beyond its available [CPU Credits] diff --git a/website/source/docs/builders/amazon-instance.html.md b/website/source/docs/builders/amazon-instance.html.md index 412e2e703..750bd5d30 100644 --- a/website/source/docs/builders/amazon-instance.html.md +++ b/website/source/docs/builders/amazon-instance.html.md @@ -199,9 +199,11 @@ builder. Default `false`. - `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport) - on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy. - Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's - documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`. + on HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy. + If false, this will disable enhanced networking in the final AMI as opposed to passing + the setting through unchanged from the source. Note: you must make sure enhanced + networking is enabled on your instance. See [Amazon's documentation on enabling enhanced + networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). - `enable_t2_unlimited` (boolean) - Enabling T2 Unlimited allows the source instance to burst additional CPU beyond its available [CPU Credits] From feb8067c7d71deaa5f88d9fda7d73f48780a9cff Mon Sep 17 00:00:00 2001 From: Matt Dainty Date: Fri, 19 Oct 2018 12:21:00 +0100 Subject: [PATCH 6/9] Convert `ena_support` to a pointer This means it now has three states, `true`, `false`, & `nil`. The default state is now `nil` which does nothing instead of `false` which now will explicitly disable ENA support instead of just not enabling it. --- builder/amazon/chroot/step_register_ami.go | 4 +-- builder/amazon/common/ami_config.go | 2 +- .../amazon/common/step_modify_ebs_instance.go | 36 ++++++++++--------- builder/amazon/common/step_source_ami_info.go | 4 +-- builder/amazon/ebs/builder.go | 2 +- builder/amazon/ebssurrogate/builder.go | 2 +- .../amazon/ebssurrogate/step_register_ami.go | 4 +-- builder/amazon/ebsvolume/builder.go | 4 +-- builder/amazon/instance/builder.go | 2 +- builder/amazon/instance/step_register_ami.go | 4 +-- 10 files changed, 33 insertions(+), 31 deletions(-) diff --git a/builder/amazon/chroot/step_register_ami.go b/builder/amazon/chroot/step_register_ami.go index 4f3ad54c4..dbb84a5be 100644 --- a/builder/amazon/chroot/step_register_ami.go +++ b/builder/amazon/chroot/step_register_ami.go @@ -14,7 +14,7 @@ import ( // StepRegisterAMI creates the AMI. type StepRegisterAMI struct { RootVolumeSize int64 - EnableAMIENASupport bool + EnableAMIENASupport *bool EnableAMISriovNetSupport bool } @@ -83,7 +83,7 @@ func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) mul // As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge) registerOpts.SriovNetSupport = aws.String("simple") } - if s.EnableAMIENASupport { + if s.EnableAMIENASupport != nil && *s.EnableAMIENASupport { // Set EnaSupport to true // As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge registerOpts.EnaSupport = aws.Bool(true) diff --git a/builder/amazon/common/ami_config.go b/builder/amazon/common/ami_config.go index 58c6b8827..60844ec63 100644 --- a/builder/amazon/common/ami_config.go +++ b/builder/amazon/common/ami_config.go @@ -19,7 +19,7 @@ type AMIConfig struct { AMIRegions []string `mapstructure:"ami_regions"` AMISkipRegionValidation bool `mapstructure:"skip_region_validation"` AMITags TagMap `mapstructure:"tags"` - AMIENASupport bool `mapstructure:"ena_support"` + AMIENASupport *bool `mapstructure:"ena_support"` AMISriovNetSupport bool `mapstructure:"sriov_support"` AMIForceDeregister bool `mapstructure:"force_deregister"` AMIForceDeleteSnapshot bool `mapstructure:"force_delete_snapshot"` diff --git a/builder/amazon/common/step_modify_ebs_instance.go b/builder/amazon/common/step_modify_ebs_instance.go index 806417548..8e8b830b4 100644 --- a/builder/amazon/common/step_modify_ebs_instance.go +++ b/builder/amazon/common/step_modify_ebs_instance.go @@ -12,7 +12,7 @@ import ( ) type StepModifyEBSBackedInstance struct { - EnableAMIENASupport bool + EnableAMIENASupport *bool EnableAMISriovNetSupport bool } @@ -40,22 +40,24 @@ func (s *StepModifyEBSBackedInstance) Run(_ context.Context, state multistep.Sta // Handle EnaSupport flag. // As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge - var prefix string - if s.EnableAMIENASupport { - prefix = "En" - } else { - prefix = "Dis" - } - ui.Say(fmt.Sprintf("%sabling Enhanced Networking (ENA)...", prefix)) - _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ - InstanceId: instance.InstanceId, - EnaSupport: &ec2.AttributeBooleanValue{Value: aws.Bool(s.EnableAMIENASupport)}, - }) - if err != nil { - err := fmt.Errorf("Error %sabling Enhanced Networking (ENA) on %s: %s", strings.ToLower(prefix), *instance.InstanceId, err) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt + if s.EnableAMIENASupport != nil { + var prefix string + if *s.EnableAMIENASupport { + prefix = "En" + } else { + prefix = "Dis" + } + ui.Say(fmt.Sprintf("%sabling Enhanced Networking (ENA)...", prefix)) + _, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{ + InstanceId: instance.InstanceId, + EnaSupport: &ec2.AttributeBooleanValue{Value: aws.Bool(*s.EnableAMIENASupport)}, + }) + if err != nil { + err := fmt.Errorf("Error %sabling Enhanced Networking (ENA) on %s: %s", strings.ToLower(prefix), *instance.InstanceId, err) + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt + } } return multistep.ActionContinue diff --git a/builder/amazon/common/step_source_ami_info.go b/builder/amazon/common/step_source_ami_info.go index cb7a08b51..5cbcb0cc8 100644 --- a/builder/amazon/common/step_source_ami_info.go +++ b/builder/amazon/common/step_source_ami_info.go @@ -20,7 +20,7 @@ import ( type StepSourceAMIInfo struct { SourceAmi string EnableAMISriovNetSupport bool - EnableAMIENASupport bool + EnableAMIENASupport *bool AMIVirtType string AmiFilters AmiFilterOptions } @@ -106,7 +106,7 @@ func (s *StepSourceAMIInfo) Run(_ context.Context, state multistep.StateBag) mul // Enhanced Networking can only be enabled on HVM AMIs. // See http://goo.gl/icuXh5 - if s.EnableAMIENASupport || s.EnableAMISriovNetSupport { + if (s.EnableAMIENASupport != nil && *s.EnableAMIENASupport) || s.EnableAMISriovNetSupport { err = s.canEnableEnhancedNetworking(image) if err != nil { state.Put("error", err) diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 1980a770d..2347de1a8 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -70,7 +70,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend(errs, b.config.BlockDevices.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) - if b.config.IsSpotInstance() && (b.config.AMIENASupport || b.config.AMISriovNetSupport) { + if b.config.IsSpotInstance() && ((b.config.AMIENASupport != nil && *b.config.AMIENASupport) || b.config.AMISriovNetSupport) { errs = packer.MultiErrorAppend(errs, fmt.Errorf("Spot instances do not support modification, which is required "+ "when either `ena_support` or `sriov_support` are set. Please ensure "+ diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index 59537572b..76c5ec75e 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -85,7 +85,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName)) } - if b.config.IsSpotInstance() && (b.config.AMIENASupport || b.config.AMISriovNetSupport) { + if b.config.IsSpotInstance() && ((b.config.AMIENASupport != nil && *b.config.AMIENASupport) || b.config.AMISriovNetSupport) { errs = packer.MultiErrorAppend(errs, fmt.Errorf("Spot instances do not support modification, which is required "+ "when either `ena_support` or `sriov_support` are set. Please ensure "+ diff --git a/builder/amazon/ebssurrogate/step_register_ami.go b/builder/amazon/ebssurrogate/step_register_ami.go index 63e0f5581..60b653681 100644 --- a/builder/amazon/ebssurrogate/step_register_ami.go +++ b/builder/amazon/ebssurrogate/step_register_ami.go @@ -16,7 +16,7 @@ type StepRegisterAMI struct { RootDevice RootBlockDevice AMIDevices []*ec2.BlockDeviceMapping LaunchDevices []*ec2.BlockDeviceMapping - EnableAMIENASupport bool + EnableAMIENASupport *bool EnableAMISriovNetSupport bool image *ec2.Image } @@ -44,7 +44,7 @@ func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) mul // As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge) registerOpts.SriovNetSupport = aws.String("simple") } - if s.EnableAMIENASupport { + if s.EnableAMIENASupport != nil && *s.EnableAMIENASupport { // Set EnaSupport to true // As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge registerOpts.EnaSupport = aws.Bool(true) diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index 643b55a2a..a661576e1 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -24,7 +24,7 @@ type Config struct { awscommon.RunConfig `mapstructure:",squash"` VolumeMappings []BlockDevice `mapstructure:"ebs_volumes"` - AMIENASupport bool `mapstructure:"ena_support"` + AMIENASupport *bool `mapstructure:"ena_support"` AMISriovNetSupport bool `mapstructure:"sriov_support"` launchBlockDevices awscommon.BlockDevices @@ -70,7 +70,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs = packer.MultiErrorAppend(errs, err) } - if b.config.IsSpotInstance() && (b.config.AMIENASupport || b.config.AMISriovNetSupport) { + if b.config.IsSpotInstance() && ((b.config.AMIENASupport != nil && *b.config.AMIENASupport) || b.config.AMISriovNetSupport) { errs = packer.MultiErrorAppend(errs, fmt.Errorf("Spot instances do not support modification, which is required "+ "when either `ena_support` or `sriov_support` are set. Please ensure "+ diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 6872f3883..977370138 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -156,7 +156,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { errs, fmt.Errorf("x509_key_path points to bad file: %s", err)) } - if b.config.IsSpotInstance() && (b.config.AMIENASupport || b.config.AMISriovNetSupport) { + if b.config.IsSpotInstance() && ((b.config.AMIENASupport != nil && *b.config.AMIENASupport) || b.config.AMISriovNetSupport) { errs = packer.MultiErrorAppend(errs, fmt.Errorf("Spot instances do not support modification, which is required "+ "when either `ena_support` or `sriov_support` are set. Please ensure "+ diff --git a/builder/amazon/instance/step_register_ami.go b/builder/amazon/instance/step_register_ami.go index 20df1f0d4..2dfcda02b 100644 --- a/builder/amazon/instance/step_register_ami.go +++ b/builder/amazon/instance/step_register_ami.go @@ -12,7 +12,7 @@ import ( ) type StepRegisterAMI struct { - EnableAMIENASupport bool + EnableAMIENASupport *bool EnableAMISriovNetSupport bool } @@ -38,7 +38,7 @@ func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) mul // As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge) registerOpts.SriovNetSupport = aws.String("simple") } - if s.EnableAMIENASupport { + if s.EnableAMIENASupport != nil && *s.EnableAMIENASupport { // Set EnaSupport to true // As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge registerOpts.EnaSupport = aws.Bool(true) From 3c73e07afa3ac8d0f3d1e255bf23468ddf45969b Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 18 Oct 2018 15:37:32 -0700 Subject: [PATCH 7/9] add explanation of ui message types --- website/source/docs/commands/index.html.md | 58 +++++++++++++++++----- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/website/source/docs/commands/index.html.md b/website/source/docs/commands/index.html.md index 63543c134..05229af06 100644 --- a/website/source/docs/commands/index.html.md +++ b/website/source/docs/commands/index.html.md @@ -71,21 +71,21 @@ This makes it more convenient to parse using standard Unix tools such as `awk` o The format is: ``` text -timestamp,target,type,data... +timestamp,,target,type,data... ``` Each component is explained below: - `timestamp` is a Unix timestamp in UTC of when the message was printed. -- `target` is the target of the following output. This is empty if the message - is related to Packer globally. Otherwise, this is generally a build name so - you can relate output to a specific build while parallel builds are running. -- `type` is the type of machine-readable message being outputted. There are a - set of standard types which are covered later, but each component of Packer - (builders, provisioners, etc.) may output their own custom types as well, - allowing the machine-readable output to be infinitely flexible. +- `target` When you call `packer build` this can be either `''` or individual + build names, e.g. `amazon-ebs`. You'll normally see `''` when output from + the build process is happening, and the build name when artifacts of + particular builds are being referred to. + +- `type` is the type of machine-readable message being outputted. The two most + common `type`s are `ui` and `artifact` - `data` is zero or more comma-separated values associated with the prior type. The exact amount and meaning of this data is type-dependent, so you must read @@ -101,11 +101,43 @@ become a literal `\r`. ### Machine-Readable Message Types -The set of machine-readable message types can be found in the -[machine-readable format](/docs/commands/index.html) complete -documentation section. This section contains documentation on all the message -types exposed by Packer core as well as all the components that ship with -Packer by default. +There are two common message types for the Machine Readable output: + +- `ui`: this means that the information being provided is a human-readable string + that would be sent to stdout even if we aren't in machine-readable mode. There + are three "data" subtypes associated with this type: + + - `say`: in a non-machine-readable format, this would be bolded. Normally it is + used for anouncements about beginning new steps in the build process + + - `message`: the most commonly used message type, used for basic updates during + the build process. + + - `error`: reserved for errors + +- `artifact`: This data type tells you information about what Packer created + during its build. An example of output follows the pattern + `timestamp, buildname, artifact, artifact_number, key, value` where `key` and + `value` contain information about the artifact. + + For example: + + ``` + 1539967803,,ui,say,\n==> Builds finished. The artifacts of successful builds are: + 1539967803,amazon-ebs,artifact-count,2 + 1539967803,amazon-ebs,artifact,0,builder-id,mitchellh.amazonebs + 1539967803,amazon-ebs,artifact,0,id,eu-west-1:ami-04d23aca8bdd36e30 + 1539967803,amazon-ebs,artifact,0,string,AMIs were created:\neu-west-1: ami-04d23aca8bdd36e30\n + 1539967803,amazon-ebs,artifact,0,files-count,0 + 1539967803,amazon-ebs,artifact,0,end + 1539967803,,ui,say,--> amazon-ebs: AMIs were created:\neu-west-1: ami-04d23aca8bdd36e30\n + 1539967803,amazon-ebs,artifact,1,builder-id, + 1539967803,amazon-ebs,artifact,1,id, + 1539967803,amazon-ebs,artifact,1,string, + 1539967803,amazon-ebs,artifact,1,files-count,0 + 2018/10/19 09:50:03 waiting for all plugin processes to complete... + 1539967803,amazon-ebs,artifact,1,end + ``` ## Autocompletion From 4e7a0fd09f2e06ccf4f127ebc42e3460988122e0 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 19 Oct 2018 10:08:06 -0700 Subject: [PATCH 8/9] add version types --- website/source/docs/commands/index.html.md | 55 ++++++++++++++-------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/website/source/docs/commands/index.html.md b/website/source/docs/commands/index.html.md index 05229af06..2a47eaa72 100644 --- a/website/source/docs/commands/index.html.md +++ b/website/source/docs/commands/index.html.md @@ -71,7 +71,7 @@ This makes it more convenient to parse using standard Unix tools such as `awk` o The format is: ``` text -timestamp,,target,type,data... +timestamp,target,type,data... ``` Each component is explained below: @@ -101,7 +101,9 @@ become a literal `\r`. ### Machine-Readable Message Types -There are two common message types for the Machine Readable output: +Here's an incomplete list of types you may see in the machine-readable output: + +You'll see these data types when you run `packer build`: - `ui`: this means that the information being provided is a human-readable string that would be sent to stdout even if we aren't in machine-readable mode. There @@ -115,29 +117,42 @@ There are two common message types for the Machine Readable output: - `error`: reserved for errors +- `artifact-count`: This data type tells you how many artifacts a particular + build produced. + - `artifact`: This data type tells you information about what Packer created during its build. An example of output follows the pattern `timestamp, buildname, artifact, artifact_number, key, value` where `key` and `value` contain information about the artifact. - For example: - - ``` - 1539967803,,ui,say,\n==> Builds finished. The artifacts of successful builds are: - 1539967803,amazon-ebs,artifact-count,2 - 1539967803,amazon-ebs,artifact,0,builder-id,mitchellh.amazonebs - 1539967803,amazon-ebs,artifact,0,id,eu-west-1:ami-04d23aca8bdd36e30 - 1539967803,amazon-ebs,artifact,0,string,AMIs were created:\neu-west-1: ami-04d23aca8bdd36e30\n - 1539967803,amazon-ebs,artifact,0,files-count,0 - 1539967803,amazon-ebs,artifact,0,end - 1539967803,,ui,say,--> amazon-ebs: AMIs were created:\neu-west-1: ami-04d23aca8bdd36e30\n - 1539967803,amazon-ebs,artifact,1,builder-id, - 1539967803,amazon-ebs,artifact,1,id, - 1539967803,amazon-ebs,artifact,1,string, - 1539967803,amazon-ebs,artifact,1,files-count,0 - 2018/10/19 09:50:03 waiting for all plugin processes to complete... - 1539967803,amazon-ebs,artifact,1,end - ``` + For example: + + ``` + 1539967803,,ui,say,\n==> Builds finished. The artifacts of successful builds are: + 1539967803,amazon-ebs,artifact-count,2 + 1539967803,amazon-ebs,artifact,0,builder-id,mitchellh.amazonebs + 1539967803,amazon-ebs,artifact,0,id,eu-west-1:ami-04d23aca8bdd36e30 + 1539967803,amazon-ebs,artifact,0,string,AMIs were created:\neu-west-1: ami-04d23aca8bdd36e30\n + 1539967803,amazon-ebs,artifact,0,files-count,0 + 1539967803,amazon-ebs,artifact,0,end + 1539967803,,ui,say,--> amazon-ebs: AMIs were created:\neu-west-1: ami-04d23aca8bdd36e30\n + 1539967803,amazon-ebs,artifact,1,builder-id, + 1539967803,amazon-ebs,artifact,1,id, + 1539967803,amazon-ebs,artifact,1,string, + 1539967803,amazon-ebs,artifact,1,files-count,0 + 2018/10/19 09:50:03 waiting for all plugin processes to complete... + 1539967803,amazon-ebs,artifact,1,end + ``` + +You'll see these data types when you run `packer version`: + +- `version`: what version of Packer is running + +- `version-prerelease`: Data will contain `dev` if version is prerelease, and + otherwise will be blank. + +- `version-commit`: The git hash for the commit that the branch of Packer is + currently on; most useful for Packer developers. ## Autocompletion From 31bbf1908281fc331b8a011dbb829c1068c8ed74 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 19 Oct 2018 10:15:12 -0700 Subject: [PATCH 9/9] clean up --- website/source/docs/commands/index.html.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/source/docs/commands/index.html.md b/website/source/docs/commands/index.html.md index 2a47eaa72..36cee1383 100644 --- a/website/source/docs/commands/index.html.md +++ b/website/source/docs/commands/index.html.md @@ -79,10 +79,10 @@ Each component is explained below: - `timestamp` is a Unix timestamp in UTC of when the message was printed. -- `target` When you call `packer build` this can be either `''` or individual - build names, e.g. `amazon-ebs`. You'll normally see `''` when output from - the build process is happening, and the build name when artifacts of - particular builds are being referred to. +- `target` When you call `packer build` this can be either empty or individual + build names, e.g. `amazon-ebs`. It is normally empty when builds are in + progress, and the build name when artifacts of particular builds are being + referred to. - `type` is the type of machine-readable message being outputted. The two most common `type`s are `ui` and `artifact`