Просмотр исходного кода

Guard second aws.Pricing map access

Since it is _still_ possible that even after `DownloadPricingData` for the key to be 404
Matthew L Daniel 7 лет назад
Родитель
Сommit
f15b483fbc
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      cloud/awsprovider.go

+ 5 - 1
cloud/awsprovider.go

@@ -289,7 +289,11 @@ func (aws *AWS) NodePricing(key string) (*Node, error) {
 		if err != nil {
 			return nil, err
 		}
-		terms := aws.Pricing[key]
+		terms, termsOk := aws.Pricing[key]
+		if !termsOk {
+			log.Printf("Unable to find any Pricing data for \"%s\"", key)
+			return nil, errors.New("Missing aws.Pricing")
+		}
 		if aws.isPreemptible(key) {
 			return &Node{
 				VCPU:         terms.VCpu,