Skip to content

Commit 4d3c7a8

Browse files
committed
comment-1
1 parent 3c31c86 commit 4d3c7a8

3 files changed

Lines changed: 9 additions & 34 deletions

File tree

pkg/telemetry/collector.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,14 @@ func getMachineType(bp config.Blueprint) string {
235235

236236
// getMachineCategory maps each machine type to its inferred hardware category (CPU/GPU/TPU/Other)
237237
func getMachineCategory(bp config.Blueprint) string {
238-
var categories []string
239-
seen := make(map[string]bool)
238+
machineTypes := getMachineType(bp)
239+
if machineTypes == "" {
240+
return ""
241+
}
240242

241-
for _, m := range config.GetAllBpModules(&bp) {
242-
if mt := getMachineTypeFromModule(m, bp); mt != "" && !seen[mt] {
243-
categories = append(categories, fmt.Sprintf("%s:%s", mt, detectMachineCategory(mt)))
244-
seen[mt] = true
245-
}
243+
var categories []string
244+
for _, mt := range strings.Split(machineTypes, ",") {
245+
categories = append(categories, fmt.Sprintf("%s:%s", mt, detectMachineCategory(mt)))
246246
}
247247

248248
return strings.Join(categories, ",")

pkg/telemetry/collector_test.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,31 +3076,6 @@ func TestGetMachineCategory(t *testing.T) {
30763076
},
30773077
want: "a100-40gb-1:GPU,v6e-4:TPU",
30783078
},
3079-
{
3080-
name: "Handles memory-optimized machine types correctly as CPU",
3081-
bp: config.Blueprint{
3082-
Groups: []config.Group{
3083-
{
3084-
Name: config.GroupName("primary"),
3085-
Modules: []config.Module{
3086-
{
3087-
ID: config.ModuleID("compute_mem_1"),
3088-
Settings: config.NewDict(map[string]cty.Value{
3089-
"machine_type": cty.StringVal("m1-megamem-96"),
3090-
}),
3091-
},
3092-
{
3093-
ID: config.ModuleID("compute_mem_2"),
3094-
Settings: config.NewDict(map[string]cty.Value{
3095-
"machine_type": cty.StringVal("m2-ultramem-208"),
3096-
}),
3097-
},
3098-
},
3099-
},
3100-
},
3101-
},
3102-
want: "m1-megamem-96:CPU,m2-ultramem-208:CPU",
3103-
},
31043079
{
31053080
name: "Handles unknown machine types mapped to Other",
31063081
bp: config.Blueprint{

pkg/telemetry/collector_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,8 @@ func detectMachineCategory(mType string) string {
11141114
// isCPUFallback checks if the machine type contains any of the standard CPU identifiers.
11151115
func isCPUFallback(mType string) bool {
11161116
cpuKeywords := []string{
1117-
"-standard-", "-highmem-", "-highcpu-",
1118-
"-megamem-", "-ultramem-", "custom-",
1117+
"-standard-", "-highmem-", "-highcpu-", "-megamem-",
1118+
"-ultramem-", "custom-", "-micro", "-small", "-medium", "-metal",
11191119
}
11201120
for _, kw := range cpuKeywords {
11211121
if strings.Contains(mType, kw) {

0 commit comments

Comments
 (0)