-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client: Return empty values when host stats fail #6349
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package stats | ||
|
||
import ( | ||
"fmt" | ||
"math" | ||
"runtime" | ||
"sync" | ||
|
@@ -117,39 +116,45 @@ func (h *HostStatsCollector) collectLocked() error { | |
// Determine up-time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - I'm planning on going back and refactoring this a little bit next week. Mostly wanted to get something together to help folks with debugging. |
||
uptime, err := host.Uptime() | ||
if err != nil { | ||
return err | ||
h.logger.Error("failed to collect upstime stats", "error", err) | ||
uptime = 0 | ||
} | ||
hs.Uptime = uptime | ||
|
||
// Collect memory stats | ||
mstats, err := h.collectMemoryStats() | ||
if err != nil { | ||
return err | ||
h.logger.Error("failed to collect memory stats", "error", err) | ||
mstats = &MemoryStats{} | ||
} | ||
hs.Memory = mstats | ||
|
||
// Collect cpu stats | ||
cpus, ticks, err := h.collectCPUStats() | ||
if err != nil { | ||
return err | ||
h.logger.Error("failed to collect cpu stats", "error", err) | ||
cpus = []*CPUStats{} | ||
ticks = 0 | ||
} | ||
hs.CPU = cpus | ||
hs.CPUTicksConsumed = ticks | ||
|
||
// Collect disk stats | ||
diskStats, err := h.collectDiskStats() | ||
if err != nil { | ||
return err | ||
h.logger.Error("failed to collect disk stats", "error", err) | ||
hs.DiskStats = []*DiskStats{} | ||
} | ||
hs.DiskStats = diskStats | ||
|
||
// Getting the disk stats for the allocation directory | ||
usage, err := disk.Usage(h.allocDir) | ||
if err != nil { | ||
return fmt.Errorf("failed to find disk usage of alloc_dir %q: %v", h.allocDir, err) | ||
h.logger.Error("failed to find disk usage of alloc", "alloc_dir", h.allocDir, "error", err) | ||
hs.AllocDirStats = &DiskStats{} | ||
} else { | ||
hs.AllocDirStats = h.toDiskStats(usage, nil) | ||
} | ||
hs.AllocDirStats = h.toDiskStats(usage, nil) | ||
|
||
// Collect devices stats | ||
deviceStats := h.collectDeviceGroupStats() | ||
hs.DeviceStats = deviceStats | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would adjust the casing, we typically have lower case message. Also,
MemoryStats is nil
is low level implementation; would be nice to have a user facing message, maybe something like: