Skip to content
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

test/connectivity: Add a bit more logging around Hubble connections #1203

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions connectivity/check/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,28 @@ func (a *Action) Run(f func(*Action)) {
// Channel for the flow listener to notify us when ready.
ready := make(chan bool, 1)

wg := sync.WaitGroup{}
wg.Add(1)
// TODO(timo): Use an actual context that can be cancelled by the user.
// `Run()` should take context.
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
defer func() {
cancel()
wg.Wait()
}()

// Start flow listener in the background.
go func() {
if err := a.followFlows(ctx, ready); err != nil {
a.Fatalf("Receiving flows from Hubble Relay: %s", err)
}
a.Debug("Receiving flows from Hubble Relay gracefully closed down.")
wg.Done()
}()

// Wait for at least one Hubble node to signal that it's ready so we don't
// generate any traffic before it can be captured.
timeout := time.NewTimer(10 * time.Second)
timeout := time.NewTimer(30 * time.Second)
defer timeout.Stop()

select {
Expand Down Expand Up @@ -717,11 +724,13 @@ func (a *Action) followFlows(ctx context.Context, ready chan bool) error {
if errors.Is(err, io.EOF) ||
errors.Is(err, context.Canceled) ||
errors.Is(err, context.DeadlineExceeded) {
a.Debugf("Hubble polling ended: %v", err)
return nil
}

// Return gracefully on 'canceled' gRPC error.
if status.Code(err) == codes.Canceled {
a.Debugf("Hubble polling ended: %v", err)
return nil
}

Expand Down