Skip to content

Commit 035debb

Browse files
committed
comment-1
1 parent 3c31c86 commit 035debb

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

pkg/telemetry/collector_test.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3077,29 +3077,41 @@ func TestGetMachineCategory(t *testing.T) {
30773077
want: "a100-40gb-1:GPU,v6e-4:TPU",
30783078
},
30793079
{
3080-
name: "Handles memory-optimized machine types correctly as CPU",
3080+
name: "Handles unknown CPU prefixes securely falling back to CPU via string shapes",
30813081
bp: config.Blueprint{
30823082
Groups: []config.Group{
30833083
{
30843084
Name: config.GroupName("primary"),
30853085
Modules: []config.Module{
30863086
{
3087-
ID: config.ModuleID("compute_mem_1"),
3087+
ID: config.ModuleID("compute_node_fallback_1"),
30883088
Settings: config.NewDict(map[string]cty.Value{
3089-
"machine_type": cty.StringVal("m1-megamem-96"),
3089+
"machine_type": cty.StringVal("z9-standard-8"),
30903090
}),
30913091
},
30923092
{
3093-
ID: config.ModuleID("compute_mem_2"),
3093+
ID: config.ModuleID("compute_node_fallback_2"),
30943094
Settings: config.NewDict(map[string]cty.Value{
3095-
"machine_type": cty.StringVal("m2-ultramem-208"),
3095+
"machine_type": cty.StringVal("q4-highmem-32"),
3096+
}),
3097+
},
3098+
{
3099+
ID: config.ModuleID("compute_node_fallback_3"),
3100+
Settings: config.NewDict(map[string]cty.Value{
3101+
"machine_type": cty.StringVal("p2-highcpu-4"),
3102+
}),
3103+
},
3104+
{
3105+
ID: config.ModuleID("compute_node_fallback_4"),
3106+
Settings: config.NewDict(map[string]cty.Value{
3107+
"machine_type": cty.StringVal("custom-3-4096"),
30963108
}),
30973109
},
30983110
},
30993111
},
31003112
},
31013113
},
3102-
want: "m1-megamem-96:CPU,m2-ultramem-208:CPU",
3114+
want: "z9-standard-8:CPU,q4-highmem-32:CPU,p2-highcpu-4:CPU,custom-3-4096:CPU",
31033115
},
31043116
{
31053117
name: "Handles unknown machine types mapped to Other",

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)