Merge pull request #8786 from swordqiu/hotfix/qj-keystone-init-empty-catalog

fix: keystone init empty catalogy cause panic
This commit is contained in:
Zexi Li
2020-11-13 15:23:44 +08:00
committed by GitHub
2 changed files with 7 additions and 13 deletions
+1 -12
View File
@@ -61,7 +61,7 @@ func policyReadFilter(session *mcclient.ClientSession, s jsonutils.JSONObject, q
}
func policyWriteFilter(session *mcclient.ClientSession, s jsonutils.JSONObject, query jsonutils.JSONObject) (jsonutils.JSONObject, error) {
ret := jsonutils.NewDict()
ret := s.(*jsonutils.JSONDict).CopyExcludes("policy")
if s.Contains("policy") {
blobJson, err := s.Get("policy")
if err != nil {
@@ -78,17 +78,6 @@ func policyWriteFilter(session *mcclient.ClientSession, s jsonutils.JSONObject,
// ret.Add(jsonutils.NewString(blobJson.String()), "blob")
ret.Add(blobJson, "blob")
}
for _, k := range []string{
"name", "type", "enabled", "domain", "domain_id", "project_domain", "description", "is_public", "public_scope", "shared_domains", "scope", "is_system",
} {
if s.Contains(k) {
val, err := s.Get(k)
if err != nil {
return nil, err
}
ret.Add(val, k)
}
}
return ret, nil
}
+6 -1
View File
@@ -27,6 +27,7 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/gotypes"
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/identity"
@@ -147,7 +148,11 @@ func (this *ClientSession) GetServiceVersionURL(service, endpointType, apiVersio
endpointType = this.endpointType
}
service = this.getServiceName(service, apiVersion)
url, err := this.GetServiceCatalog().GetServiceURL(service, this.region, this.zone, endpointType)
catalog := this.GetServiceCatalog()
if gotypes.IsNil(catalog) {
return this.client.authUrl, nil
}
url, err := catalog.GetServiceURL(service, this.region, this.zone, endpointType)
if err != nil && service == api.SERVICE_TYPE {
return this.client.authUrl, nil
}