-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DynamoDB events by session ID #13284
Conversation
e0e8bb6
to
26b2714
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable to me. My two concerns are:
- Why is the
sessionID
not being propagated in some places? - Is this truly a Dynamo only issue? Does Firestore experience the same sluggishness?
@@ -548,7 +549,7 @@ func (l *Log) searchEventsOnce(fromUTC, toUTC time.Time, namespace string, limit | |||
|
|||
// SearchSessionEvents returns session related events only. This is used to | |||
// find completed sessions. | |||
func (l *Log) SearchSessionEvents(fromUTC, toUTC time.Time, limit int, order types.EventOrder, startKey string, cond *types.WhereExpr) ([]apievents.AuditEvent, string, error) { | |||
func (l *Log) SearchSessionEvents(fromUTC, toUTC time.Time, limit int, order types.EventOrder, startKey string, cond *types.WhereExpr, sessionID string) ([]apievents.AuditEvent, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know if Firestore has the same performance issues as Dynamo? Should the sessionID
be used here at all if provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firestore does only one call though the sessionID index is not leverage during query. I have extended the query call in case if sessionID is present.
@@ -362,7 +362,7 @@ func getCheckpointFromEvent(event apievents.AuditEvent) (string, error) { | |||
return event.GetID(), nil | |||
} | |||
|
|||
func (l *FileLog) SearchSessionEvents(fromUTC, toUTC time.Time, limit int, order types.EventOrder, startKey string, cond *types.WhereExpr) ([]apievents.AuditEvent, string, error) { | |||
func (l *FileLog) SearchSessionEvents(fromUTC, toUTC time.Time, limit int, order types.EventOrder, startKey string, cond *types.WhereExpr, sessionID string) ([]apievents.AuditEvent, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this benefit at all from using the sessionID
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, The sesisonID was only added here to fulfil common interfaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary for this PR, but from looking at findInFile
I think it could potentially benefit from using the sessionID
if one was provided.
@@ -1161,7 +1161,7 @@ func (c *Client) SearchEvents(fromUTC, toUTC time.Time, namespace string, eventT | |||
} | |||
|
|||
// SearchSessionEvents returns session related events to find completed sessions. | |||
func (c *Client) SearchSessionEvents(fromUTC, toUTC time.Time, limit int, order types.EventOrder, startKey string, cond *types.WhereExpr) ([]apievents.AuditEvent, string, error) { | |||
func (c *Client) SearchSessionEvents(fromUTC, toUTC time.Time, limit int, order types.EventOrder, startKey string, cond *types.WhereExpr, sessionID string) ([]apievents.AuditEvent, string, error) { | |||
events, lastKey, err := c.APIClient.SearchSessionEvents(context.TODO(), fromUTC, toUTC, limit, order, startKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the APIClient
be updated to take the sessionID
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only place right now where the ClientI.SearchSessionEvents is called is
Line 2206 in 9cc58cc
return clt.SearchSessionEvents(from, to, limit, order, startKey, nil) |
func (h *Handler) clusterSearchSessionEvents(w http.ResponseWriter, r *http.Request, p httprouter.Params, ctx *SessionContext, site reversetunnel.RemoteSite) (interface{}, error) {
searchSessionEvents := func(clt auth.ClientI, from, to time.Time, limit int, order types.EventOrder, startKey string) ([]apievents.AuditEvent, string, error) {
return clt.SearchSessionEvents(from, to, limit, order, startKey, nil, "")
}
return clusterEventsList(ctx, site, r.URL.Query(), searchSessionEvents)
}
Where both types.WhereExpr
and sesionID are ignored.
The usage of cond *types.WhereExpr
and sessionID string
is only scoped to internal teleport flow when "where" role filtering param was set.
c.Assert(err, check.NotNil) | ||
} | ||
|
||
func (s *DynamoeventsSuite) TestSearchSessionEvensBySessionID(c *check.C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's too bad CI doesn't run the DynamoeventsSuite
tests 😞
40737e0
to
aa4cc95
Compare
@@ -362,7 +362,7 @@ func getCheckpointFromEvent(event apievents.AuditEvent) (string, error) { | |||
return event.GetID(), nil | |||
} | |||
|
|||
func (l *FileLog) SearchSessionEvents(fromUTC, toUTC time.Time, limit int, order types.EventOrder, startKey string, cond *types.WhereExpr) ([]apievents.AuditEvent, string, error) { | |||
func (l *FileLog) SearchSessionEvents(fromUTC, toUTC time.Time, limit int, order types.EventOrder, startKey string, cond *types.WhereExpr, sessionID string) ([]apievents.AuditEvent, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's necessary for this PR, but from looking at findInFile
I think it could potentially benefit from using the sessionID
if one was provided.
@xacrimon Could you take a look ? |
e4585db
to
f734952
Compare
@smallinsky See the table below for backport results.
|
Issue:
#12498
Description:
The pull/10570/files#diff changed the:
call to
The
SearchSessionEvents
is called withtime.Time{}
argument (Right now the/webapi/sites/main/sessions/84079b13-29fc-4adf-9563-d3c654d32c5d/events
call doesn't provide information aboutfromTime
) that result in hundreds of dynamoDB API call -searchEventsWithFilter
will call API for each date withintime.Time{} - time.Now()
range.Fix
In case of
/webapi/sites/main/sessions/84079b13-29fc-4adf-9563-d3c654d32c5d/events
serach session events based on primarysessionID
index instead of secondarytimesearchV2
global index.Alternative approaches:
session.end
ordesktop.session.end
event was found.