Merge pull request #49231 from dims/tolerate-flavor-info-keys

Automatic merge from submit-queue

Tolerate Flavor information for computing instance type

**What this PR does / why we need it**:
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.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-07-20 00:33:46 -07:00 committed by GitHub
commit acc19cafa4

View File

@ -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) {