@@ -65,6 +65,7 @@ type GCECompute interface {
65
65
// RepairUnderspecifiedVolumeKey will query the cloud provider and check each zone for the disk specified
66
66
// by the volume key and return a volume key with a correct zone
67
67
func (cloud * CloudProvider ) RepairUnderspecifiedVolumeKey (ctx context.Context , volumeKey * meta.Key ) (* meta.Key , error ) {
68
+ klog .V (5 ).Infof ("Repairing potentially underspecified volume key %v" , volumeKey )
68
69
region , err := common .GetRegionFromZones ([]string {cloud .zone })
69
70
if err != nil {
70
71
return nil , fmt .Errorf ("failed to get region from zones: %v" , err )
@@ -114,6 +115,7 @@ func (cloud *CloudProvider) RepairUnderspecifiedVolumeKey(ctx context.Context, v
114
115
}
115
116
116
117
func (cloud * CloudProvider ) ListZones (ctx context.Context , region string ) ([]string , error ) {
118
+ klog .V (5 ).Infof ("Listing zones in region: %v" , region )
117
119
if len (cloud .zonesCache [region ]) > 0 {
118
120
return cloud .zonesCache [region ], nil
119
121
}
@@ -131,6 +133,7 @@ func (cloud *CloudProvider) ListZones(ctx context.Context, region string) ([]str
131
133
}
132
134
133
135
func (cloud * CloudProvider ) ListSnapshots (ctx context.Context , filter string , maxEntries int64 , pageToken string ) ([]* computev1.Snapshot , string , error ) {
136
+ klog .V (5 ).Infof ("Listing snapshots with filter: %s, max entries: %v, page token: %s" , filter , maxEntries , pageToken )
134
137
snapshots := []* computev1.Snapshot {}
135
138
snapshotList , err := cloud .service .Snapshots .List (cloud .project ).Filter (filter ).MaxResults (maxEntries ).PageToken (pageToken ).Do ()
136
139
if err != nil {
@@ -144,6 +147,7 @@ func (cloud *CloudProvider) ListSnapshots(ctx context.Context, filter string, ma
144
147
}
145
148
146
149
func (cloud * CloudProvider ) GetDisk (ctx context.Context , key * meta.Key ) (* CloudDisk , error ) {
150
+ klog .V (5 ).Infof ("Getting disk %v" , key )
147
151
switch key .Type () {
148
152
case meta .Zonal :
149
153
disk , err := cloud .getZonalDiskOrError (ctx , key .Zone , key .Name )
@@ -159,23 +163,20 @@ func (cloud *CloudProvider) GetDisk(ctx context.Context, key *meta.Key) (*CloudD
159
163
func (cloud * CloudProvider ) getZonalDiskOrError (ctx context.Context , volumeZone , volumeName string ) (* computev1.Disk , error ) {
160
164
svc := cloud .service
161
165
project := cloud .project
162
- klog . V ( 4 ). Infof ( "Getting disk %v from zone %v" , volumeName , volumeZone )
166
+
163
167
disk , err := svc .Disks .Get (project , volumeZone , volumeName ).Context (ctx ).Do ()
164
168
if err != nil {
165
169
return nil , err
166
170
}
167
- klog .V (4 ).Infof ("Got disk %v from zone %v" , volumeName , volumeZone )
168
171
return disk , nil
169
172
}
170
173
171
174
func (cloud * CloudProvider ) getRegionalDiskOrError (ctx context.Context , volumeRegion , volumeName string ) (* computev1.Disk , error ) {
172
175
project := cloud .project
173
- klog .V (4 ).Infof ("Getting disk %v from region %v" , volumeName , volumeRegion )
174
176
disk , err := cloud .service .RegionDisks .Get (project , volumeRegion , volumeName ).Context (ctx ).Do ()
175
177
if err != nil {
176
178
return nil , err
177
179
}
178
- klog .V (4 ).Infof ("Got disk %v from region %v" , volumeName , volumeRegion )
179
180
return disk , nil
180
181
}
181
182
@@ -194,6 +195,7 @@ func (cloud *CloudProvider) getRegionURI(region string) string {
194
195
}
195
196
196
197
func (cloud * CloudProvider ) ValidateExistingDisk (ctx context.Context , resp * CloudDisk , diskType string , reqBytes , limBytes int64 ) error {
198
+ klog .V (5 ).Infof ("Validating existing disk %v with diskType: %s, reqested bytes: %v, limit bytes: %v" , resp , diskType , reqBytes , limBytes )
197
199
if resp == nil {
198
200
return fmt .Errorf ("disk does not exist" )
199
201
}
@@ -212,13 +214,11 @@ func (cloud *CloudProvider) ValidateExistingDisk(ctx context.Context, resp *Clou
212
214
return fmt .Errorf ("disk already exists with incompatible type. Need %v. Got %v" ,
213
215
diskType , respType [len (respType )- 1 ])
214
216
}
215
-
216
- // Volume exists with matching name, capacity, type.
217
- klog .V (4 ).Infof ("Compatible disk already exists. Reusing existing." )
218
217
return nil
219
218
}
220
219
221
220
func (cloud * CloudProvider ) InsertDisk (ctx context.Context , volKey * meta.Key , diskType string , capBytes int64 , capacityRange * csi.CapacityRange , replicaZones []string , snapshotID , diskEncryptionKmsKey string ) error {
221
+ klog .V (5 ).Infof ("Inserting disk %v" , volKey )
222
222
switch volKey .Type () {
223
223
case meta .Zonal :
224
224
return cloud .insertZonalDisk (ctx , volKey , diskType , capBytes , capacityRange , snapshotID , diskEncryptionKmsKey )
@@ -349,6 +349,7 @@ func (cloud *CloudProvider) insertZonalDisk(ctx context.Context, volKey *meta.Ke
349
349
}
350
350
351
351
func (cloud * CloudProvider ) DeleteDisk (ctx context.Context , volKey * meta.Key ) error {
352
+ klog .V (5 ).Infof ("Deleting disk: %v" , volKey )
352
353
switch volKey .Type () {
353
354
case meta .Zonal :
354
355
return cloud .deleteZonalDisk (ctx , volKey .Zone , volKey .Name )
@@ -392,6 +393,7 @@ func (cloud *CloudProvider) deleteRegionalDisk(ctx context.Context, region, name
392
393
}
393
394
394
395
func (cloud * CloudProvider ) AttachDisk (ctx context.Context , volKey * meta.Key , readWrite , diskType , instanceZone , instanceName string ) error {
396
+ klog .V (5 ).Infof ("Attaching disk %v to %s" , volKey , instanceName )
395
397
source := cloud .GetDiskSourceURI (volKey )
396
398
397
399
deviceName , err := common .GetDeviceName (volKey )
@@ -418,6 +420,7 @@ func (cloud *CloudProvider) AttachDisk(ctx context.Context, volKey *meta.Key, re
418
420
}
419
421
420
422
func (cloud * CloudProvider ) DetachDisk (ctx context.Context , deviceName , instanceZone , instanceName string ) error {
423
+ klog .V (5 ).Infof ("Detaching disk %v from %v" , deviceName , instanceName )
421
424
op , err := cloud .service .Instances .DetachDisk (cloud .project , instanceZone , instanceName , deviceName ).Context (ctx ).Do ()
422
425
if err != nil {
423
426
return err
@@ -516,11 +519,13 @@ func (cloud *CloudProvider) waitForGlobalOp(ctx context.Context, op *computev1.O
516
519
}
517
520
518
521
func (cloud * CloudProvider ) WaitForAttach (ctx context.Context , volKey * meta.Key , instanceZone , instanceName string ) error {
522
+ klog .V (5 ).Infof ("Waiting for attach of disk %v to instance %v to complete..." , volKey .Name , instanceName )
523
+ start := time .Now ()
519
524
return wait .Poll (5 * time .Second , 2 * time .Minute , func () (bool , error ) {
525
+ klog .V (6 ).Infof ("Polling for attach of disk %v to instance %v to complete for %v" , volKey .Name , instanceName , time .Since (start ))
520
526
disk , err := cloud .GetDisk (ctx , volKey )
521
527
if err != nil {
522
- klog .Errorf ("GetDisk failed to get disk: %v" , err )
523
- return false , err
528
+ return false , fmt .Errorf ("GetDisk failed to get disk: %v" , err )
524
529
}
525
530
526
531
if disk == nil {
@@ -547,31 +552,29 @@ func opIsDone(op *computev1.Operation) (bool, error) {
547
552
}
548
553
549
554
func (cloud * CloudProvider ) GetInstanceOrError (ctx context.Context , instanceZone , instanceName string ) (* computev1.Instance , error ) {
555
+ klog .V (5 ).Infof ("Getting instance %v from zone %v" , instanceName , instanceZone )
550
556
svc := cloud .service
551
557
project := cloud .project
552
- klog .V (4 ).Infof ("Getting instance %v from zone %v" , instanceName , instanceZone )
553
-
554
558
instance , err := svc .Instances .Get (project , instanceZone , instanceName ).Do ()
555
559
if err != nil {
556
560
return nil , err
557
561
}
558
- klog .V (4 ).Infof ("Got instance %v from zone %v" , instanceName , instanceZone )
559
562
return instance , nil
560
563
}
561
564
562
565
func (cloud * CloudProvider ) GetSnapshot (ctx context.Context , snapshotName string ) (* computev1.Snapshot , error ) {
566
+ klog .V (5 ).Infof ("Getting snapshot %v" , snapshotName )
563
567
svc := cloud .service
564
568
project := cloud .project
565
- klog .V (4 ).Infof ("Getting snapshot %v" , snapshotName )
566
569
snapshot , err := svc .Snapshots .Get (project , snapshotName ).Context (ctx ).Do ()
567
570
if err != nil {
568
571
return nil , err
569
572
}
570
- klog .V (4 ).Infof ("Got snapshot %v" , snapshotName )
571
573
return snapshot , nil
572
574
}
573
575
574
576
func (cloud * CloudProvider ) DeleteSnapshot (ctx context.Context , snapshotName string ) error {
577
+ klog .V (5 ).Infof ("Deleting snapshot %v" , snapshotName )
575
578
op , err := cloud .service .Snapshots .Delete (cloud .project , snapshotName ).Context (ctx ).Do ()
576
579
if err != nil {
577
580
if IsGCEError (err , "notFound" ) {
@@ -588,6 +591,7 @@ func (cloud *CloudProvider) DeleteSnapshot(ctx context.Context, snapshotName str
588
591
}
589
592
590
593
func (cloud * CloudProvider ) CreateSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
594
+ klog .V (5 ).Infof ("Creating snapshot %s for volume %v" , snapshotName , volKey )
591
595
switch volKey .Type () {
592
596
case meta .Zonal :
593
597
return cloud .createZonalDiskSnapshot (ctx , volKey , snapshotName )
@@ -599,6 +603,7 @@ func (cloud *CloudProvider) CreateSnapshot(ctx context.Context, volKey *meta.Key
599
603
}
600
604
601
605
func (cloud * CloudProvider ) ResizeDisk (ctx context.Context , volKey * meta.Key , requestBytes int64 ) (int64 , error ) {
606
+ klog .V (5 ).Infof ("Resizing disk %v to size %v" , volKey , requestBytes )
602
607
cloudDisk , err := cloud .GetDisk (ctx , volKey )
603
608
if err != nil {
604
609
return - 1 , fmt .Errorf ("failed to get disk: %v" , err )
@@ -694,16 +699,16 @@ func (cloud *CloudProvider) waitForSnapshotCreation(ctx context.Context, snapsho
694
699
for {
695
700
select {
696
701
case <- ticker .C :
697
- klog .V (5 ).Infof ("Checking GCE Snapshot %s." , snapshotName )
702
+ klog .V (6 ).Infof ("Checking GCE Snapshot %s." , snapshotName )
698
703
snapshot , err := cloud .GetSnapshot (ctx , snapshotName )
699
704
if err != nil {
700
705
klog .Warningf ("Error in getting snapshot %s, %v" , snapshotName , err )
701
706
} else if snapshot != nil {
702
707
if snapshot .Status != "CREATING" {
703
- klog .V (5 ).Infof ("Snapshot %s status is %s" , snapshotName , snapshot .Status )
708
+ klog .V (6 ).Infof ("Snapshot %s status is %s" , snapshotName , snapshot .Status )
704
709
return snapshot , nil
705
710
} else {
706
- klog .V (5 ).Infof ("Snapshot %s is still creating ..." , snapshotName )
711
+ klog .V (6 ).Infof ("Snapshot %s is still creating ..." , snapshotName )
707
712
}
708
713
}
709
714
case <- timer .C :
0 commit comments