Skip to content

Commit

Permalink
Use k8s.io/klog instead of github.com/golang/glog
Browse files Browse the repository at this point in the history
* The Kubernetes has moved over to using k8s.io/klog
* Using glog will cause "flag redefined: log_dir" when running e2e that import values from github.com/kubernetes-sigs/aws-ebs-csi-driver/
* Similar to issue kubernetes/kubernetes#35096
  • Loading branch information
dkoshkin committed Dec 21, 2018
1 parent d31d900 commit 000cfd5
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 1,591 deletions.
4 changes: 2 additions & 2 deletions THIRD-PARTY
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
** github.com/aws/aws-sdk-go/; version v1.15.27 -- https://github.com/aws/aws-sdk-go/
** github.com/container-storage-interface/spec; version v0.3.0 -- https://github.com/container-storage-interface/spec/
** github.com/go-ini/ini; version v1.38.2 -- https://github.com/go-ini/ini
** github.com/golang/glog; version 1.0 -- https://github.com/golang/glog/
** github.com/kubernetes/klog; version v0.1.0 -- https://github.com/kubernetes/klog
** github.com/golang/mock; version v1.1.1 -- https://github.com/golang/mock
** github.com/kubernetes-csi/csi-test; version v0.3.0-2 -- https://github.com/kubernetes-csi/csi-test
** github.com/spf13/afero; version v1.1.2 -- https://github.com/spf13/afero
Expand Down Expand Up @@ -206,7 +206,7 @@ NOTICE:
Copyright {yyyy} {name of copyright owner}
* For github.com/go-ini/ini see also this required NOTICE:
Copyright 2014 Unknwon
* For github.com/golang/glog see also this required NOTICE:
* For github.com/kubernetes/klog see also this required NOTICE:
Copyright 2013 Google Inc. All Rights Reserved.
* For github.com/golang/mock see also this required NOTICE:
Copyright 2010 Google Inc.
Expand Down
8 changes: 4 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"fmt"
"os"

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

func main() {
Expand All @@ -35,17 +35,17 @@ func main() {
if *version {
info, err := driver.GetVersionJSON()
if err != nil {
glog.Fatalln(err)
klog.Fatalln(err)
}
fmt.Println(info)
os.Exit(0)
}

drv, err := driver.NewDriver(*endpoint)
if err != nil {
glog.Fatalln(err)
klog.Fatalln(err)
}
if err := drv.Run(); err != nil {
glog.Fatalln(err)
klog.Fatalln(err)
}
}
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ require (
github.com/go-openapi/strfmt v0.17.2 // indirect
github.com/go-openapi/validate v0.17.2 // indirect
github.com/gogo/protobuf v1.1.1 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect
github.com/golang/mock v1.2.0
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect
Expand Down Expand Up @@ -90,7 +89,7 @@ require (
k8s.io/cloud-provider v0.0.0-20181121074215-9b77dc1c3846 // indirect
k8s.io/cluster-bootstrap v0.0.0-20181110194056-c71be3de9a2f // indirect
k8s.io/csi-api v0.0.0-20181130072956-61a1735c3f50 // indirect
k8s.io/klog v0.1.0 // indirect
k8s.io/klog v0.1.0
k8s.io/kube-aggregator v0.0.0-20181206110645-d02c483df5c3 // indirect
k8s.io/kube-openapi v0.0.0-20181114233023-0317810137be // indirect
k8s.io/kubernetes v1.13.1
Expand Down
10 changes: 5 additions & 5 deletions pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/golang/glog"
dm "github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud/devicemanager"
"github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/util"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog"
)

// AWS volume types
Expand Down Expand Up @@ -213,7 +213,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *
zone := diskOptions.AvailabilityZone
if zone == "" {
zone = c.metadata.GetAvailabilityZone()
glog.V(5).Infof("AZ is not provided. Using node AZ [%s]", zone)
klog.V(5).Infof("AZ is not provided. Using node AZ [%s]", zone)
}

request := &ec2.CreateVolumeInput{
Expand Down Expand Up @@ -292,7 +292,7 @@ func (c *cloud) AttachDisk(ctx context.Context, volumeID, nodeID string) (string
}
return "", fmt.Errorf("could not attach volume %q to node %q: %v", volumeID, nodeID, err)
}
glog.V(5).Infof("AttachVolume volume=%q instance=%q request returned %v", volumeID, nodeID, resp)
klog.V(5).Infof("AttachVolume volume=%q instance=%q request returned %v", volumeID, nodeID, resp)

}

Expand Down Expand Up @@ -323,7 +323,7 @@ func (c *cloud) DetachDisk(ctx context.Context, volumeID, nodeID string) error {
defer device.Release(true)

if !device.IsAlreadyAssigned {
glog.Warningf("DetachDisk called on non-attached volume: %s", volumeID)
klog.Warningf("DetachDisk called on non-attached volume: %s", volumeID)
}

request := &ec2.DetachVolumeInput{
Expand Down Expand Up @@ -486,7 +486,7 @@ func (c *cloud) waitForAttachmentState(ctx context.Context, volumeID, state stri

for _, a := range volume.Attachments {
if a.State == nil {
glog.Warningf("Ignoring nil attachment state for volume %q: %v", volumeID, a)
klog.Warningf("Ignoring nil attachment state for volume %q: %v", volumeID, a)
continue
}
if *a.State == state {
Expand Down
8 changes: 4 additions & 4 deletions pkg/cloud/devicemanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/golang/glog"
"k8s.io/klog"
)

const devPreffix = "/dev/xvd"
Expand All @@ -41,7 +41,7 @@ type Device struct {
func (d *Device) Release(force bool) {
if !d.isTainted || force {
if err := d.releaseFunc(); err != nil {
glog.Errorf("Error releasing device: %v", err)
klog.Errorf("Error releasing device: %v", err)
}
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ func (d *deviceManager) release(device *Device) error {
return fmt.Errorf("release on device %q assigned to different volume: %q vs %q", device.Path, device.VolumeID, existingVolumeID)
}

glog.V(5).Infof("Releasing in-process attachment entry: %v -> volume %s", device, device.VolumeID)
klog.V(5).Infof("Releasing in-process attachment entry: %v -> volume %s", device, device.VolumeID)
d.inFlight.Del(nodeID, name)

return nil
Expand All @@ -220,7 +220,7 @@ func (d *deviceManager) getDeviceNamesInUse(instance *ec2.Instance, nodeID strin
name = strings.TrimPrefix(name, "/dev/xvd")

if len(name) < 1 || len(name) > 2 {
glog.Warningf("Unexpected EBS DeviceName: %q", aws.StringValue(blockDevice.DeviceName))
klog.Warningf("Unexpected EBS DeviceName: %q", aws.StringValue(blockDevice.DeviceName))
}
inUse[name] = aws.StringValue(blockDevice.Ebs.VolumeId)
}
Expand Down
24 changes: 12 additions & 12 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
"strconv"

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

var (
Expand All @@ -46,7 +46,7 @@ var (
)

func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
glog.V(4).Infof("CreateVolume: called with args %+v", *req)
klog.V(4).Infof("CreateVolume: called with args %+v", *req)
volName := req.GetName()
if len(volName) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume name not provided")
Expand Down Expand Up @@ -131,15 +131,15 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
}

func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {
glog.V(4).Infof("DeleteVolume: called with args: %+v", *req)
klog.V(4).Infof("DeleteVolume: called with args: %+v", *req)
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
}

if _, err := d.cloud.DeleteDisk(ctx, volumeID); err != nil {
if err == cloud.ErrNotFound {
glog.V(4).Info("DeleteVolume: volume not found, returning with success")
klog.V(4).Info("DeleteVolume: volume not found, returning with success")
return &csi.DeleteVolumeResponse{}, nil
}
return nil, status.Errorf(codes.Internal, "Could not delete volume ID %q: %v", volumeID, err)
Expand All @@ -149,7 +149,7 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
}

func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) {
glog.V(4).Infof("ControllerPublishVolume: called with args %+v", *req)
klog.V(4).Infof("ControllerPublishVolume: called with args %+v", *req)
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
Expand Down Expand Up @@ -188,14 +188,14 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
}
return nil, status.Errorf(codes.Internal, "Could not attach volume %q to node %q: %v", volumeID, nodeID, err)
}
glog.V(5).Infof("ControllerPublishVolume: volume %s attached to node %s through device %s", volumeID, nodeID, devicePath)
klog.V(5).Infof("ControllerPublishVolume: volume %s attached to node %s through device %s", volumeID, nodeID, devicePath)

pvInfo := map[string]string{"devicePath": devicePath}
return &csi.ControllerPublishVolumeResponse{PublishContext: pvInfo}, nil
}

func (d *Driver) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) {
glog.V(4).Infof("ControllerUnpublishVolume: called with args %+v", *req)
klog.V(4).Infof("ControllerUnpublishVolume: called with args %+v", *req)
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
Expand All @@ -209,13 +209,13 @@ func (d *Driver) ControllerUnpublishVolume(ctx context.Context, req *csi.Control
if err := d.cloud.DetachDisk(ctx, volumeID, nodeID); err != nil {
return nil, status.Errorf(codes.Internal, "Could not detach volume %q from node %q: %v", volumeID, nodeID, err)
}
glog.V(5).Infof("ControllerUnpublishVolume: volume %s detached from node %s", volumeID, nodeID)
klog.V(5).Infof("ControllerUnpublishVolume: volume %s detached from node %s", volumeID, nodeID)

return &csi.ControllerUnpublishVolumeResponse{}, nil
}

func (d *Driver) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) {
glog.V(4).Infof("ControllerGetCapabilities: called with args %+v", *req)
klog.V(4).Infof("ControllerGetCapabilities: called with args %+v", *req)
var caps []*csi.ControllerServiceCapability
for _, cap := range controllerCaps {
c := &csi.ControllerServiceCapability{
Expand All @@ -231,17 +231,17 @@ func (d *Driver) ControllerGetCapabilities(ctx context.Context, req *csi.Control
}

func (d *Driver) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error) {
glog.V(4).Infof("GetCapacity: called with args %+v", *req)
klog.V(4).Infof("GetCapacity: called with args %+v", *req)
return nil, status.Error(codes.Unimplemented, "")
}

func (d *Driver) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error) {
glog.V(4).Infof("ListVolumes: called with args %+v", *req)
klog.V(4).Infof("ListVolumes: called with args %+v", *req)
return nil, status.Error(codes.Unimplemented, "")
}

func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) {
glog.V(4).Infof("ValidateVolumeCapabilities: called with args %+v", *req)
klog.V(4).Infof("ValidateVolumeCapabilities: called with args %+v", *req)
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
Expand Down
10 changes: 5 additions & 5 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"
"github.com/golang/glog"
"github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud"
"github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/util"
"google.golang.org/grpc"
"k8s.io/klog"
"k8s.io/kubernetes/pkg/util/mount"
)

Expand All @@ -44,7 +44,7 @@ type Driver struct {
}

func NewDriver(endpoint string) (*Driver, error) {
glog.Infof("Driver: %v Version: %v", DriverName, driverVersion)
klog.Infof("Driver: %v Version: %v", DriverName, driverVersion)

cloud, err := cloud.NewCloud()
if err != nil {
Expand Down Expand Up @@ -74,7 +74,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 @@ -87,12 +87,12 @@ func (d *Driver) Run() error {
csi.RegisterControllerServer(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)
}

func (d *Driver) Stop() {
glog.Infof("Stopping server")
klog.Infof("Stopping server")
d.srv.Stop()
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/driver/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"context"

csi "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/glog"
"k8s.io/klog"
)

func (d *Driver) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
glog.V(4).Infof("GetPluginInfo: called with args %+v", *req)
klog.V(4).Infof("GetPluginInfo: called with args %+v", *req)
resp := &csi.GetPluginInfoResponse{
Name: DriverName,
VendorVersion: driverVersion,
Expand All @@ -34,7 +34,7 @@ func (d *Driver) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoReques
}

func (d *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
glog.V(4).Infof("GetPluginCapabilities: called with args %+v", *req)
klog.V(4).Infof("GetPluginCapabilities: called with args %+v", *req)
resp := &csi.GetPluginCapabilitiesResponse{
Capabilities: []*csi.PluginCapability{
{
Expand All @@ -58,6 +58,6 @@ func (d *Driver) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCa
}

func (d *Driver) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) {
glog.V(4).Infof("Probe: called with args %+v", *req)
klog.V(4).Infof("Probe: called with args %+v", *req)
return &csi.ProbeResponse{}, nil
}
Loading

0 comments on commit 000cfd5

Please sign in to comment.