Set start_time in k8s session.end event (#4770)

The field got lost somewhere during recent refactors. Set the start_time
to correctly show session duration on web UI.
This commit is contained in:
Andrew Lytvynov 2020-11-10 17:12:10 +00:00 committed by GitHub
parent ce8c83d722
commit 0711da03b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -617,6 +617,7 @@ func (f *Forwarder) exec(ctx *authContext, w http.ResponseWriter, req *http.Requ
f.Errorf("Failed to create cluster session: %v.", err)
return nil, trace.Wrap(err)
}
sessionStart := f.Clock.Now().UTC()
if request.tty {
// Emit "new session created" event. There are no initial terminal
@ -714,7 +715,8 @@ func (f *Forwarder) exec(ctx *authContext, w http.ResponseWriter, req *http.Requ
Interactive: true,
// There can only be 1 participant, k8s sessions are not join-able.
Participants: []string{ctx.User.GetName()},
EndTime: time.Now().UTC(),
StartTime: sessionStart,
EndTime: f.Clock.Now().UTC(),
}
if err := emitter.EmitAuditEvent(f.Context, sessionEndEvent); err != nil {
f.WithError(err).Warn("Failed to emit session end event.")