Skip to content

Commit

Permalink
Merge pull request #38 from kaytu-io/fix-add-spot
Browse files Browse the repository at this point in the history
fix: show preemptible state
  • Loading branch information
artaasadi committed Jul 8, 2024
2 parents b285c61 + 08e42ba commit d85c61f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugin/preferences/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var DefaultComputeEnginePreferences = []*golang.PreferenceItem{
{Service: "ComputeInstance", Key: "CPUBreathingRoom", IsNumber: true, Value: wrapperspb.String("10"), PreventPinning: true, Unit: "%"},
{Service: "ComputeInstance", Key: "MemoryBreathingRoom", IsNumber: true, Value: wrapperspb.String("10"), PreventPinning: true, Unit: "%"},
{Service: "ComputeInstance", Key: "ExcludeUpsizingFeature", Value: wrapperspb.String("Yes"), PreventPinning: true, PossibleValues: []string{"No", "Yes"}},
{Service: "ComputeInstance", Key: "ProvisioningModel", Pinned: true, PossibleValues: []string{"Standard", "Spot"}},

{Service: "ComputeDisk", Key: "DiskType"},
{Service: "ComputeDisk", Key: "DiskSizeGb", IsNumber: true, Unit: "GiB"},
Expand Down
12 changes: 12 additions & 0 deletions plugin/processor/compute_instance/compute_instance_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,19 @@ func (i ComputeInstanceItem) ComputeInstanceDevice() (*golang.ChartRow, map[stri
}

RegionProperty := &golang.Property{Key: "Region"}
ProvisioningModelProperty := &golang.Property{Key: "Provisioning Model"}
MachineTypeProperty := &golang.Property{Key: "Machine Type"}
MachineFamilyProperty := &golang.Property{Key: "Machine Family"}
CPUProperty := &golang.Property{Key: " CPU"}
MemoryProperty := &golang.Property{Key: " MemoryMB"}

if i.Wastage != nil {
RegionProperty.Current = i.Wastage.Rightsizing.Current.Region
provisioningModel := "Standard"
if i.Wastage.Rightsizing.Current.Preemptible {
provisioningModel = "Preemptible"
}
ProvisioningModelProperty.Current = provisioningModel
MachineTypeProperty.Current = i.Wastage.Rightsizing.Current.MachineType
MachineFamilyProperty.Current = i.Wastage.Rightsizing.Current.MachineFamily

Expand Down Expand Up @@ -88,6 +94,11 @@ func (i ComputeInstanceItem) ComputeInstanceDevice() (*golang.ChartRow, map[stri
Value: utils.FormatPriceFloat(i.Wastage.Rightsizing.Current.Cost - i.Wastage.Rightsizing.Recommended.Cost),
}
RegionProperty.Recommended = i.Wastage.Rightsizing.Recommended.Region
provisioningModel := "Standard"
if i.Wastage.Rightsizing.Recommended.Preemptible {
provisioningModel = "Preemptible"
}
ProvisioningModelProperty.Recommended = provisioningModel
MachineTypeProperty.Recommended = i.Wastage.Rightsizing.Recommended.MachineType
CPUProperty.Recommended = fmt.Sprintf("%d", i.Wastage.Rightsizing.Recommended.Cpu)
MemoryProperty.Recommended = fmt.Sprintf("%d MB", i.Wastage.Rightsizing.Recommended.MemoryMb)
Expand All @@ -99,6 +110,7 @@ func (i ComputeInstanceItem) ComputeInstanceDevice() (*golang.ChartRow, map[stri
properties.Properties = append(properties.Properties, RegionProperty)
properties.Properties = append(properties.Properties, MachineTypeProperty)
properties.Properties = append(properties.Properties, MachineFamilyProperty)
properties.Properties = append(properties.Properties, ProvisioningModelProperty)
properties.Properties = append(properties.Properties, &golang.Property{
Key: "Compute",
})
Expand Down

0 comments on commit d85c61f

Please sign in to comment.