@@ -19,15 +19,16 @@ import (
19
19
"strings"
20
20
"time"
21
21
22
+ "context"
23
+
24
+ "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta"
22
25
csi "github.com/container-storage-interface/spec/lib/go/csi"
23
- "github.com/golang/glog"
24
- "golang.org/x/net/context"
25
26
computebeta "google.golang.org/api/compute/v0.beta"
26
27
compute "google.golang.org/api/compute/v1"
27
28
"google.golang.org/grpc/codes"
28
29
"google.golang.org/grpc/status"
29
30
"k8s.io/apimachinery/pkg/util/wait"
30
- "k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta "
31
+ "k8s.io/klog "
31
32
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
32
33
)
33
34
@@ -143,23 +144,23 @@ func (cloud *CloudProvider) GetDisk(ctx context.Context, key *meta.Key) (*CloudD
143
144
func (cloud * CloudProvider ) getZonalDiskOrError (ctx context.Context , volumeZone , volumeName string ) (* compute.Disk , error ) {
144
145
svc := cloud .service
145
146
project := cloud .project
146
- glog .V (4 ).Infof ("Getting disk %v from zone %v" , volumeName , volumeZone )
147
+ klog .V (4 ).Infof ("Getting disk %v from zone %v" , volumeName , volumeZone )
147
148
disk , err := svc .Disks .Get (project , volumeZone , volumeName ).Context (ctx ).Do ()
148
149
if err != nil {
149
150
return nil , err
150
151
}
151
- glog .V (4 ).Infof ("Got disk %v from zone %v" , volumeName , volumeZone )
152
+ klog .V (4 ).Infof ("Got disk %v from zone %v" , volumeName , volumeZone )
152
153
return disk , nil
153
154
}
154
155
155
156
func (cloud * CloudProvider ) getRegionalDiskOrError (ctx context.Context , volumeRegion , volumeName string ) (* computebeta.Disk , error ) {
156
157
project := cloud .project
157
- glog .V (4 ).Infof ("Getting disk %v from region %v" , volumeName , volumeRegion )
158
+ klog .V (4 ).Infof ("Getting disk %v from region %v" , volumeName , volumeRegion )
158
159
disk , err := cloud .betaService .RegionDisks .Get (project , volumeRegion , volumeName ).Context (ctx ).Do ()
159
160
if err != nil {
160
161
return nil , err
161
162
}
162
- glog .V (4 ).Infof ("Got disk %v from region %v" , volumeName , volumeRegion )
163
+ klog .V (4 ).Infof ("Got disk %v from region %v" , volumeName , volumeRegion )
163
164
return disk , nil
164
165
}
165
166
@@ -198,7 +199,7 @@ func (cloud *CloudProvider) ValidateExistingDisk(ctx context.Context, resp *Clou
198
199
}
199
200
200
201
// Volume exists with matching name, capacity, type.
201
- glog .V (4 ).Infof ("Compatible disk already exists. Reusing existing." )
202
+ klog .V (4 ).Infof ("Compatible disk already exists. Reusing existing." )
202
203
return nil
203
204
}
204
205
@@ -245,7 +246,7 @@ func (cloud *CloudProvider) insertRegionalDisk(ctx context.Context, volKey *meta
245
246
if err != nil {
246
247
return err
247
248
}
248
- glog .Warningf ("GCE PD %s already exists, reusing" , volKey .Name )
249
+ klog .Warningf ("GCE PD %s already exists, reusing" , volKey .Name )
249
250
return nil
250
251
}
251
252
return status .Error (codes .Internal , fmt .Sprintf ("unkown Insert disk error: %v" , err ))
@@ -264,7 +265,7 @@ func (cloud *CloudProvider) insertRegionalDisk(ctx context.Context, volKey *meta
264
265
if err != nil {
265
266
return err
266
267
}
267
- glog .Warningf ("GCE PD %s already exists after wait, reusing" , volKey .Name )
268
+ klog .Warningf ("GCE PD %s already exists after wait, reusing" , volKey .Name )
268
269
return nil
269
270
}
270
271
return fmt .Errorf ("unkown Insert disk operation error: %v" , err )
@@ -304,7 +305,7 @@ func (cloud *CloudProvider) insertZonalDisk(ctx context.Context, volKey *meta.Ke
304
305
if err != nil {
305
306
return err
306
307
}
307
- glog .Warningf ("GCE PD %s already exists, reusing" , volKey .Name )
308
+ klog .Warningf ("GCE PD %s already exists, reusing" , volKey .Name )
308
309
return nil
309
310
}
310
311
return fmt .Errorf ("unkown Insert disk error: %v" , err )
@@ -324,7 +325,7 @@ func (cloud *CloudProvider) insertZonalDisk(ctx context.Context, volKey *meta.Ke
324
325
if err != nil {
325
326
return err
326
327
}
327
- glog .Warningf ("GCE PD %s already exists after wait, reusing" , volKey .Name )
328
+ klog .Warningf ("GCE PD %s already exists after wait, reusing" , volKey .Name )
328
329
return nil
329
330
}
330
331
return fmt .Errorf ("unkown Insert disk operation error: %v" , err )
@@ -465,7 +466,7 @@ func (cloud *CloudProvider) waitForZonalOp(ctx context.Context, op *compute.Oper
465
466
return wait .Poll (3 * time .Second , 5 * time .Minute , func () (bool , error ) {
466
467
pollOp , err := svc .ZoneOperations .Get (project , zone , op .Name ).Context (ctx ).Do ()
467
468
if err != nil {
468
- glog .Errorf ("WaitForOp(op: %#v, zone: %#v) failed to poll the operation" , op , zone )
469
+ klog .Errorf ("WaitForOp(op: %#v, zone: %#v) failed to poll the operation" , op , zone )
469
470
return false , err
470
471
}
471
472
done , err := opIsDone (pollOp )
@@ -477,7 +478,7 @@ func (cloud *CloudProvider) waitForRegionalOp(ctx context.Context, op *computebe
477
478
return wait .Poll (3 * time .Second , 5 * time .Minute , func () (bool , error ) {
478
479
pollOp , err := cloud .betaService .RegionOperations .Get (cloud .project , region , op .Name ).Context (ctx ).Do ()
479
480
if err != nil {
480
- glog .Errorf ("WaitForOp(op: %#v, region: %#v) failed to poll the operation" , op , region )
481
+ klog .Errorf ("WaitForOp(op: %#v, region: %#v) failed to poll the operation" , op , region )
481
482
return false , err
482
483
}
483
484
done , err := regionalOpIsDone (pollOp )
@@ -491,7 +492,7 @@ func (cloud *CloudProvider) waitForGlobalOp(ctx context.Context, op *compute.Ope
491
492
return wait .Poll (3 * time .Second , 5 * time .Minute , func () (bool , error ) {
492
493
pollOp , err := svc .GlobalOperations .Get (project , op .Name ).Context (ctx ).Do ()
493
494
if err != nil {
494
- glog .Errorf ("waitForGlobalOp(op: %#v) failed to poll the operation" , op )
495
+ klog .Errorf ("waitForGlobalOp(op: %#v) failed to poll the operation" , op )
495
496
return false , err
496
497
}
497
498
done , err := opIsDone (pollOp )
@@ -503,7 +504,7 @@ func (cloud *CloudProvider) WaitForAttach(ctx context.Context, volKey *meta.Key,
503
504
return wait .Poll (5 * time .Second , 2 * time .Minute , func () (bool , error ) {
504
505
disk , err := cloud .GetDisk (ctx , volKey )
505
506
if err != nil {
506
- glog .Errorf ("GetDisk failed to get disk: %v" , err )
507
+ klog .Errorf ("GetDisk failed to get disk: %v" , err )
507
508
return false , err
508
509
}
509
510
@@ -543,25 +544,25 @@ func regionalOpIsDone(op *computebeta.Operation) (bool, error) {
543
544
func (cloud * CloudProvider ) GetInstanceOrError (ctx context.Context , instanceZone , instanceName string ) (* compute.Instance , error ) {
544
545
svc := cloud .service
545
546
project := cloud .project
546
- glog .V (4 ).Infof ("Getting instance %v from zone %v" , instanceName , instanceZone )
547
+ klog .V (4 ).Infof ("Getting instance %v from zone %v" , instanceName , instanceZone )
547
548
548
549
instance , err := svc .Instances .Get (project , instanceZone , instanceName ).Do ()
549
550
if err != nil {
550
551
return nil , err
551
552
}
552
- glog .V (4 ).Infof ("Got instance %v from zone %v" , instanceName , instanceZone )
553
+ klog .V (4 ).Infof ("Got instance %v from zone %v" , instanceName , instanceZone )
553
554
return instance , nil
554
555
}
555
556
556
557
func (cloud * CloudProvider ) GetSnapshot (ctx context.Context , snapshotName string ) (* compute.Snapshot , error ) {
557
558
svc := cloud .service
558
559
project := cloud .project
559
- glog .V (4 ).Infof ("Getting snapshot %v" , snapshotName )
560
+ klog .V (4 ).Infof ("Getting snapshot %v" , snapshotName )
560
561
snapshot , err := svc .Snapshots .Get (project , snapshotName ).Context (ctx ).Do ()
561
562
if err != nil {
562
563
return nil , err
563
564
}
564
- glog .V (4 ).Infof ("Got snapshot %v" , snapshotName )
565
+ klog .V (4 ).Infof ("Got snapshot %v" , snapshotName )
565
566
return snapshot , nil
566
567
}
567
568
@@ -629,16 +630,16 @@ func (cloud *CloudProvider) waitForSnapshotCreation(ctx context.Context, snapsho
629
630
for {
630
631
select {
631
632
case <- ticker .C :
632
- glog .V (5 ).Infof ("Checking GCE Snapshot %s." , snapshotName )
633
+ klog .V (5 ).Infof ("Checking GCE Snapshot %s." , snapshotName )
633
634
snapshot , err := cloud .GetSnapshot (ctx , snapshotName )
634
635
if err != nil {
635
- glog .Warningf ("Error in getting snapshot %s, %v" , snapshotName , err )
636
+ klog .Warningf ("Error in getting snapshot %s, %v" , snapshotName , err )
636
637
} else if snapshot != nil {
637
638
if snapshot .Status != "CREATING" {
638
- glog .V (5 ).Infof ("Snapshot %s status is %s" , snapshotName , snapshot .Status )
639
+ klog .V (5 ).Infof ("Snapshot %s status is %s" , snapshotName , snapshot .Status )
639
640
return snapshot , nil
640
641
} else {
641
- glog .V (5 ).Infof ("Snapshot %s is still creating ..." , snapshotName )
642
+ klog .V (5 ).Infof ("Snapshot %s is still creating ..." , snapshotName )
642
643
}
643
644
}
644
645
case <- timer .C :
0 commit comments