Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit 4246a22

Browse files
author
Kubernetes Submit Queue
authored
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 ```
2 parents 244515a + 132b102 commit 4246a22

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

pkg/cloudprovider/providers/openstack/openstack_instances.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,17 @@ func (i *Instances) InstanceType(name types.NodeName) (string, error) {
188188
}
189189

190190
func srvInstanceType(srv *servers.Server) (string, error) {
191-
val, ok := srv.Flavor["name"]
192-
193-
if !ok {
194-
return "", fmt.Errorf("flavor name not present in server info")
195-
}
196-
197-
flavor, ok := val.(string)
198-
199-
if !ok {
200-
return "", fmt.Errorf("flavor name is not a string")
191+
keys := []string{"name", "id", "original_name"}
192+
for _, key := range keys {
193+
val, found := srv.Flavor[key]
194+
if found {
195+
flavor, ok := val.(string)
196+
if ok {
197+
return flavor, nil
198+
}
199+
}
201200
}
202-
203-
return flavor, nil
201+
return "", fmt.Errorf("flavor name/id not found")
204202
}
205203

206204
func instanceIDFromProviderID(providerID string) (instanceID string, err error) {

0 commit comments

Comments
 (0)