mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(apigateway): compose environment without k8s service (#20617)
This commit is contained in:
@@ -155,10 +155,8 @@ func (m WebConsoleManager) doCloudShell(s *mcclient.ClientSession, info *webcons
|
||||
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())
|
||||
@@ -166,6 +164,15 @@ func (m WebConsoleManager) doCloudShell(s *mcclient.ClientSession, info *webcons
|
||||
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