Skip to content

Commit

Permalink
feat: export mid resource metrics
Browse files Browse the repository at this point in the history
Signed-off-by: j4ckstraw <j4ckstraw@foxmail.com>
  • Loading branch information
j4ckstraw committed Jan 29, 2024
1 parent 22ffeec commit 623f38d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/koordlet/statesinformer/impl/states_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,10 @@ func recordNodeResources(node *corev1.Node) {
metrics.RecordNodeResourceAllocatable(string(apiext.BatchCPU), metrics.UnitInteger, float64(batchCPU.Value()))
batchMemory := node.Status.Allocatable.Name(apiext.BatchMemory, resource.BinarySI)
metrics.RecordNodeResourceAllocatable(string(apiext.BatchMemory), metrics.UnitByte, float64(batchMemory.Value()))

// record node allocatable of MidCPU & MidMemory
midCPU := node.Status.Allocatable.Name(apiext.MidCPU, resource.DecimalSI)
metrics.RecordNodeResourceAllocatable(string(apiext.MidCPU), metrics.UnitInteger, float64(midCPU.Value()))
midMemory := node.Status.Allocatable.Name(apiext.MidMemory, resource.BinarySI)
metrics.RecordNodeResourceAllocatable(string(apiext.MidMemory), metrics.UnitByte, float64(midMemory.Value()))
}
13 changes: 13 additions & 0 deletions pkg/koordlet/statesinformer/impl/states_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,17 @@ func recordContainerResourceMetrics(container *corev1.Container, containerStatus
if q, ok := container.Resources.Limits[apiext.BatchMemory]; ok {
metrics.RecordContainerResourceLimits(string(apiext.BatchMemory), metrics.UnitByte, containerStatus, pod, float64(util.QuantityPtr(q).Value()))
}
// record pod requests/limits of MidCPU & MidMemory
if q, ok := container.Resources.Requests[apiext.MidCPU]; ok {
metrics.RecordContainerResourceRequests(string(apiext.MidCPU), metrics.UnitInteger, containerStatus, pod, float64(util.QuantityPtr(q).Value()))
}
if q, ok := container.Resources.Requests[apiext.MidMemory]; ok {
metrics.RecordContainerResourceRequests(string(apiext.MidMemory), metrics.UnitInteger, containerStatus, pod, float64(util.QuantityPtr(q).Value()))
}
if q, ok := container.Resources.Limits[apiext.MidCPU]; ok {
metrics.RecordContainerResourceLimits(string(apiext.MidCPU), metrics.UnitByte, containerStatus, pod, float64(util.QuantityPtr(q).Value()))
}
if q, ok := container.Resources.Limits[apiext.MidMemory]; ok {
metrics.RecordContainerResourceLimits(string(apiext.MidMemory), metrics.UnitByte, containerStatus, pod, float64(util.QuantityPtr(q).Value()))
}
}

0 comments on commit 623f38d

Please sign in to comment.