Merge pull request #6118 from justinsb/warn_if_missing_image_types_from_map

machine-type generator: Warn if instance type not in ENI map
This commit is contained in:
k8s-ci-robot 2018-11-27 06:49:51 -08:00 committed by GitHub
commit 8b1e299fa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 6 deletions

View File

@ -152,6 +152,8 @@ func run() error {
} }
} }
var warnings []string
seen := map[string]bool{} seen := map[string]bool{}
for _, item := range prices { for _, item := range prices {
for k, v := range item { for k, v := range item {
@ -162,13 +164,15 @@ func run() error {
attributes[k] = v.(string) attributes[k] = v.(string)
} }
if _, ok := seen[attributes["instanceType"]]; ok { instanceType := attributes["instanceType"]
if _, ok := seen[instanceType]; ok {
continue continue
} }
seen[attributes["instanceType"]] = true seen[instanceType] = true
machine := awsup.AWSMachineTypeInfo{ machine := awsup.AWSMachineTypeInfo{
Name: attributes["instanceType"], Name: instanceType,
Cores: stringToInt(attributes["vcpu"]), Cores: stringToInt(attributes["vcpu"]),
} }
@ -201,16 +205,21 @@ func run() error {
machine.ECU = stringToFloat32(attributes["ecu"]) machine.ECU = stringToFloat32(attributes["ecu"])
} }
if enis, enisOK := InstanceENIsAvailable[attributes["instanceType"]]; enisOK { if enis, enisOK := InstanceENIsAvailable[instanceType]; enisOK {
machine.InstanceENIs = enis machine.InstanceENIs = enis
} else {
warnings = append(warnings, fmt.Sprintf("ENIs not known for %s", instanceType))
} }
if ipsPerENI, ipsOK := InstanceIPsAvailable[attributes["instanceType"]]; ipsOK {
if ipsPerENI, ipsOK := InstanceIPsAvailable[instanceType]; ipsOK {
machine.InstanceIPsPerENI = int(ipsPerENI) machine.InstanceIPsPerENI = int(ipsPerENI)
} else {
warnings = append(warnings, fmt.Sprintf("IPs per ENI not known for %s", instanceType))
} }
machines = append(machines, machine) machines = append(machines, machine)
family := strings.Split(attributes["instanceType"], ".")[0] family := strings.Split(instanceType, ".")[0]
families[family] = struct{}{} families[family] = struct{}{}
} }
@ -243,6 +252,14 @@ func run() error {
var output string var output string
if len(warnings) != 0 {
output = output + "\n"
for _, warning := range warnings {
output = output + "// WARNING: " + warning + "\n"
}
output = output + "\n"
}
for _, f := range sortedFamilies { for _, f := range sortedFamilies {
output = output + fmt.Sprintf("\n// %s family", f) output = output + fmt.Sprintf("\n// %s family", f)
previousMachine := "" previousMachine := ""