From 33562f5f4c647beb482d2fc7c4d4ee1c631bc766 Mon Sep 17 00:00:00 2001 From: Sergiu Ghitea <28300158+sergiught@users.noreply.github.com> Date: Thu, 20 Apr 2023 14:17:11 +0200 Subject: [PATCH] Fix concurrency issue --- internal/cli/logs.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/cli/logs.go b/internal/cli/logs.go index 1d4dab323..1880b4024 100644 --- a/internal/cli/logs.go +++ b/internal/cli/logs.go @@ -124,7 +124,7 @@ func tailLogsCmd(cli *cli) *cobra.Command { set := make(map[string]struct{}) list = dedupeLogs(list, set) - go func() { + go func(lastLogID string) { defer close(logsCh) for { @@ -139,7 +139,7 @@ func tailLogsCmd(cli *cli) *cobra.Command { queryParams = append(queryParams, management.Query(inputs.Filter)) } - list, err = cli.api.Log.List(queryParams...) + list, err := cli.api.Log.List(queryParams...) if err != nil { cli.renderer.Errorf("Failed to get latest logs: %v", err) return @@ -150,12 +150,12 @@ func tailLogsCmd(cli *cli) *cobra.Command { lastLogID = list[len(list)-1].GetLogID() } - if len(list) < 90 { + if len(list) < logsPerPageLimit { // Not a lot is happening, sleep on it. - time.Sleep(1 * time.Second) + time.Sleep(time.Second) } } - }() + }(lastLogID) cli.renderer.LogTail(list, logsCh, !cli.debug) return nil