From 2a6737061d2b86dd6718154efae923282c32fe4f Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Thu, 21 Feb 2019 18:16:17 +0800 Subject: [PATCH] fix: find empty endpoints due to invalid duplicate service --- pkg/mcclient/token2.go | 2 +- pkg/mcclient/token3.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/mcclient/token2.go b/pkg/mcclient/token2.go index f64d045014..81645b4396 100644 --- a/pkg/mcclient/token2.go +++ b/pkg/mcclient/token2.go @@ -191,7 +191,7 @@ func (catalog KeystoneServiceCatalogV2) getRegions() []string { func (catalog KeystoneServiceCatalogV2) getServiceEndpoint(service, region, zone string) (KeystoneEndpointV2, error) { var selected KeystoneEndpointV2 for i := 0; i < len(catalog); i++ { - if service == catalog[i].Type { + if service == catalog[i].Type && len(catalog[i].Endpoints) > 0 { if len(region) == 0 { if len(catalog[i].Endpoints) >= 1 { selected = catalog[i].Endpoints[0] diff --git a/pkg/mcclient/token3.go b/pkg/mcclient/token3.go index 38e962b119..3f943397e2 100644 --- a/pkg/mcclient/token3.go +++ b/pkg/mcclient/token3.go @@ -270,7 +270,7 @@ func (catalog KeystoneServiceCatalogV3) GetServiceURLs(service, region, zone, en endpointType = "internalURL" } for i := 0; i < len(catalog); i++ { - if service == catalog[i].Type { + if service == catalog[i].Type && len(catalog[i].Endpoints) > 0 { var selected []string regeps := make(map[string][]string) regionzone := ""