Merge pull request #8397 from adongy/adong/surrogate_spot

amazon-ebssurrogate: allow enabling ena/sr-iov on spot instances
This commit is contained in:
Wilken Rivera 2019-11-21 16:33:21 -05:00 committed by GitHub
commit 40e9c4b517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -13,6 +13,7 @@ import (
) )
type StepModifyEBSBackedInstance struct { type StepModifyEBSBackedInstance struct {
Skip bool
EnableAMIENASupport confighelper.Trilean EnableAMIENASupport confighelper.Trilean
EnableAMISriovNetSupport bool EnableAMISriovNetSupport bool
} }
@ -22,6 +23,11 @@ func (s *StepModifyEBSBackedInstance) Run(ctx context.Context, state multistep.S
instance := state.Get("instance").(*ec2.Instance) instance := state.Get("instance").(*ec2.Instance)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
// Skip when it is a spot instance
if s.Skip {
return multistep.ActionContinue
}
// Set SriovNetSupport to "simple". See http://goo.gl/icuXh5 // Set SriovNetSupport to "simple". See http://goo.gl/icuXh5
// As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge) // As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge)
if s.EnableAMISriovNetSupport { if s.EnableAMISriovNetSupport {

View File

@ -123,13 +123,6 @@ 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)) errs = packer.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName))
} }
if b.config.IsSpotInstance() && (b.config.AMIENASupport.True() || 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 "+
"you use an AMI that already has either SR-IOV or ENA enabled."))
}
if b.config.RunConfig.SpotPriceAutoProduct != "" { if b.config.RunConfig.SpotPriceAutoProduct != "" {
warns = append(warns, "spot_price_auto_product is deprecated and no "+ warns = append(warns, "spot_price_auto_product is deprecated and no "+
"longer necessary for Packer builds. In future versions of "+ "longer necessary for Packer builds. In future versions of "+
@ -294,6 +287,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
DisableStopInstance: b.config.DisableStopInstance, DisableStopInstance: b.config.DisableStopInstance,
}, },
&awscommon.StepModifyEBSBackedInstance{ &awscommon.StepModifyEBSBackedInstance{
Skip: b.config.IsSpotInstance(),
EnableAMISriovNetSupport: b.config.AMISriovNetSupport, EnableAMISriovNetSupport: b.config.AMISriovNetSupport,
EnableAMIENASupport: b.config.AMIENASupport, EnableAMIENASupport: b.config.AMIENASupport,
}, },