From ed563a8a7137e7600f890e565e79aac5999a7f8d Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Fri, 4 Mar 2022 20:55:51 +0000 Subject: [PATCH 1/3] Don't show context cancelled errors in attribute reader Fix #18997 Signed-off-by: Andrew Thornton --- modules/git/repo_attribute.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/git/repo_attribute.go b/modules/git/repo_attribute.go index 772ee6ad12b46..f6b61e56a1027 100644 --- a/modules/git/repo_attribute.go +++ b/modules/git/repo_attribute.go @@ -205,7 +205,7 @@ func (c *CheckAttributeReader) Run() error { return nil }, }) - if err != nil && c.ctx.Err() != nil && err.Error() != "signal: killed" { + if err != nil && c.ctx.Err() != err && err.Error() != "signal: killed" { return fmt.Errorf("failed to run attr-check. Error: %w\nStderr: %s", err, stdErr.String()) } return nil From dd9e22ae8db87667f643638de6d85480be8a4ea5 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 5 Mar 2022 18:35:08 +0000 Subject: [PATCH 2/3] Add some comments Signed-off-by: Andrew Thornton --- modules/git/repo_attribute.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/git/repo_attribute.go b/modules/git/repo_attribute.go index f6b61e56a1027..c68e58ec5146d 100644 --- a/modules/git/repo_attribute.go +++ b/modules/git/repo_attribute.go @@ -205,7 +205,9 @@ func (c *CheckAttributeReader) Run() error { return nil }, }) - if err != nil && c.ctx.Err() != err && err.Error() != "signal: killed" { + if err != nil && // If there is an error we need to return but: + c.ctx.Err() != err && // 1. We should not pass up error due to the context being cancelled + err.Error() != "signal: killed" { // 2. We should not pass up errors due to the program being killed return fmt.Errorf("failed to run attr-check. Error: %w\nStderr: %s", err, stdErr.String()) } return nil From ecf330c1281693e9bfa6a50a5de6ec9f32118b3e Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 8 Mar 2022 08:29:29 +0000 Subject: [PATCH 3/3] Update modules/git/repo_attribute.go as per wxiaoguang Co-authored-by: wxiaoguang --- modules/git/repo_attribute.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/git/repo_attribute.go b/modules/git/repo_attribute.go index c68e58ec5146d..ce24b0a7a3416 100644 --- a/modules/git/repo_attribute.go +++ b/modules/git/repo_attribute.go @@ -206,7 +206,7 @@ func (c *CheckAttributeReader) Run() error { }, }) if err != nil && // If there is an error we need to return but: - c.ctx.Err() != err && // 1. We should not pass up error due to the context being cancelled + c.ctx.Err() != err && // 1. Ignore the context error if the context is cancelled or exceeds the deadline (RunWithContext could return c.ctx.Err() which is Canceled or DeadlineExceeded) err.Error() != "signal: killed" { // 2. We should not pass up errors due to the program being killed return fmt.Errorf("failed to run attr-check. Error: %w\nStderr: %s", err, stdErr.String()) }