mirror of
https://github.com/openziti/ziti.git
synced 2026-10-12 07:18:36 +00:00
Added new 'network.createSessionRetries' option to control number of session creation attempts. (#175)
This commit is contained in:
@@ -298,8 +298,6 @@ func (network *Network) LinkChanged(l *Link) {
|
||||
}
|
||||
|
||||
func (network *Network) CreateSession(srcR *Router, clientId *identity.TokenId, service string) (*session, error) {
|
||||
log := pfxlog.Logger()
|
||||
|
||||
// 1: Allocate Session Identifier
|
||||
sessionIdHash, err := network.sequence.NextHash()
|
||||
if err != nil {
|
||||
@@ -350,10 +348,10 @@ func (network *Network) CreateSession(srcR *Router, clientId *identity.TokenId,
|
||||
network.removeRouteSender(rs)
|
||||
if err != nil {
|
||||
retries++
|
||||
if retries > 3 {
|
||||
if retries > network.options.CreateSessionRetries {
|
||||
continue
|
||||
} else {
|
||||
return nil, errors.Wrap(err, "error routing")
|
||||
return nil, errors.Wrapf(err, "exceeded maximum [%d] retries creating session [s/%s]", network.options.CreateSessionRetries, sessionId.Token)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +367,7 @@ func (network *Network) CreateSession(srcR *Router, clientId *identity.TokenId,
|
||||
network.sessionController.add(ss)
|
||||
network.SessionCreated(ss.Id, ss.ClientId, ss.Service.Id, ss.Circuit)
|
||||
|
||||
log.Debugf("created session [s/%s] ==> %s", sessionId.Token, ss.Circuit)
|
||||
logrus.Debugf("created session [s/%s] ==> %s", sessionId.Token, ss.Circuit)
|
||||
return ss, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ type Options struct {
|
||||
RerouteCap uint32
|
||||
}
|
||||
RouteTimeout time.Duration
|
||||
CreateSessionRetries int
|
||||
CtrlChanLatencyInterval time.Duration
|
||||
}
|
||||
|
||||
@@ -36,6 +37,7 @@ func DefaultOptions() *Options {
|
||||
options := &Options{
|
||||
CycleSeconds: 60,
|
||||
RouteTimeout: 10 * time.Second,
|
||||
CreateSessionRetries: 3,
|
||||
CtrlChanLatencyInterval: 10 * time.Second,
|
||||
}
|
||||
options.Smart.RerouteFraction = 0.02
|
||||
@@ -62,6 +64,14 @@ func LoadOptions(src map[interface{}]interface{}) (*Options, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if value, found := src["createSessionRetries"]; found {
|
||||
if createSessionRetries, ok := value.(int); ok {
|
||||
options.CreateSessionRetries = createSessionRetries
|
||||
} else {
|
||||
return nil, errors.New("invalid value for 'createSessionRetries'")
|
||||
}
|
||||
}
|
||||
|
||||
if value, found := src["ctrlChanLatencyIntervalSeconds"]; found {
|
||||
if val, ok := value.(int); ok {
|
||||
options.CtrlChanLatencyInterval = time.Duration(val) * time.Second
|
||||
|
||||
Reference in New Issue
Block a user