Skip to content

Commit

Permalink
fix: failed to upload codecov
Browse files Browse the repository at this point in the history
Signed-off-by: tao.yang <tao.yang@daocloud.io>
  • Loading branch information
ty-dc committed Aug 21, 2024
1 parent 21d8e1a commit 4362999
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 105 deletions.
1 change: 1 addition & 0 deletions .github/codespell-ignorewords
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NotIn
2 changes: 1 addition & 1 deletion .github/workflows/lint-golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand Down
4 changes: 2 additions & 2 deletions pkg/apiserver/registry/kdoctor/kdoctorreport/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package kdoctorreport

import (
"context"
"fmt"
"errors"

"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -74,7 +74,7 @@ func (p kdoctorReportStrategy) ValidateUpdate(ctx context.Context, obj, old runt
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
kdoctorReport, ok := obj.(*v1beta1.KdoctorReport)
if !ok {
return nil, nil, fmt.Errorf("given object is not a KdoctorReport")
return nil, nil, errors.New("given object is not a KdoctorReport")
}
return labels.Set(kdoctorReport.ObjectMeta.Labels), SelectableFields(kdoctorReport), nil
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/fileManager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
package fileManager

import (
"errors"
"fmt"
"go.uber.org/zap"
"os"
"path"
"strings"
"time"

"go.uber.org/zap"
)

type FileManager interface {
Expand All @@ -28,7 +30,7 @@ var _ FileManager = &fileManager{}

func NewManager(logger *zap.Logger, reportDir string, cleanInterval time.Duration) (FileManager, error) {
if logger == nil || len(reportDir) == 0 {
return nil, fmt.Errorf("bad request")
return nil, errors.New("bad request")

Check warning on line 33 in pkg/fileManager/manager.go

View check run for this annotation

Codecov / codecov/patch

pkg/fileManager/manager.go#L33

Added line #L33 was not covered by tests
}

// create directory if not exist
Expand Down Expand Up @@ -58,7 +60,7 @@ func NewManager(logger *zap.Logger, reportDir string, cleanInterval time.Duratio
func getTaskFileEndTime(filePath string) (endTime time.Time, err error) {
name := path.Base(filePath)
if len(name) == 0 {
return time.Time{}, fmt.Errorf("failed to get file name")
return time.Time{}, errors.New("failed to get file name")

Check warning on line 63 in pkg/fileManager/manager.go

View check run for this annotation

Codecov / codecov/patch

pkg/fileManager/manager.go#L63

Added line #L63 was not covered by tests
}
v := strings.Split(name, "_")
if len(v) < 3 {
Expand Down
3 changes: 2 additions & 1 deletion pkg/fileManager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"time"

"github.com/kdoctor-io/kdoctor/pkg/fileManager"
"github.com/kdoctor-io/kdoctor/pkg/logger"
"time"
)

var _ = Describe("test fileManager", Label("fileManager"), func() {
Expand Down
10 changes: 5 additions & 5 deletions pkg/grpcManager/server_implement.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/k8ObjManager/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package k8sObjManager
import (
"context"
"encoding/json"
"errors"
"fmt"

"github.com/kdoctor-io/kdoctor/pkg/types"
"github.com/kdoctor-io/kdoctor/pkg/utils"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -121,7 +123,7 @@ func (nm *k8sObjManager) ListDaemonsetPodMultusIPs(ctx context.Context, daemonse
return nil, e
}
if len(podlist) == 0 {
return nil, fmt.Errorf("failed to get any pods")
return nil, errors.New("failed to get any pods")
}
return parseMultusIP(podlist)
}
Expand All @@ -133,7 +135,7 @@ func (nm *k8sObjManager) ListDaemonsetPodIPs(ctx context.Context, daemonsetName,
return nil, e
}
if len(podlist) == 0 {
return nil, fmt.Errorf("failed to get any pods")
return nil, errors.New("failed to get any pods")
}

result := PodIps{}
Expand Down
6 changes: 4 additions & 2 deletions pkg/k8ObjManager/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ package k8sObjManager

import (
"context"
"errors"
"fmt"

"github.com/kdoctor-io/kdoctor/pkg/utils"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -51,7 +53,7 @@ func (nm *k8sObjManager) ListDeploymentPodIPs(ctx context.Context, deploymentNam
return nil, e
}
if len(podList) == 0 {
return nil, fmt.Errorf("failed to get any pods")
return nil, errors.New("failed to get any pods")
}

result := PodIps{}
Expand All @@ -77,7 +79,7 @@ func (nm *k8sObjManager) ListDeployPodMultusIPs(ctx context.Context, deploymentN
return nil, e
}
if len(podlist) == 0 {
return nil, fmt.Errorf("failed to get any pods")
return nil, errors.New("failed to get any pods")
}
return parseMultusIP(podlist)
}
7 changes: 4 additions & 3 deletions pkg/k8ObjManager/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ package k8sObjManager

import (
"context"
"fmt"
"errors"

"github.com/kdoctor-io/kdoctor/pkg/utils"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -40,7 +41,7 @@ func (nm *k8sObjManager) ListSelectedPodIPs(ctx context.Context, labelSelector *
return nil, e
}
if len(podlist) == 0 {
return nil, fmt.Errorf("failed to get any pods")
return nil, errors.New("failed to get any pods")
}

result := PodIps{}
Expand All @@ -66,7 +67,7 @@ func (nm *k8sObjManager) ListSelectedPodMultusIPs(ctx context.Context, labelSele
return nil, e
}
if len(podlist) == 0 {
return nil, fmt.Errorf("failed to get any pods")
return nil, errors.New("failed to get any pods")
}

return parseMultusIP(podlist)
Expand Down
6 changes: 4 additions & 2 deletions pkg/k8ObjManager/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ package k8sObjManager

import (
"context"
"errors"
"fmt"
"net"

"github.com/kdoctor-io/kdoctor/pkg/types"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"net"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -54,7 +56,7 @@ func (nm *k8sObjManager) GetServiceAccessUrl(ctx context.Context, name, namespac
return nil, fmt.Errorf("variable portName is empty, but service has multiple ports: %v", s.Spec.Ports)
}
if t == 0 {
return nil, fmt.Errorf("service has empty ports ")
return nil, errors.New("service has empty ports ")
}
portIndex = 0
} else {
Expand Down
9 changes: 5 additions & 4 deletions pkg/lease/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package lease

import (
"context"
"errors"
"fmt"
"time"

Expand All @@ -25,16 +26,16 @@ var (
func NewLeaseElector(ctx context.Context, leaseNamespace, leaseName, leaseID string, logger *zap.Logger) (getLease chan struct{}, lossLease chan struct{}, err error) {

if len(leaseNamespace) == 0 {
return nil, nil, fmt.Errorf("failed to new lease elector: Lease Namespace must be specified")
return nil, nil, errors.New("failed to new lease elector: Lease Namespace must be specified")
}
if len(leaseName) == 0 {
return nil, nil, fmt.Errorf("failed to new lease elector: Lease Name must be specified")
return nil, nil, errors.New("failed to new lease elector: Lease Name must be specified")
}
if len(leaseID) == 0 {
return nil, nil, fmt.Errorf("failed to new lease elector: Lease Identity must be specified")
return nil, nil, errors.New("failed to new lease elector: Lease Identity must be specified")
}
if logger == nil {
return nil, nil, fmt.Errorf("miss logger")
return nil, nil, errors.New("miss logger")
}

getLease = make(chan struct{})
Expand Down
3 changes: 2 additions & 1 deletion pkg/loadRequest/loadDns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ package loadDns

import (
"fmt"
"time"

"github.com/kdoctor-io/kdoctor/pkg/k8s/apis/system/v1beta1"
"github.com/miekg/dns"
"go.uber.org/zap"
"time"
)

type RequestProtocol string
Expand Down
29 changes: 13 additions & 16 deletions pkg/pluginManager/apphttphealthy/agentExecuteTask.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"crypto/x509"
"encoding/json"
"fmt"
"strings"

k8sObjManager "github.com/kdoctor-io/kdoctor/pkg/k8ObjManager"
crd "github.com/kdoctor-io/kdoctor/pkg/k8s/apis/kdoctor.io/v1beta1"
"github.com/kdoctor-io/kdoctor/pkg/k8s/apis/system/v1beta1"
Expand All @@ -19,7 +21,6 @@ import (
"go.uber.org/zap"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
"strings"
)

func ParseSuccessCondition(successCondition *crd.NetSuccessCondition, metricResult *v1beta1.HttpMetrics) (failureReason string) {
Expand Down Expand Up @@ -82,7 +83,7 @@ func (s *PluginAppHttpHealthy) AgentExecuteTask(logger *zap.Logger, ctx context.
if !ok {
msg := "failed to get instance"
logger.Error(msg)
err = fmt.Errorf(msg)
err = fmt.Errorf("error: %v", msg)
return finalfailureReason, task, err
}

Expand Down Expand Up @@ -111,9 +112,8 @@ func (s *PluginAppHttpHealthy) AgentExecuteTask(logger *zap.Logger, ctx context.

tlsData, err := k8sObjManager.GetK8sObjManager().GetSecret(context.Background(), *target.TlsSecretName, *target.TlsSecretNamespace)
if err != nil {
msg := fmt.Sprintf("failed get [%s/%s] secret err : %v", *target.TlsSecretNamespace, *target.TlsSecretName, err)
logger.Sugar().Errorf(msg)
err = fmt.Errorf(msg)
err = fmt.Errorf("failed get [%s/%s] secret err : %v", *target.TlsSecretNamespace, *target.TlsSecretName, err)
logger.Sugar().Errorf(err.Error())
return finalfailureReason, task, err
}
ca, caOk := tlsData.Data["ca.crt"]
Expand All @@ -127,9 +127,8 @@ func (s *PluginAppHttpHealthy) AgentExecuteTask(logger *zap.Logger, ctx context.
if crtOk && keyOk {
cert, err := tls.X509KeyPair(crt, key)
if err != nil {
msg := fmt.Sprintf("failed to load certificate and key: %v", err)
logger.Sugar().Errorf(msg)
err = fmt.Errorf(msg)
err := fmt.Errorf("failed to load certificate and key: %v", err)
logger.Sugar().Errorf(err.Error())
return finalfailureReason, task, err
}
d.ClientCert = cert
Expand All @@ -141,17 +140,15 @@ func (s *PluginAppHttpHealthy) AgentExecuteTask(logger *zap.Logger, ctx context.
if target.BodyConfigName != nil {
bodyCM, err := k8sObjManager.GetK8sObjManager().GetConfigMap(context.Background(), *target.BodyConfigName, *target.BodyConfigNamespace)
if err != nil {
msg := fmt.Sprintf("failed get [%s/%s] configmap err : %v", *target.BodyConfigNamespace, *target.BodyConfigName, err)
logger.Sugar().Errorf(msg)
err = fmt.Errorf(msg)
return finalfailureReason, task, err
errMsg := fmt.Errorf("failed get [%s/%s] configmap err : %v", *target.BodyConfigNamespace, *target.BodyConfigName, err)
logger.Sugar().Errorf(errMsg.Error())
return finalfailureReason, task, errMsg
}
body, err := json.Marshal(bodyCM.Data)
if err != nil {
msg := fmt.Sprintf("failed get body from [%s/%s] configmap err : %v", *target.BodyConfigNamespace, *target.BodyConfigName, err)
logger.Sugar().Errorf(msg)
err = fmt.Errorf(msg)
return finalfailureReason, task, err
errMsg := fmt.Errorf("failed get body from [%s/%s] configmap err : %v", *target.BodyConfigNamespace, *target.BodyConfigName, err)
logger.Sugar().Errorf(errMsg.Error())
return finalfailureReason, task, errMsg
}
d.Body = body
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/pluginManager/controllerReconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ package pluginManager

import (
"context"
"github.com/kdoctor-io/kdoctor/pkg/types"
"reflect"
"time"

"github.com/kdoctor-io/kdoctor/pkg/types"

"go.uber.org/zap"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -37,7 +38,7 @@ type pluginControllerReconciler struct {

// controller reconcile
// (1) schedule all task time
// (2) update stauts result
// (2) update status result
// (3) collect report from agent
func (s *pluginControllerReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {

Expand Down
6 changes: 4 additions & 2 deletions pkg/pluginManager/netdns/agentExecuteTask.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ package netdns

import (
"context"
"errors"
"fmt"
"github.com/kdoctor-io/kdoctor/pkg/runningTask"
"net"
"strconv"
"sync"

"github.com/kdoctor-io/kdoctor/pkg/runningTask"

"github.com/miekg/dns"
"go.uber.org/zap"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -89,7 +91,7 @@ func (s *PluginNetDns) AgentExecuteTask(logger *zap.Logger, ctx context.Context,
if !ok {
msg := "failed to get instance"
logger.Error(msg)
err = fmt.Errorf(msg)
err = errors.New(msg)
return
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/pluginManager/netreach/agentExecuteTask.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
Loading

0 comments on commit 4362999

Please sign in to comment.