diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 9be5a98e..84fc5423 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -10,7 +10,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: ^1.13 + go-version: ^1.15 id: go - name: Check out code into the Go module directory uses: actions/checkout@v2 diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml index f90f73ab..43567a68 100644 --- a/.github/workflows/linux.yaml +++ b/.github/workflows/linux.yaml @@ -13,7 +13,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: ^1.13 + go-version: ^1.15 id: go - name: Check out code into the Go module directory diff --git a/hack/verify-examples.sh b/hack/verify-examples.sh index 1c248d43..bd071110 100755 --- a/hack/verify-examples.sh +++ b/hack/verify-examples.sh @@ -24,6 +24,9 @@ kubectl apply -f ./deploy/example/statefulset.yaml echo "sleep 60s ..." sleep 60 +echo "begin to check pod status ..." +kubectl get pods -o wide + kubectl get pods --field-selector status.phase=Running | grep deployment-nfs kubectl get pods --field-selector status.phase=Running | grep statefulset-nfs-0 diff --git a/pkg/nfs/indentityserver.go b/pkg/nfs/indentityserver.go index f7f1db3c..52d6943a 100644 --- a/pkg/nfs/indentityserver.go +++ b/pkg/nfs/indentityserver.go @@ -22,8 +22,6 @@ import ( "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - - "k8s.io/klog/v2" ) type IdentityServer struct { @@ -31,8 +29,6 @@ type IdentityServer struct { } func (ids *IdentityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) { - klog.V(5).Infof("Using default GetPluginInfo") - if ids.Driver.name == "" { return nil, status.Error(codes.Unavailable, "Driver name not configured") } @@ -56,7 +52,6 @@ func (ids *IdentityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*c } func (ids *IdentityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) { - klog.V(5).Infof("Using default capabilities") return &csi.GetPluginCapabilitiesResponse{ Capabilities: []*csi.PluginCapability{ { diff --git a/pkg/nfs/utils.go b/pkg/nfs/utils.go index d89204ab..97eb83b3 100644 --- a/pkg/nfs/utils.go +++ b/pkg/nfs/utils.go @@ -70,14 +70,25 @@ func ParseEndpoint(ep string) (string, string, error) { return "", "", fmt.Errorf("Invalid endpoint: %v", ep) } +func getLogLevel(method string) int32 { + if method == "/csi.v1.Identity/Probe" || + method == "/csi.v1.Node/NodeGetCapabilities" || + method == "/csi.v1.Node/NodeGetVolumeStats" { + return 10 + } + return 2 +} + func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { - klog.V(3).Infof("GRPC call: %s", info.FullMethod) - klog.V(5).Infof("GRPC request: %s", protosanitizer.StripSecrets(req)) + level := klog.Level(getLogLevel(info.FullMethod)) + klog.V(level).Infof("GRPC call: %s", info.FullMethod) + klog.V(level).Infof("GRPC request: %s", protosanitizer.StripSecrets(req)) + resp, err := handler(ctx, req) if err != nil { klog.Errorf("GRPC error: %v", err) } else { - klog.V(5).Infof("GRPC response: %s", protosanitizer.StripSecrets(resp)) + klog.V(level).Infof("GRPC response: %s", protosanitizer.StripSecrets(resp)) } return resp, err } diff --git a/pkg/nfs/utils_test.go b/pkg/nfs/utils_test.go index 536f8065..1177373d 100644 --- a/pkg/nfs/utils_test.go +++ b/pkg/nfs/utils_test.go @@ -83,3 +83,38 @@ func TestParseEndpoint(t *testing.T) { }) } } + +func TestGetLogLevel(t *testing.T) { + tests := []struct { + method string + level int32 + }{ + { + method: "/csi.v1.Identity/Probe", + level: 10, + }, + { + method: "/csi.v1.Node/NodeGetCapabilities", + level: 10, + }, + { + method: "/csi.v1.Node/NodeGetVolumeStats", + level: 10, + }, + { + method: "", + level: 2, + }, + { + method: "unknown", + level: 2, + }, + } + + for _, test := range tests { + level := getLogLevel(test.method) + if level != test.level { + t.Errorf("returned level: (%v), expected level: (%v)", level, test.level) + } + } +}