Skip to content

Commit 474c3e9

Browse files
author
Itxaka
authored
Do not store cpu info if not available (#321)
Fixes #320
1 parent b3ffee1 commit 474c3e9

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pkg/server/register.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright © 2022 SUSE LLC
2+
Copyright © 2023 SUSE LLC
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -499,8 +499,17 @@ func updateInventoryFromSystemData(data []byte, inv *elementalv1.MachineInventor
499499
inv.Labels = map[string]string{}
500500
}
501501
inv.Labels["elemental.cattle.io/TotalMemory"] = strconv.Itoa(int(systemData.Memory.TotalPhysicalBytes))
502-
inv.Labels["elemental.cattle.io/CpuTotalCores"] = strconv.Itoa(int(systemData.CPU.TotalCores))
503-
inv.Labels["elemental.cattle.io/CpuTotalThreads"] = strconv.Itoa(int(systemData.CPU.TotalThreads))
502+
503+
// Both checks below is due to ghw not detecting aarch64 cores/threads properly, so it ends up in a label
504+
// with 0 valuie, which is not useful at all
505+
// tracking bug: https://github.com/jaypipes/ghw/issues/199
506+
if systemData.CPU.TotalCores > 0 {
507+
inv.Labels["elemental.cattle.io/CpuTotalCores"] = strconv.Itoa(int(systemData.CPU.TotalCores))
508+
}
509+
510+
if systemData.CPU.TotalThreads > 0 {
511+
inv.Labels["elemental.cattle.io/CpuTotalThreads"] = strconv.Itoa(int(systemData.CPU.TotalThreads))
512+
}
504513

505514
// This should never happen but just in case
506515
if len(systemData.CPU.Processors) > 0 {

0 commit comments

Comments
 (0)