@@ -497,24 +497,12 @@ func (cc *Config) Validate(awsClient *aws.Client) error {
497497 }
498498 }
499499
500- // instance_distribution cleanup must be performed before availability_zone cleanup
501- if cc .Spot != nil && * cc .Spot && len (cc .SpotConfig .InstanceDistribution ) >= 0 {
502- cleanedDistribution := []string {* cc .InstanceType }
503- for _ , instanceType := range cc .SpotConfig .InstanceDistribution {
504- if instanceType != * cc .InstanceType {
505- cleanedDistribution = append (cleanedDistribution , instanceType )
506- }
507- }
508- cc .SpotConfig .InstanceDistribution = cleanedDistribution
509- }
510-
511500 if err := cc .validateAvailabilityZones (awsClient ); err != nil {
512501 return errors .Wrap (err , AvailabilityZonesKey )
513502 }
514503
515504 if cc .Spot != nil && * cc .Spot {
516505 cc .AutoFillSpot (awsClient )
517-
518506 chosenInstance := aws.InstanceMetadatas [* cc.Region ][* cc.InstanceType ]
519507 compatibleSpots := CompatibleSpotInstances (awsClient , chosenInstance , cc .SpotConfig .MaxPrice , _spotInstanceDistributionLength )
520508 if len (compatibleSpots ) == 0 {
@@ -654,6 +642,14 @@ func CompatibleSpotInstances(awsClient *aws.Client, targetInstance aws.InstanceM
654642
655643func AutoGenerateSpotConfig (awsClient * aws.Client , spotConfig * SpotConfig , region string , instanceType string ) error {
656644 chosenInstance := aws.InstanceMetadatas [region ][instanceType ]
645+ cleanedDistribution := []string {instanceType }
646+ for _ , spotInstance := range spotConfig .InstanceDistribution {
647+ if spotInstance != instanceType {
648+ cleanedDistribution = append (cleanedDistribution , spotInstance )
649+ }
650+ }
651+ spotConfig .InstanceDistribution = cleanedDistribution
652+
657653 if len (spotConfig .InstanceDistribution ) == 1 {
658654 compatibleSpots := CompatibleSpotInstances (awsClient , chosenInstance , spotConfig .MaxPrice , _spotInstanceDistributionLength )
659655 if len (compatibleSpots ) == 0 {
0 commit comments