Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Remove log levels and use klog v2 #28

Merged
merged 1 commit into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/objectstorage-sidecar/app/objectstorage-sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"google.golang.org/grpc"

"k8s.io/klog"
"k8s.io/klog/v2"
)

const (
Expand All @@ -36,7 +36,7 @@ func NewSidecarOptions() *SidecarOptions {

// Run starts the sidecar with the configured options
func (so *SidecarOptions) Run() {
klog.V(1).Infof("attempting to open a gRPC connection with: %q", so.driverAddress)
klog.Infof("attempting to open a gRPC connection with: %q", so.driverAddress)
grpcClient, err := grpcclient.NewGRPCClient(so.driverAddress, []grpc.DialOption{}, nil)
if err != nil {
klog.Errorf("error creating GRPC Client: %v", err)
Expand All @@ -52,7 +52,7 @@ func (so *SidecarOptions) Run() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

klog.V(1).Infof("creating provisioner client")
klog.Infof("creating provisioner client")
provisionerClient := osspec.NewProvisionerClient(grpcConn)

klog.Infof("discovering driver name")
Expand Down
3 changes: 2 additions & 1 deletion cmd/sample-driver/driver-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"

"k8s.io/klog/v2"

cosi "github.com/kubernetes-sigs/container-object-storage-interface-spec"
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/sample-driver/sample-driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (
"github.com/minio/minio/pkg/madmin"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/klog"

"k8s.io/klog/v2"

"sigs.k8s.io/container-object-storage-interface-provisioner-sidecar/pkg/grpcserver"
)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ require (
k8s.io/api v0.19.4
k8s.io/apimachinery v0.19.4
k8s.io/client-go v0.19.4
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.2.0
)
10 changes: 5 additions & 5 deletions pkg/controller/bucket/bucket_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

osspec "github.com/kubernetes-sigs/container-object-storage-interface-spec"

"k8s.io/klog"
"k8s.io/klog/v2"

"golang.org/x/time/rate"
)
Expand Down Expand Up @@ -93,7 +93,7 @@ func (bl *bucketListener) InitializeBucketClient(bc bucketclientset.Interface) {

// Add will call the provisioner and add a bucket
func (bl *bucketListener) Add(ctx context.Context, obj *v1alpha1.Bucket) error {
klog.V(1).Infof("bucketListener: add called for bucket %s", obj.Name)
klog.Infof("bucketListener: add called for bucket %s", obj.Name)

// Verify this bucket is for this provisioner
if !strings.EqualFold(obj.Spec.Provisioner, bl.provisionerName) {
Expand Down Expand Up @@ -133,13 +133,13 @@ func (bl *bucketListener) Add(ctx context.Context, obj *v1alpha1.Bucket) error {

// Update does nothing
func (bl *bucketListener) Update(ctx context.Context, old, new *v1alpha1.Bucket) error {
klog.V(1).Infof("bucketListener: update called for bucket %s", old.Name)
klog.Infof("bucketListener: update called for bucket %s", old.Name)
return nil
}

// Delete will call the provisioner and delete a bucket
func (bl *bucketListener) Delete(ctx context.Context, obj *v1alpha1.Bucket) error {
klog.V(1).Infof("bucketListener: delete called for bucket %s", obj.Name)
klog.Infof("bucketListener: delete called for bucket %s", obj.Name)

// Verify this bucket is for this provisioner
if !strings.EqualFold(obj.Spec.Provisioner, bl.provisionerName) {
Expand Down Expand Up @@ -179,7 +179,7 @@ func (bl *bucketListener) Delete(ctx context.Context, obj *v1alpha1.Bucket) erro
_, err = bl.bucketClient.ObjectstorageV1alpha1().Buckets().UpdateStatus(ctx, obj, metav1.UpdateOptions{})
return err
}
klog.V(1).Infof("provisioner returned delete bucket response %v", rsp)
klog.Infof("provisioner returned delete bucket response %v", rsp)

// update bucket availability to false
return bl.updateStatus(ctx, obj.Name, "Bucket Deleted", false)
Expand Down
12 changes: 6 additions & 6 deletions pkg/controller/bucketaccess/bucket_access_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (

osspec "github.com/kubernetes-sigs/container-object-storage-interface-spec"

"k8s.io/klog"
"k8s.io/klog/v2"

"golang.org/x/time/rate"
)
Expand Down Expand Up @@ -100,7 +100,7 @@ func (bal *bucketAccessListener) InitializeBucketClient(bc bucketclientset.Inter

// Add will call the provisioner to grant permissions
func (bal *bucketAccessListener) Add(ctx context.Context, obj *v1alpha1.BucketAccess) error {
klog.V(1).Infof("bucketAccessListener: add called for bucket access %s", obj.Name)
klog.Infof("bucketAccessListener: add called for bucket access %s", obj.Name)

// Verify this bucket access is for this provisioner
if !strings.EqualFold(obj.Spec.Provisioner, bal.provisionerName) {
Expand Down Expand Up @@ -144,7 +144,7 @@ func (bal *bucketAccessListener) Add(ctx context.Context, obj *v1alpha1.BucketAc
klog.Errorf("error calling ProvisionerGrantBucketAccess: %v", err)
return err
}
klog.V(1).Infof("provisioner returned grant bucket access response %v", rsp)
klog.Infof("provisioner returned grant bucket access response %v", rsp)

// Only update the principal in the BucketAccess if it wasn't set because
// that means that the provisioner created one
Expand Down Expand Up @@ -185,13 +185,13 @@ func (bal *bucketAccessListener) Add(ctx context.Context, obj *v1alpha1.BucketAc

// Update does nothing
func (bal *bucketAccessListener) Update(ctx context.Context, old, new *v1alpha1.BucketAccess) error {
klog.V(1).Infof("bucketAccessListener: update called for bucket %s", old.Name)
klog.Infof("bucketAccessListener: update called for bucket %s", old.Name)
return nil
}

// Delete will call the provisioner to revoke permissions
func (bal *bucketAccessListener) Delete(ctx context.Context, obj *v1alpha1.BucketAccess) error {
klog.V(1).Infof("bucketAccessListener: delete called for bucket access %s", obj.Name)
klog.Infof("bucketAccessListener: delete called for bucket access %s", obj.Name)

// Verify this bucket access is for this provisioner
if !strings.EqualFold(obj.Spec.Provisioner, bal.provisionerName) {
Expand Down Expand Up @@ -234,7 +234,7 @@ func (bal *bucketAccessListener) Delete(ctx context.Context, obj *v1alpha1.Bucke
klog.Errorf("error calling ProvisionerRevokeBucketAccess: %v", err)
return err
}
klog.V(1).Infof("provisioner returned revoke bucket access response %v", rsp)
klog.Infof("provisioner returned revoke bucket access response %v", rsp)

// Delete the secret
if obj.Spec.ServiceAccount == nil {
Expand Down
10 changes: 5 additions & 5 deletions pkg/grpcclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"google.golang.org/grpc"

"k8s.io/klog"
"k8s.io/klog/v2"
)

type options struct {
Expand Down Expand Up @@ -102,11 +102,11 @@ func (c *GRPCClient) ConnectWithLogging(interval time.Duration) (*grpc.ClientCon
klog.Infof("Connecting to %s", c.serverAddress)

grpcLogFunc := func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
klog.V(5).Infof("GRPC call: %s", method)
klog.V(5).Infof("GRPC request: %s", req)
klog.Infof("GRPC call: %s", method)
klog.Infof("GRPC request: %s", req)
err := invoker(ctx, method, req, reply, cc, opts...)
klog.V(5).Infof("GRPC response: %s", reply)
klog.V(5).Infof("GRPC error: %v", err)
klog.Infof("GRPC response: %s", reply)
klog.Infof("GRPC error: %v", err)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/grpcserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

osi "github.com/kubernetes-sigs/container-object-storage-interface-spec"

"k8s.io/klog"
"k8s.io/klog/v2"
)

// Defines Non blocking GRPC server interfaces
Expand Down