Skip to content

Commit bfb6953

Browse files
SkylerMalinowskibsngardner
authored andcommitted
fix(scripts): use guestCpus instead of parsed third term
Normal machine types follow <family>-<class>-<cpus>. Accelerator optimized machines follow <family>-<class>-<gpus>. fix(scripts): accelerator optimized machine type socket handling fix: simplify fetching template.machine_info
1 parent 7e596c0 commit bfb6953

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
55
## \[5.7.6\]
66

77
- Prefix user visible errors with its source.
8+
- Fix accelerator optimized machine type SMT handling.
9+
- Fix accelerator optimized machine type socket handling.
810

911
## \[5.7.5\]
1012

scripts/util.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -1067,22 +1067,16 @@ def get_insert_operations(group_ids, flt=None, project=None, compute=compute):
10671067

10681068

10691069
def machine_type_sockets(template):
1070-
pattern = re.compile("^(?P<family>[^-]+)-(?P<type>[^-]+)-(?P<core>[^-]+)$")
1070+
pattern = re.compile("^(?P<family>[^-]+)")
10711071
m = pattern.match(template.machineType)
10721072
if not m:
10731073
raise Exception(f"template {template} does not match expected regex")
10741074
family = m.group("family")
1075-
try:
1076-
core_count = int(m.group("core"))
1077-
except ValueError:
1078-
log.warning(
1079-
f"core count in machine type {template.machineType} is not an integer. Default to 1 socket."
1080-
)
1081-
return 1
1075+
guestCpus: int = int(template.machine_info.guestCpus)
10821076
socket_count = dict.get(
10831077
{
10841078
"h3": 2,
1085-
"c2d": 2 if core_count > 56 else 1,
1079+
"c2d": 2 if guestCpus > 56 else 1,
10861080
},
10871081
family,
10881082
1, # assume 1 socket for all other families
@@ -1092,11 +1086,11 @@ def machine_type_sockets(template):
10921086

10931087
def isSmt(template):
10941088
machineType: str = template.machineType
1089+
guestCpus: int = int(template.machine_info.guestCpus)
10951090

1096-
pattern = re.compile("^(?P<family>[^-]+)-(?P<type>[^-]+)-(?P<core>[^-]+)$")
1091+
pattern = re.compile("^(?P<family>[^-]+)")
10971092
matches = pattern.match(machineType)
10981093
machineTypeFamily: str = matches["family"]
1099-
machineTypeCore: int = int(matches["core"])
11001094

11011095
# https://cloud.google.com/compute/docs/cpu-platforms
11021096
noSmtFamily = [
@@ -1106,7 +1100,7 @@ def isSmt(template):
11061100
]
11071101
if machineTypeFamily in noSmtFamily:
11081102
return False
1109-
elif machineTypeCore == 1:
1103+
elif guestCpus == 1:
11101104
return False
11111105
return True
11121106

0 commit comments

Comments
 (0)