Skip to content

Commit

Permalink
hubble/recorder: Install recorder before the sink
Browse files Browse the repository at this point in the history
This ensures the stop timer is not started before it can receive any
data.

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
  • Loading branch information
gandro committed Jul 28, 2021
1 parent 13ec4f2 commit 427caea
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/hubble/recorder/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,11 @@ func (s *Service) startRecording(
},
}

handle, err = s.dispatch.StartSink(ctx, config)
if err != nil {
return nil, "", err
}

// Upserting a new recorder can take up to a few seconds due to datapath
// regeneration. To avoid having the stop condition timer on the sink
// already running while the recorder is still being upserted, we install
// the recorder before the sink. This is safe, as sink.Dispatch silently
// ignores recordings for unknown sinks.
recInfo := &recorder.RecInfo{
ID: recorder.ID(ruleID),
CapLen: uint16(capLen),
Expand All @@ -372,6 +372,11 @@ func (s *Service) startRecording(
return nil, "", err
}

handle, err = s.dispatch.StartSink(ctx, config)
if err != nil {
return nil, "", err
}

// Ensure to delete the above recorder when the sink has stopped
go func() {
<-handle.Done
Expand Down

0 comments on commit 427caea

Please sign in to comment.