mirror of https://github.com/k3s-io/k3s
Tolerate Flavor information for computing instance type
Current devstack seems to return "id", and an upcoming change using nova's microversion will be returning "original_name": https://blueprints.launchpad.net/nova/+spec/instance-flavor-api So let's just inspect what is present and use that to figure out the instance type.pull/6/head
parent
ebf24c14a9
commit
c197e6238d
|
@ -188,19 +188,17 @@ func (i *Instances) InstanceType(name types.NodeName) (string, error) {
|
|||
}
|
||||
|
||||
func srvInstanceType(srv *servers.Server) (string, error) {
|
||||
val, ok := srv.Flavor["name"]
|
||||
|
||||
if !ok {
|
||||
return "", fmt.Errorf("flavor name not present in server info")
|
||||
keys := []string{"name", "id", "original_name"}
|
||||
for _, key := range keys {
|
||||
val, found := srv.Flavor[key]
|
||||
if found {
|
||||
flavor, ok := val.(string)
|
||||
if ok {
|
||||
return flavor, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flavor, ok := val.(string)
|
||||
|
||||
if !ok {
|
||||
return "", fmt.Errorf("flavor name is not a string")
|
||||
}
|
||||
|
||||
return flavor, nil
|
||||
return "", fmt.Errorf("flavor name/id not found")
|
||||
}
|
||||
|
||||
func instanceIDFromProviderID(providerID string) (instanceID string, err error) {
|
||||
|
|
Loading…
Reference in New Issue