From 799dfe377ad8ba3b4868c93ea5b98427c2be5fed Mon Sep 17 00:00:00 2001 From: Qiaozp Date: Mon, 31 Oct 2022 23:12:37 +0800 Subject: [PATCH] fix filter nil will cut all log Signed-off-by: Qiaozp --- pkg/apiserver/domain/service/pipeline.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/apiserver/domain/service/pipeline.go b/pkg/apiserver/domain/service/pipeline.go index 162b8cbbb..a47ec6668 100644 --- a/pkg/apiserver/domain/service/pipeline.go +++ b/pkg/apiserver/domain/service/pipeline.go @@ -673,16 +673,17 @@ func getResourceLogs(ctx context.Context, config *rest.Config, cli client.Client } break } - for _, f := range filters { - if strings.Contains(s, f) { - buf.WriteString(s) + if filters != nil && len(filters) != 0 { + for _, f := range filters { + if strings.Contains(s, f) { + buf.WriteString(s) + } } } } if readErr != nil { errPrint(buf, "error in copy information from APIServer to buffer: %s", err.Error()) log.Logger.Errorf("fail to copy pod logs: %v", err) - return } logMap.Store(fmt.Sprintf("%s/%s", pc.Name, pc.Container), buf.String()) }(pc)