Skip to content

Commit

Permalink
Merge pull request #448 from gravitational/sasha/identity
Browse files Browse the repository at this point in the history
recover back AuthIdentityEvent
  • Loading branch information
kontsevoy committed Jun 9, 2016
2 parents 5d91a14 + 235fc64 commit bc4c8f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/auth/tun.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (

// dialRetryInterval specifies the time interval tun client waits to retry
// dialing the same auth server
const dialRetryInterval = time.Duration(time.Millisecond * 50)
const dialRetryInterval = 100 * time.Millisecond

// AuthTunnel listens on TCP/IP socket and accepts SSH connections. It then establishes
// an SSH tunnell which HTTP requests travel over. In other words, the Auth Service API
Expand Down Expand Up @@ -621,7 +621,7 @@ func (c *TunClient) GetDialer() AccessPointDialer {
if err == nil {
return conn, nil
}
time.Sleep(dialRetryInterval * time.Duration(attempt))
time.Sleep(4 * time.Duration(attempt) * dialRetryInterval)
}
log.Error(err)
return nil, trace.Wrap(err)
Expand Down
27 changes: 20 additions & 7 deletions lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const (
// TeleportExitEvent is generated when someone is askign Teleport Process to close
// all listening sockets and exit
TeleportExitEvent = "TeleportExit"
// AuthIdentityEvent is generated when auth's identity has been initialized
AuthIdentityEvent = "AuthIdentity"
)

// RoleConfig is a configuration for a server role (either proxy or node)
Expand Down Expand Up @@ -330,23 +332,35 @@ func (process *TeleportProcess) initAuthService(authority auth.Authority) error
auth.SetLimiter(limiter),
)
if err != nil {
utils.Consolef(cfg.Console, "[PROXY] Error: %v", err)
utils.Consolef(cfg.Console, "[AUTH] Error: %v", err)
return trace.Wrap(err)
}
if err := authTunnel.Start(); err != nil {
if askedToExit {
log.Infof("[PROXY] Auth Tunnel exited")
log.Infof("[AUTH] Auth Tunnel exited")
return nil
}
utils.Consolef(cfg.Console, "[PROXY] Error: %v", err)
utils.Consolef(cfg.Console, "[AUTH] Error: %v", err)
return trace.Wrap(err)
}
return nil
})

// Heart beat auth server presence, this is not the best place for this
// logic, consolidate it into auth package later
var authClient *auth.TunClient
process.RegisterFunc(func() error {
// Heart beat auth server presence, this is not the best place for this
// logic, consolidate it into auth package later
connector, err := process.connectToAuthService(teleport.RoleAdmin)
if err != nil {
return trace.Wrap(err)
}
// External integrations rely on this event:
process.BroadcastEvent(Event{Name: AuthIdentityEvent, Payload: connector})
process.onExit(func(payload interface{}) {
connector.Client.Close()
})
return nil
})

process.RegisterFunc(func() error {
srv := services.Server{
ID: process.Config.HostUUID,
Expand Down Expand Up @@ -389,7 +403,6 @@ func (process *TeleportProcess) initAuthService(authority auth.Authority) error
process.onExit(func(payload interface{}) {
askedToExit = true
authTunnel.Close()
authClient.Close()
log.Infof("[AUTH] auth service exited")
})
return nil
Expand Down

0 comments on commit bc4c8f4

Please sign in to comment.