@@ -24,11 +24,11 @@ import (
2424 "os/signal"
2525 "time"
2626
27- "github.com/golang/glog"
2827 "k8s.io/client-go/kubernetes"
2928 "k8s.io/client-go/kubernetes/scheme"
3029 "k8s.io/client-go/rest"
3130 "k8s.io/client-go/tools/clientcmd"
31+ "k8s.io/klog"
3232
3333 "github.com/kubernetes-csi/external-snapshotter/pkg/connection"
3434 "github.com/kubernetes-csi/external-snapshotter/pkg/controller"
@@ -67,38 +67,39 @@ var (
6767)
6868
6969func main () {
70+ klog .InitFlags (nil )
7071 flag .Set ("logtostderr" , "true" )
7172 flag .Parse ()
7273
7374 if * showVersion {
7475 fmt .Println (os .Args [0 ], version )
7576 os .Exit (0 )
7677 }
77- glog .Infof ("Version: %s" , version )
78+ klog .Infof ("Version: %s" , version )
7879
7980 if * connectionTimeout != 0 {
80- glog .Warning ("--connection-timeout is deprecated and will have no effect" )
81+ klog .Warning ("--connection-timeout is deprecated and will have no effect" )
8182 }
8283 if * snapshotter != "" {
83- glog .Warning ("--snapshotter is deprecated and will have no effect" )
84+ klog .Warning ("--snapshotter is deprecated and will have no effect" )
8485 }
8586
8687 // Create the client config. Use kubeconfig if given, otherwise assume in-cluster.
8788 config , err := buildConfig (* kubeconfig )
8889 if err != nil {
89- glog .Error (err .Error ())
90+ klog .Error (err .Error ())
9091 os .Exit (1 )
9192 }
9293
9394 kubeClient , err := kubernetes .NewForConfig (config )
9495 if err != nil {
95- glog .Error (err .Error ())
96+ klog .Error (err .Error ())
9697 os .Exit (1 )
9798 }
9899
99100 snapClient , err := clientset .NewForConfig (config )
100101 if err != nil {
101- glog .Errorf ("Error building snapshot clientset: %s" , err .Error ())
102+ klog .Errorf ("Error building snapshot clientset: %s" , err .Error ())
102103 os .Exit (1 )
103104 }
104105
@@ -108,14 +109,14 @@ func main() {
108109 // Create CRD resource
109110 aeclientset , err := apiextensionsclient .NewForConfig (config )
110111 if err != nil {
111- glog .Error (err .Error ())
112+ klog .Error (err .Error ())
112113 os .Exit (1 )
113114 }
114115
115116 // initialize CRD resource if it does not exist
116117 err = CreateCRD (aeclientset )
117118 if err != nil {
118- glog .Error (err .Error ())
119+ klog .Error (err .Error ())
119120 os .Exit (1 )
120121 }
121122
@@ -125,7 +126,7 @@ func main() {
125126 // Connect to CSI.
126127 csiConn , err := connection .New (* csiAddress )
127128 if err != nil {
128- glog .Error (err .Error ())
129+ klog .Error (err .Error ())
129130 os .Exit (1 )
130131 }
131132
@@ -136,34 +137,34 @@ func main() {
136137 // Find driver name
137138 * snapshotter , err = csiConn .GetDriverName (ctx )
138139 if err != nil {
139- glog .Error (err .Error ())
140+ klog .Error (err .Error ())
140141 os .Exit (1 )
141142 }
142- glog .V (2 ).Infof ("CSI driver name: %q" , * snapshotter )
143+ klog .V (2 ).Infof ("CSI driver name: %q" , * snapshotter )
143144
144145 // Check it's ready
145146 if err = waitForDriverReady (csiConn , * connectionTimeout ); err != nil {
146- glog .Error (err .Error ())
147+ klog .Error (err .Error ())
147148 os .Exit (1 )
148149 }
149150
150151 // Find out if the driver supports create/delete snapshot.
151152 supportsCreateSnapshot , err := csiConn .SupportsControllerCreateSnapshot (ctx )
152153 if err != nil {
153- glog .Error (err .Error ())
154+ klog .Error (err .Error ())
154155 os .Exit (1 )
155156 }
156157 if ! supportsCreateSnapshot {
157- glog .Errorf ("CSI driver %s does not support ControllerCreateSnapshot" , * snapshotter )
158+ klog .Errorf ("CSI driver %s does not support ControllerCreateSnapshot" , * snapshotter )
158159 os .Exit (1 )
159160 }
160161
161162 if len (* snapshotNamePrefix ) == 0 {
162- glog .Error ("Snapshot name prefix cannot be of length 0" )
163+ klog .Error ("Snapshot name prefix cannot be of length 0" )
163164 os .Exit (1 )
164165 }
165166
166- glog .V (2 ).Infof ("Start NewCSISnapshotController with snapshotter [%s] kubeconfig [%s] connectionTimeout [%+v] csiAddress [%s] createSnapshotContentRetryCount [%d] createSnapshotContentInterval [%+v] resyncPeriod [%+v] snapshotNamePrefix [%s] snapshotNameUUIDLength [%d]" , * snapshotter , * kubeconfig , * connectionTimeout , * csiAddress , createSnapshotContentRetryCount , * createSnapshotContentInterval , * resyncPeriod , * snapshotNamePrefix , snapshotNameUUIDLength )
167+ klog .V (2 ).Infof ("Start NewCSISnapshotController with snapshotter [%s] kubeconfig [%s] connectionTimeout [%+v] csiAddress [%s] createSnapshotContentRetryCount [%d] createSnapshotContentInterval [%+v] resyncPeriod [%+v] snapshotNamePrefix [%s] snapshotNameUUIDLength [%d]" , * snapshotter , * kubeconfig , * connectionTimeout , * csiAddress , createSnapshotContentRetryCount , * createSnapshotContentInterval , * resyncPeriod , * snapshotNamePrefix , snapshotNameUUIDLength )
167168
168169 ctrl := controller .NewCSISnapshotController (
169170 snapClient ,
@@ -211,10 +212,10 @@ func waitForDriverReady(csiConn connection.CSIConnection, timeout time.Duration)
211212 defer cancel ()
212213 err = csiConn .Probe (ctx )
213214 if err == nil {
214- glog .V (2 ).Infof ("Probe succeeded" )
215+ klog .V (2 ).Infof ("Probe succeeded" )
215216 return nil
216217 }
217- glog .V (2 ).Infof ("Probe failed with %s" , err )
218+ klog .V (2 ).Infof ("Probe failed with %s" , err )
218219
219220 now := time .Now ()
220221 if now .After (finish ) {
0 commit comments