Prevent nil pointer panic on node shutdown

If node hasn't fully initialized before getting stopped (such as when
join token isn't valid), most pointer vars in `initSSH` will be nil.
Handle that cleanly.
This commit is contained in:
Andrew Lytvynov 2020-04-22 09:38:49 -07:00 committed by Andrew Lytvynov
parent a7d9a03a09
commit 64b11dd5ab

View file

@ -1588,12 +1588,14 @@ func (process *TeleportProcess) initSSH() error {
warnOnErr(s.Shutdown(payloadContext(payload)))
}
}
if conn.UseTunnel() {
if conn != nil && conn.UseTunnel() {
agentPool.Stop()
}
// Close BPF service.
warnOnErr(ebpf.Close())
if ebpf != nil {
// Close BPF service.
warnOnErr(ebpf.Close())
}
log.Infof("Exited.")
})