From 401f41a2bd89400e0ae6ba3050b6d6aa9b5d38a6 Mon Sep 17 00:00:00 2001 From: "tao.yang" Date: Thu, 8 Aug 2024 09:50:34 +0800 Subject: [PATCH] fix: failed to upload codecov Signed-off-by: tao.yang --- .github/codespell-ignorewords | 1 + .github/workflows/lint-golang.yaml | 2 +- pkg/grpcManager/server_implement.go | 10 +++++----- pkg/pluginManager/netreach/agentExecuteTask.go | 6 ++++-- pkg/reportManager/worker.go | 15 ++++++++------- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/codespell-ignorewords b/.github/codespell-ignorewords index e69de29b..add1f5af 100644 --- a/.github/codespell-ignorewords +++ b/.github/codespell-ignorewords @@ -0,0 +1 @@ +NotIn diff --git a/.github/workflows/lint-golang.yaml b/.github/workflows/lint-golang.yaml index 394e9b28..3b999db6 100644 --- a/.github/workflows/lint-golang.yaml +++ b/.github/workflows/lint-golang.yaml @@ -201,7 +201,7 @@ jobs: # ============= upload coverage report - name: Upload to Codecov if: ${{ steps.unitest.outcome != 'failure' }} - uses: codecov/codecov-action@v4.0.1 + uses: codecov/codecov-action@v4 with: directory: './' files: '${{ env.COVERAGE_REPORT_PATH }}' diff --git a/pkg/grpcManager/server_implement.go b/pkg/grpcManager/server_implement.go index d0de4e9f..97127d3c 100644 --- a/pkg/grpcManager/server_implement.go +++ b/pkg/grpcManager/server_implement.go @@ -6,13 +6,14 @@ package grpcManager import ( "context" "fmt" + "io" + "time" + "github.com/kdoctor-io/kdoctor/api/v1/agentGrpc" "github.com/kdoctor-io/kdoctor/pkg/utils" "go.uber.org/zap" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "io" - "time" ) // ------ implement @@ -82,9 +83,8 @@ func (s *myGrpcServer) ExecRemoteCmd(stream agentGrpc.CmdService_ExecRemoteCmdSe } if e := stream.Send(re); e != nil { - c := fmt.Sprintf("grpc server failed to send msg: %v", err) - logger.Error(c) - finalError = fmt.Errorf(c) + finalError := fmt.Errorf("grpc server failed to send msg: %v", e) + logger.Error(finalError.Error()) break } } diff --git a/pkg/pluginManager/netreach/agentExecuteTask.go b/pkg/pluginManager/netreach/agentExecuteTask.go index 0353c7c1..81acce64 100644 --- a/pkg/pluginManager/netreach/agentExecuteTask.go +++ b/pkg/pluginManager/netreach/agentExecuteTask.go @@ -5,11 +5,13 @@ package netreach import ( "context" + "errors" "fmt" + "sync" + "github.com/kdoctor-io/kdoctor/pkg/resource" "github.com/kdoctor-io/kdoctor/pkg/runningTask" networkingv1 "k8s.io/api/networking/v1" - "sync" "go.uber.org/zap" "k8s.io/apimachinery/pkg/runtime" @@ -85,7 +87,7 @@ func (s *PluginNetReach) AgentExecuteTask(logger *zap.Logger, ctx context.Contex if !ok { msg := "failed to get instance" logger.Error(msg) - err = fmt.Errorf(msg) + err = errors.New(msg) return } diff --git a/pkg/reportManager/worker.go b/pkg/reportManager/worker.go index a120db50..1ff70b45 100644 --- a/pkg/reportManager/worker.go +++ b/pkg/reportManager/worker.go @@ -6,16 +6,17 @@ package reportManager import ( "context" "fmt" + "net" + "path" + "strings" + "time" + "github.com/kdoctor-io/kdoctor/pkg/grpcManager" k8sObjManager "github.com/kdoctor-io/kdoctor/pkg/k8ObjManager" "github.com/kdoctor-io/kdoctor/pkg/scheduler" "github.com/kdoctor-io/kdoctor/pkg/types" "github.com/kdoctor-io/kdoctor/pkg/utils" "go.uber.org/zap" - "net" - "path" - "strings" - "time" ) func GetMissRemoteReport(remoteFileList []string, localFileList []string) []string { @@ -116,10 +117,10 @@ func (s *reportManager) runControllerAggregateReportOnce(ctx context.Context, lo podIP, err = k8sObjManager.GetK8sObjManager().ListDeploymentPodIPs(context.Background(), task.RuntimeName, types.ControllerConfig.PodNamespace) } if err != nil { - m := fmt.Sprintf("failed to get kind %s name %s agent ip, error=%v", task.RuntimeKind, task.RuntimeName, err) - logger.Error(m) + m := fmt.Errorf("failed to get kind %s name %s agent ip, error=%v", task.RuntimeKind, task.RuntimeName, err) + logger.Error(m.Error()) // retry - return fmt.Errorf(m) + return m } logger.Sugar().Debugf("podIP : %v", podIP)