mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix: no etcd watching if endpoint type is not internal (#15174)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -62,7 +62,11 @@ func InitAuth(options *common_options.CommonOptions, authComplete auth.AuthCompl
|
||||
|
||||
if options.SessionEndpointType != "" {
|
||||
if !utils.IsInStringArray(options.SessionEndpointType,
|
||||
[]string{identity.EndpointInterfacePublic, identity.EndpointInterfaceInternal}) {
|
||||
[]string{
|
||||
identity.EndpointInterfacePublic,
|
||||
identity.EndpointInterfaceInternal,
|
||||
identity.EndpointInterfaceApigateway,
|
||||
}) {
|
||||
log.Fatalf("Invalid session endpoint type %s", options.SessionEndpointType)
|
||||
}
|
||||
auth.SetEndpointType(options.SessionEndpointType)
|
||||
@@ -85,10 +89,12 @@ func InitAuth(options *common_options.CommonOptions, authComplete auth.AuthCompl
|
||||
|
||||
InitBaseAuth(&options.BaseOptions)
|
||||
|
||||
watcher := newEndpointChangeManager()
|
||||
watcher.StartWatching(&identity_modules.EndpointsV3)
|
||||
if options.SessionEndpointType == identity.EndpointInterfaceInternal {
|
||||
watcher := newEndpointChangeManager()
|
||||
watcher.StartWatching(&identity_modules.EndpointsV3)
|
||||
|
||||
startEtcdEndpointPuller()
|
||||
startEtcdEndpointPuller()
|
||||
}
|
||||
}
|
||||
|
||||
func InitBaseAuth(options *common_options.BaseOptions) {
|
||||
@@ -106,7 +112,7 @@ func FetchEtcdServiceInfo() (*identity.EndpointDetails, error) {
|
||||
|
||||
func startEtcdEndpointPuller() {
|
||||
retryInterval := 60
|
||||
etecdUrl, err := auth.GetServiceURL(apis.SERVICE_TYPE_ETCD, consts.GetRegion(), "", "")
|
||||
etecdUrl, err := auth.GetServiceURL(apis.SERVICE_TYPE_ETCD, consts.GetRegion(), "", identity.EndpointInterfaceInternal)
|
||||
if err != nil {
|
||||
log.Errorf("[etcd] GetServiceURL fail %s, retry after %d seconds", err, retryInterval)
|
||||
} else if len(etecdUrl) == 0 {
|
||||
|
||||
@@ -21,7 +21,9 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/util/reflectutils"
|
||||
|
||||
identity_api "yunion.io/x/onecloud/pkg/apis/identity"
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/syncman/watcher"
|
||||
@@ -78,7 +80,13 @@ func StartOptionManagerWithSessionDriver(options interface{}, refreshSeconds int
|
||||
OptionManager.FirstSync()
|
||||
|
||||
if session.IsRemote() {
|
||||
OptionManager.StartWatching(&identity.ServicesV3)
|
||||
var opts *CommonOptions
|
||||
err := reflectutils.FindAnonymouStructPointer(options, &opts)
|
||||
if err != nil {
|
||||
log.Errorf("cannot find CommonOptions in options")
|
||||
} else if opts.SessionEndpointType == identity_api.EndpointInterfaceInternal {
|
||||
OptionManager.StartWatching(&identity.ServicesV3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user