Skip to content

Commit

Permalink
Switch to use klog for logging (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheng Pan committed Feb 13, 2019
1 parent a6ef1bb commit 3e925a3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package main
import (
"flag"

"github.com/golang/glog"
"github.com/kubernetes-sigs/aws-efs-csi-driver/pkg/driver"
"k8s.io/klog"
)

func main() {
Expand All @@ -29,6 +29,6 @@ func main() {

drv := driver.NewDriver(*endpoint)
if err := drv.Run(); err != nil {
glog.Fatalln(err)
klog.Fatalln(err)
}
}
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ module github.com/kubernetes-sigs/aws-efs-csi-driver
require (
github.com/aws/aws-sdk-go v1.16.5
github.com/container-storage-interface/spec v0.3.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/mock v1.2.0
github.com/golang/protobuf v1.2.0
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d
google.golang.org/grpc v1.17.0
k8s.io/apimachinery v0.0.0-20181211025822-57dc7e687b54 // indirect
k8s.io/klog v0.1.0
k8s.io/kubernetes v1.13.1
k8s.io/utils v0.0.0-20181115163542-0d26856f57b3
k8s.io/utils v0.0.0-20181115163542-0d26856f57b3 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ github.com/aws/aws-sdk-go v1.16.5/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/container-storage-interface/spec v0.3.0 h1:ALxSqFjptj8R5rL+cdyAbwbaLHHXDL5pmp1qIh1b+38=
github.com/container-storage-interface/spec v0.3.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
github.com/container-storage-interface/spec v1.0.0 h1:3DyXuJgf9MU6kyULESegQUmozsSxhpyrrv9u5bfwA3E=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk=
Expand Down
8 changes: 4 additions & 4 deletions pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"net"

csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
"github.com/golang/glog"
"github.com/kubernetes-sigs/aws-efs-csi-driver/pkg/cloud"
"github.com/kubernetes-sigs/aws-efs-csi-driver/pkg/util"
"google.golang.org/grpc"
"k8s.io/klog"
"k8s.io/kubernetes/pkg/util/mount"
)

Expand Down Expand Up @@ -59,7 +59,7 @@ type Driver struct {
func NewDriver(endpoint string) *Driver {
cloud, err := cloud.NewCloud()
if err != nil {
glog.Fatalln(err)
klog.Fatalln(err)
}

return &Driver{
Expand All @@ -83,7 +83,7 @@ func (d *Driver) Run() error {
logErr := func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
resp, err := handler(ctx, req)
if err != nil {
glog.Errorf("GRPC error: %v", err)
klog.Errorf("GRPC error: %v", err)
}
return resp, err
}
Expand All @@ -95,7 +95,7 @@ func (d *Driver) Run() error {
csi.RegisterIdentityServer(d.srv, d)
csi.RegisterNodeServer(d.srv, d)

glog.Infof("Listening for connections on address: %#v", listener.Addr())
klog.Infof("Listening for connections on address: %#v", listener.Addr())
return d.srv.Serve(listener)
}

Expand Down
18 changes: 9 additions & 9 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"os"

csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
"github.com/golang/glog"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
)

var (
Expand All @@ -40,7 +40,7 @@ func (d *Driver) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolu
}

func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
glog.V(4).Infof("NodePublishVolume: called with args %+v", req)
klog.V(4).Infof("NodePublishVolume: called with args %+v", req)

volumeId := req.GetVolumeId()
source := fmt.Sprintf("%s:/", volumeId)
Expand Down Expand Up @@ -79,12 +79,12 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
}
}
}
glog.V(5).Infof("NodePublishVolume: creating dir %s", target)
klog.V(5).Infof("NodePublishVolume: creating dir %s", target)
if err := d.mounter.MakeDir(target); err != nil {
return nil, status.Errorf(codes.Internal, "Could not create dir %q: %v", target, err)
}

glog.V(5).Infof("NodePublishVolume: mounting %s at %s with options %v", source, target, mountOptions)
klog.V(5).Infof("NodePublishVolume: mounting %s at %s with options %v", source, target, mountOptions)
if err := d.mounter.Mount(source, target, "efs", mountOptions); err != nil {
os.Remove(target)
return nil, status.Errorf(codes.Internal, "Could not mount %q at %q: %v", source, target, err)
Expand All @@ -94,14 +94,14 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
}

func (d *Driver) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
glog.V(4).Infof("NodeUnpublishVolume: called with args %+v", req)
klog.V(4).Infof("NodeUnpublishVolume: called with args %+v", req)

target := req.GetTargetPath()
if len(target) == 0 {
return nil, status.Error(codes.InvalidArgument, "Target path not provided")
}

glog.V(5).Infof("NodeUnpublishVolume: unmounting %s", target)
klog.V(5).Infof("NodeUnpublishVolume: unmounting %s", target)
err := d.mounter.Unmount(target)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not unmount %q: %v", target, err)
Expand All @@ -111,7 +111,7 @@ func (d *Driver) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublish
}

func (d *Driver) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
glog.V(4).Infof("NodeGetCapabilities: called with args %+v", req)
klog.V(4).Infof("NodeGetCapabilities: called with args %+v", req)
var caps []*csi.NodeServiceCapability
for _, cap := range nodeCaps {
c := &csi.NodeServiceCapability{
Expand All @@ -127,15 +127,15 @@ func (d *Driver) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabi
}

func (d *Driver) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
glog.V(4).Infof("NodeGetInfo: called with args %+v", req)
klog.V(4).Infof("NodeGetInfo: called with args %+v", req)

return &csi.NodeGetInfoResponse{
NodeId: d.nodeID,
}, nil
}

func (d *Driver) NodeGetId(ctx context.Context, req *csi.NodeGetIdRequest) (*csi.NodeGetIdResponse, error) {
glog.V(4).Infof("NodeGetId: called with args %+v", req)
klog.V(4).Infof("NodeGetId: called with args %+v", req)
return &csi.NodeGetIdResponse{
NodeId: d.nodeID,
}, nil
Expand Down

0 comments on commit 3e925a3

Please sign in to comment.