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

Merge pull request #346 from kubecost/AjayTripathy-fix-c2-nil

fix c2, fix spot errors
Ajay Tripathy 6 лет назад
Родитель
Сommit
bdf89242b6
2 измененных файлов с 9 добавлено и 1 удалено
  1. 4 0
      pkg/cloud/gcpprovider.go
  2. 5 1
      pkg/cloud/provider.go

+ 4 - 0
pkg/cloud/gcpprovider.go

@@ -603,6 +603,10 @@ func (gcp *GCP) parsePage(r io.Reader, inputKeys map[string]Key, pvKeys map[stri
 					instanceType = "n2standard"
 				}
 
+				if (instanceType == "ram" || instanceType == "cpu") && strings.Contains(strings.ToUpper(product.Description), "COMPUTE OPTIMIZED") {
+					instanceType = "c2standard"
+				}
+
 				if (instanceType == "ram" || instanceType == "cpu") && strings.Contains(strings.ToUpper(product.Description), "E2 INSTANCE") {
 					instanceType = "e2"
 				}

+ 5 - 1
pkg/cloud/provider.go

@@ -64,7 +64,11 @@ type Node struct {
 
 // IsSpot determines whether or not a Node uses spot by usage type
 func (n *Node) IsSpot() bool {
-	return strings.Contains(n.UsageType, "spot") || strings.Contains(n.UsageType, "emptible")
+	if n != nil {
+		return strings.Contains(n.UsageType, "spot") || strings.Contains(n.UsageType, "emptible")
+	} else {
+		return false
+	}
 }
 
 // Network is the interface by which the provider and cost model communicate network egress prices.