mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-06 21:52:54 +08:00
fix: add version etc. aux handlers to mcp-server (#24685)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -16,6 +16,8 @@ package misc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/cloudmux/pkg/cloudprovider"
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -30,6 +32,20 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules/identity"
|
||||
)
|
||||
|
||||
var (
|
||||
noValidEndpointsForServiceInRegionRegex = regexp.MustCompile(`no valid \w+ endpoints`)
|
||||
)
|
||||
|
||||
func isSkippableVersionErr(err error) bool {
|
||||
cause := errors.Cause(err)
|
||||
if cause == cloudprovider.ErrNotFound || cause == errors.ErrConnectRefused {
|
||||
return true
|
||||
}
|
||||
msg := strings.ToLower(err.Error())
|
||||
return strings.Contains(msg, "connect: connection refused") ||
|
||||
strings.Contains(msg, "connection refused") || noValidEndpointsForServiceInRegionRegex.MatchString(msg)
|
||||
}
|
||||
|
||||
func init() {
|
||||
type VersionOptions struct {
|
||||
SERVICE string `help:"Service type"`
|
||||
@@ -104,7 +120,7 @@ func init() {
|
||||
}
|
||||
ver, err := modules.GetVersion(s, serviceType)
|
||||
if err != nil {
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound || errors.Cause(err) == errors.ErrConnectRefused {
|
||||
if isSkippableVersionErr(err) {
|
||||
continue
|
||||
}
|
||||
vers[serviceType] = err.Error()
|
||||
|
||||
Reference in New Issue
Block a user