Skip to content

Commit

Permalink
fix(metrics): use Milli resource for cpu when allocating provider met… (
Browse files Browse the repository at this point in the history
#112)

fix(metrics): use Milli resource for cpu when allocating provider metrics

Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Jan 22, 2024
1 parent 0cc24f3 commit 40e1584
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions go/provider/v1/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func NewResourcesMetric() ResourcesMetric {
return ResourcesMetric{
CPU: resource.NewQuantity(0, "m"),
CPU: resource.NewMilliQuantity(0, resource.DecimalSI),
Memory: resource.NewQuantity(0, resource.DecimalSI),
GPU: resource.NewQuantity(0, resource.DecimalSI),
EphemeralStorage: resource.NewQuantity(0, resource.DecimalSI),
Expand All @@ -18,7 +18,7 @@ func NewResourcesMetric() ResourcesMetric {
}
func (inv *ResourcesMetric) AddResources(res types.Resources) {
if res.CPU != nil {
qcpu := *resource.NewQuantity(res.CPU.Units.Val.Int64(), "m")
qcpu := *resource.NewMilliQuantity(res.CPU.Units.Val.Int64(), resource.DecimalSI)
inv.CPU.Add(qcpu)
}

Expand Down Expand Up @@ -47,7 +47,7 @@ func (inv *ResourcesMetric) AddResourceUnit(res dtypes.ResourceUnit) {
val := res.CPU.Units.Dup()
val.Val.MulRaw(int64(res.Count))

qcpu := *resource.NewQuantity(val.Val.Int64(), "m")
qcpu := *resource.NewMilliQuantity(val.Val.Int64(), resource.DecimalSI)
inv.CPU.Add(qcpu)
}

Expand Down

0 comments on commit 40e1584

Please sign in to comment.