mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(apigateway): compose environment without k8s service (#20616)
This commit is contained in:
@@ -16,6 +16,7 @@ package webconsole
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
@@ -77,10 +78,8 @@ func (m WebConsoleManager) DoCloudShell(s *mcclient.ClientSession, _ jsonutils.J
|
||||
query.Add(jsonutils.NewString("system"), "scope")
|
||||
query.Add(jsonutils.NewString("system-default"), "name")
|
||||
clusters, err := k8s.KubeClusters.List(adminSession, query)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "KubeClusters")
|
||||
}
|
||||
if len(clusters.Data) == 0 {
|
||||
|
||||
climcSshConnect := func(s *mcclient.ClientSession) (jsonutils.JSONObject, error) {
|
||||
// maybe running in docker compose environment, so try to use ssh way
|
||||
if data, err := m.DoClimcSshConnect(s, "climc", 22); err != nil {
|
||||
return nil, httperrors.NewNotFoundError(errors.Wrap(err, "cluster system-default not found, try to use ssh way").Error())
|
||||
@@ -88,6 +87,15 @@ func (m WebConsoleManager) DoCloudShell(s *mcclient.ClientSession, _ jsonutils.J
|
||||
return data, nil
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Cause(err) == errors.ErrNotFound && strings.Contains(err.Error(), "No such service k8s") {
|
||||
return climcSshConnect(s)
|
||||
}
|
||||
return nil, errors.Wrap(err, "KubeClusters")
|
||||
}
|
||||
if len(clusters.Data) == 0 {
|
||||
return climcSshConnect(s)
|
||||
}
|
||||
clusterId, _ := clusters.Data[0].GetString("id")
|
||||
if len(clusterId) == 0 {
|
||||
return nil, httperrors.NewNotFoundError("cluster system-default no id")
|
||||
|
||||
Reference in New Issue
Block a user