Преглед изворни кода

set default storage prices

AjayTripathy пре 6 година
родитељ
комит
5812b9a87f
7 измењених фајлова са 14 додато и 6 уклоњено
  1. 1 0
      cloud/aws.json
  2. 2 2
      cloud/awsprovider.go
  3. 1 0
      cloud/azure.json
  4. 2 1
      cloud/default.json
  5. 1 0
      cloud/gcp.json
  6. 2 0
      cloud/provider.go
  7. 5 3
      costmodel/costmodel.go

+ 1 - 0
cloud/aws.json

@@ -6,6 +6,7 @@
     "RAM": "0.004237",
     "GPU": "0.95",
     "spotRAM": "0.000892",
+    "storage": "0.00005479452",
     "spotLabel": "kops.k8s.io/instancegroup",
     "spotLabelValue": "spotinstance-nodes",
     "awsServiceKeyName": "AKIAXW6UVLRRY5RQGGUX",

+ 2 - 2
cloud/awsprovider.go

@@ -474,7 +474,7 @@ func (aws *AWS) DownloadPricingData() error {
 	for _, pv := range pvList.Items {
 		params, ok := storageClassMap[pv.Spec.StorageClassName]
 		if !ok {
-			klog.Infof("Unable to find params for storageClassName %s", pv.Name)
+			klog.Infof("Unable to find params for storageClassName %s, falling back to default pricing", pv.Name)
 			continue
 		}
 		key := aws.GetPVKey(&pv, params)
@@ -630,7 +630,7 @@ func (aws *AWS) DownloadPricingData() error {
 
 	sp, err := parseSpotData(aws.SpotDataBucket, aws.SpotDataPrefix, aws.ProjectID, aws.SpotDataRegion, aws.ServiceKeyName, aws.ServiceKeySecret)
 	if err != nil {
-		klog.V(1).Infof("Error downloading spot data %s", err.Error())
+		klog.V(1).Infof("Skipping AWS spot data download: %s", err.Error())
 	} else {
 		aws.SpotPricingByInstanceID = sp
 	}

+ 1 - 0
cloud/azure.json

@@ -5,6 +5,7 @@
     "spotCPU": "0.007764", 
     "RAM": "0.001917", 
     "spotRAM": "0.000382",
+    "storage": "0.00005479452" ,
     "azureSubscriptionID": "",
     "azureClientID": "" ,
     "azureClientSecret": "" ,

+ 2 - 1
cloud/default.json

@@ -5,5 +5,6 @@
     "spotCPU": "0.006655",
     "RAM": "0.004237",
     "spotRAM": "0.000892",
-    "GPU": "0.95"
+    "GPU": "0.95",
+    "storage": "0.00005479452"
 }

+ 1 - 0
cloud/gcp.json

@@ -6,5 +6,6 @@
     "RAM": "0.004237",
     "spotRAM": "0.000892",
     "projectID": "guestbook-227502",
+    "storage": "0.00005479452",
     "billingDataDataset": "billing_data.gcp_billing_export_v1_01AC9F_74CF1D_5565A2"
 }

+ 2 - 0
cloud/provider.go

@@ -123,6 +123,7 @@ func GetDefaultPricingData(fname string) (*CustomPricing, error) {
 			RAM:                 "0.004237",
 			SpotRAM:             "0.000892",
 			GPU:                 "0.95",
+			Storage:             "0.00005479452",
 			CustomPricesEnabled: "false",
 		}
 		cj, err := json.Marshal(c)
@@ -150,6 +151,7 @@ type CustomPricing struct {
 	RAM                 string `json:"RAM"`
 	SpotRAM             string `json:"spotRAM"`
 	GPU                 string `json:"GPU"`
+	Storage             string `json:"storage"`
 	SpotLabel           string `json:"spotLabel,omitempty"`
 	SpotLabelValue      string `json:"spotLabelValue,omitempty"`
 	ServiceKeyName      string `json:"awsServiceKeyName,omitempty"`

+ 5 - 3
costmodel/costmodel.go

@@ -681,16 +681,18 @@ func addPVData(clientset kubernetes.Interface, pvClaimMapping map[string]*Persis
 }
 
 func GetPVCost(pv *costAnalyzerCloud.PV, kpv *v1.PersistentVolume, cloud costAnalyzerCloud.Provider) error {
+	cfg, err := cloud.GetConfig()
 	key := cloud.GetPVKey(kpv, pv.Parameters)
 	pvWithCost, err := cloud.PVPricing(key)
 	if err != nil {
 		return err
 	}
-	if pvWithCost == nil {
-		return nil
+	if pvWithCost == nil || pvWithCost.Cost == "" {
+		pv.Cost = cfg.Storage
+		return nil // set default cost
 	}
 	pv.Cost = pvWithCost.Cost
-	return err
+	return nil
 }
 
 func getNodeCost(clientset kubernetes.Interface, cloud costAnalyzerCloud.Provider) (map[string]*costAnalyzerCloud.Node, error) {