Przeglądaj źródła

Merge branch 'develop' into readme_video

Matt Ray 2 lat temu
rodzic
commit
ebaed2d94d

+ 22 - 6
pkg/cloud/azure/provider.go

@@ -1097,7 +1097,9 @@ func (az *Azure) NodePricing(key models.Key) (*models.Node, models.PricingMetada
 	config, _ := az.GetConfig()
 
 	// Spot Node
-	if slv, ok := azKey.Labels[config.SpotLabel]; ok && slv == config.SpotLabelValue && config.SpotLabel != "" && config.SpotLabelValue != "" {
+	slv, ok := azKey.Labels[config.SpotLabel]
+	isSpot := ok && slv == config.SpotLabelValue && config.SpotLabel != "" && config.SpotLabelValue != ""
+	if isSpot {
 		features := strings.Split(azKey.Features(), ",")
 		region := features[0]
 		instance := features[1]
@@ -1147,13 +1149,27 @@ func (az *Azure) NodePricing(key models.Key) (*models.Node, models.PricingMetada
 		return nil, meta, fmt.Errorf("No default pricing data available")
 	}
 
+	var vcpuCost string
+	var ramCost string
+	var gpuCost string
+
+	if isSpot {
+		vcpuCost = c.SpotCPU
+		ramCost = c.SpotRAM
+		gpuCost = c.SpotGPU
+	} else {
+		vcpuCost = c.CPU
+		ramCost = c.RAM
+		gpuCost = c.GPU
+	}
+
 	// GPU Node
 	if azKey.isValidGPUNode() {
 		return &models.Node{
-			VCPUCost:         c.CPU,
-			RAMCost:          c.RAM,
+			VCPUCost:         vcpuCost,
+			RAMCost:          ramCost,
 			UsesBaseCPUPrice: true,
-			GPUCost:          c.GPU,
+			GPUCost:          gpuCost,
 			GPU:              azKey.GetGPUCount(),
 		}, meta, nil
 	}
@@ -1170,8 +1186,8 @@ func (az *Azure) NodePricing(key models.Key) (*models.Node, models.PricingMetada
 
 	// Regular Node
 	return &models.Node{
-		VCPUCost:         c.CPU,
-		RAMCost:          c.RAM,
+		VCPUCost:         vcpuCost,
+		RAMCost:          ramCost,
 		UsesBaseCPUPrice: true,
 	}, meta, nil
 }

+ 6 - 6
pkg/costmodel/costmodel.go

@@ -1167,14 +1167,14 @@ func (cm *CostModel) GetNodeCost(cp costAnalyzerCloud.Provider) (map[string]*cos
 
 			cpuToRAMRatio := defaultCPU / defaultRAM
 			if math.IsNaN(cpuToRAMRatio) {
-				log.Warnf("cpuToRAMRatio[defaultCPU: %f / defaultRAM: %f] is NaN. Setting to 0.", defaultCPU, defaultRAM)
-				cpuToRAMRatio = 0
+				log.Warnf("cpuToRAMRatio[defaultCPU: %f / defaultRAM: %f] is NaN. Setting to 10.", defaultCPU, defaultRAM)
+				cpuToRAMRatio = 10
 			}
 
 			gpuToRAMRatio := defaultGPU / defaultRAM
 			if math.IsNaN(gpuToRAMRatio) {
-				log.Warnf("gpuToRAMRatio is NaN. Setting to 0.")
-				gpuToRAMRatio = 0
+				log.Warnf("gpuToRAMRatio is NaN. Setting to 100.")
+				gpuToRAMRatio = 100
 			}
 
 			ramGB := ram / 1024 / 1024 / 1024
@@ -1250,8 +1250,8 @@ func (cm *CostModel) GetNodeCost(cp costAnalyzerCloud.Provider) (map[string]*cos
 
 			cpuToRAMRatio := defaultCPU / defaultRAM
 			if math.IsNaN(cpuToRAMRatio) {
-				log.Warnf("cpuToRAMRatio[defaultCPU: %f / defaultRAM: %f] is NaN. Setting to 0.", defaultCPU, defaultRAM)
-				cpuToRAMRatio = 0
+				log.Warnf("cpuToRAMRatio[defaultCPU: %f / defaultRAM: %f] is NaN. Setting to 10.", defaultCPU, defaultRAM)
+				cpuToRAMRatio = 10
 			}
 
 			ramGB := ram / 1024 / 1024 / 1024

+ 5 - 6
ui/src/Reports.js

@@ -36,14 +36,12 @@ import { currencyCodes } from "./constants/currencyCodes";
 const windowOptions = [
   { name: "Today", value: "today" },
   { name: "Yesterday", value: "yesterday" },
+  { name: "Last 24h", value: "24h" },
+  { name: "Last 48h", value: "48h" },
   { name: "Week-to-date", value: "week" },
-  { name: "Month-to-date", value: "month" },
   { name: "Last week", value: "lastweek" },
-  { name: "Last month", value: "lastmonth" },
-  { name: "Last 7 days", value: "6d" },
-  { name: "Last 30 days", value: "29d" },
-  { name: "Last 60 days", value: "59d" },
-  { name: "Last 90 days", value: "89d" },
+  { name: "Last 7 days", value: "7d" },
+  { name: "Last 14 days", value: "14d" },
 ];
 
 const aggregationOptions = [
@@ -54,6 +52,7 @@ const aggregationOptions = [
   { name: "Controller", value: "controller" },
   { name: "Service", value: "service" },
   { name: "Pod", value: "pod" },
+  { name: "Deployment", value: "deployment" },
   { name: "Container", value: "container" },
 ];
 

+ 3 - 7
ui/src/cloudCost/tokens.js

@@ -1,16 +1,12 @@
 const windowOptions = [
   { name: "Today", value: "today" },
   { name: "Yesterday", value: "yesterday" },
-  { name: "Week-to-date", value: "week" },
-  // { name: "Month-to-date", value: "month" },
-  { name: "Last week", value: "lastweek" },
-  // { name: "Last month", value: "lastmonth" },
   { name: "Last 24h", value: "24h" },
   { name: "Last 48h", value: "48h" },
+  { name: "Week-to-date", value: "week" },
+  { name: "Last week", value: "lastweek" },
   { name: "Last 7 days", value: "7d" },
-  // { name: "Last 30 days", value: "30d" },
-  // { name: "Last 60 days", value: "60d" },
-  // { name: "Last 90 days", value: "90d" },
+  { name: "Last 14 days", value: "14d" },
 ];
 
 const aggregationOptions = [