From 6632d5f14de888059d4cc1ca80f484ebc468719d Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Thu, 5 Aug 2021 14:17:56 +0800 Subject: [PATCH] fix(region): avoid get openstack hostid panic --- pkg/multicloud/openstack/region.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/multicloud/openstack/region.go b/pkg/multicloud/openstack/region.go index d28afe212b..1491ec9a2c 100644 --- a/pkg/multicloud/openstack/region.go +++ b/pkg/multicloud/openstack/region.go @@ -202,6 +202,16 @@ func (region *SRegion) GetIVMById(id string) (cloudprovider.ICloudVM, error) { if err != nil { return nil, errors.Wrapf(err, "GetInstance(%s)", id) } + hosts, err := region.GetIHosts() + if err != nil { + return nil, err + } + for i := range hosts { + host := hosts[i].(*SHypervisor) + if instance.HypervisorHostname == host.HypervisorHostname { + instance.host = host + } + } return instance, nil }