[sbserver] handle missing cpu stats
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
parent
464a4977a6
commit
79cb4b0000
@ -64,12 +64,14 @@ func (c *criService) toCRIContainerStats(
|
|||||||
return nil, fmt.Errorf("failed to decode container metrics for %q: %w", cntr.ID, err)
|
return nil, fmt.Errorf("failed to decode container metrics for %q: %w", cntr.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is a calculated value and should be computed for all OSes
|
if cs.Cpu != nil && cs.Cpu.UsageCoreNanoSeconds != nil {
|
||||||
nanoUsage, err := c.getUsageNanoCores(cntr.Metadata.ID, false, cs.Cpu.UsageCoreNanoSeconds.Value, time.Unix(0, cs.Cpu.Timestamp))
|
// this is a calculated value and should be computed for all OSes
|
||||||
if err != nil {
|
nanoUsage, err := c.getUsageNanoCores(cntr.Metadata.ID, false, cs.Cpu.UsageCoreNanoSeconds.Value, time.Unix(0, cs.Cpu.Timestamp))
|
||||||
return nil, fmt.Errorf("failed to get usage nano cores, containerID: %s: %w", cntr.Metadata.ID, err)
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get usage nano cores, containerID: %s: %w", cntr.Metadata.ID, err)
|
||||||
|
}
|
||||||
|
cs.Cpu.UsageNanoCores = &runtime.UInt64Value{Value: nanoUsage}
|
||||||
}
|
}
|
||||||
cs.Cpu.UsageNanoCores = &runtime.UInt64Value{Value: nanoUsage}
|
|
||||||
|
|
||||||
containerStats.Stats = append(containerStats.Stats, cs)
|
containerStats.Stats = append(containerStats.Stats, cs)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user