From c197e6238de2f47883ca9c1e936c50ada404e7c5 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Wed, 19 Jul 2017 16:06:49 -0400 Subject: [PATCH] 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. --- .../openstack/openstack_instances.go | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pkg/cloudprovider/providers/openstack/openstack_instances.go b/pkg/cloudprovider/providers/openstack/openstack_instances.go index d75024c39e5..810858acc75 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_instances.go +++ b/pkg/cloudprovider/providers/openstack/openstack_instances.go @@ -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) {