Skip to content

Commit 6b7e63f

Browse files
committed
Replace Get operations with polling and skip VAC tests during integration test
1 parent 82a4f6c commit 6b7e63f

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

cmd/gce-pd-csi-driver/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ var (
5757
attachDiskBackoffJitter = flag.Float64("attach-disk-backoff-jitter", 0.0, "Jitter for attachDisk backoff")
5858
attachDiskBackoffSteps = flag.Int("attach-disk-backoff-steps", 24, "Steps for attachDisk backoff")
5959
attachDiskBackoffCap = flag.Duration("attach-disk-backoff-cap", 0, "Cap for attachDisk backoff")
60-
waitForOpBackoffDuration = flag.Duration("wait-op-backoff-duration", 3*time.Second, "Duration for wait for operation backoff")
60+
waitForOpBackoffDuration = flag.Duration("wait-op-backoff-duration", 2*time.Minute, "Duration for wait for operation backoff")
6161
waitForOpBackoffFactor = flag.Float64("wait-op-backoff-factor", 0.0, "Factor for wait for operation backoff")
6262
waitForOpBackoffJitter = flag.Float64("wait-op-backoff-jitter", 0.0, "Jitter for wait for operation backoff")
63-
waitForOpBackoffSteps = flag.Int("wait-op-backoff-steps", 100, "Steps for wait for operation backoff")
63+
waitForOpBackoffSteps = flag.Int("wait-op-backoff-steps", 3, "Steps for wait for operation backoff")
6464
waitForOpBackoffCap = flag.Duration("wait-op-backoff-cap", 0, "Cap for wait for operation backoff")
6565

6666
enableDeviceInUseCheck = flag.Bool("enable-device-in-use-check-on-node-unstage", true, "If set to true, block NodeUnstageVolume requests until the specified device is not in use")

pkg/gce-cloud-provider/compute/gce-compute.go

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ var AttachDiskBackoff = wait.Backoff{
7676
Cap: 0}
7777

7878
// WaitForOpBackoff is backoff used to wait for Global, Regional or Zonal operation to complete.
79-
// Default values are similar to Poll every 3 seconds with 5 minute timeout.
79+
// Default values are similar to Poll every 2 minutes with 6 minute timeout.
8080
var WaitForOpBackoff = wait.Backoff{
81-
Duration: 3 * time.Second,
81+
Duration: 2 * time.Minute,
8282
Factor: 0.0,
8383
Jitter: 0.0,
84-
Steps: 100,
84+
Steps: 3,
8585
Cap: 0}
8686

8787
// Custom error type to propagate error messages up to clients.
@@ -1064,39 +1064,52 @@ func (cloud *CloudProvider) getRegionalDiskTypeURI(project string, region, diskT
10641064
}
10651065

10661066
func (cloud *CloudProvider) waitForZonalOp(ctx context.Context, project, opName string, zone string) error {
1067-
// The v1 API can query for v1, alpha, or beta operations.
10681067
return wait.ExponentialBackoff(WaitForOpBackoff, func() (bool, error) {
1069-
pollOp, err := cloud.service.ZoneOperations.Get(project, zone, opName).Context(ctx).Do()
1068+
waitOp, err := cloud.service.ZoneOperations.Wait(project, zone, opName).Context(ctx).Do()
1069+
// In case of service unavailable do not propogate the error so ExponentialBackoff will retry
1070+
if err != nil && waitOp.HttpErrorStatusCode == 503 {
1071+
klog.Errorf("WaitForZonalOp(op: %s, zone: %#v, err: %v) failed to poll the operation", opName, zone, err)
1072+
return false, nil
1073+
}
10701074
if err != nil {
1071-
klog.Errorf("WaitForOp(op: %s, zone: %#v) failed to poll the operation", opName, zone)
1075+
klog.Errorf("WaitForZonalOp(op: %s, zone: %#v, err: %v) failed to poll the operation", opName, zone, err)
10721076
return false, err
10731077
}
1074-
done, err := opIsDone(pollOp)
1078+
done, err := opIsDone(waitOp)
10751079
return done, err
10761080
})
10771081
}
10781082

10791083
func (cloud *CloudProvider) waitForRegionalOp(ctx context.Context, project, opName string, region string) error {
1080-
// The v1 API can query for v1, alpha, or beta operations.
10811084
return wait.ExponentialBackoff(WaitForOpBackoff, func() (bool, error) {
1082-
pollOp, err := cloud.service.RegionOperations.Get(project, region, opName).Context(ctx).Do()
1085+
waitOp, err := cloud.service.RegionOperations.Wait(project, region, opName).Context(ctx).Do()
1086+
// In case of service unavailable do not propogate the error so ExponentialBackoff will retry
1087+
if err != nil && waitOp.HttpErrorStatusCode == 503 {
1088+
klog.Errorf("WaitForRegionalOp(op: %s, region: %#v, err: %v) failed to poll the operation", opName, region, err)
1089+
return false, nil
1090+
}
10831091
if err != nil {
1084-
klog.Errorf("WaitForOp(op: %s, region: %#v) failed to poll the operation", opName, region)
1092+
klog.Errorf("WaitForRegionalOp(op: %s, region: %#v, err: %v) failed to poll the operation", opName, region, err)
10851093
return false, err
10861094
}
1087-
done, err := opIsDone(pollOp)
1095+
done, err := opIsDone(waitOp)
10881096
return done, err
10891097
})
10901098
}
10911099

10921100
func (cloud *CloudProvider) waitForGlobalOp(ctx context.Context, project, opName string) error {
10931101
return wait.ExponentialBackoff(WaitForOpBackoff, func() (bool, error) {
1094-
pollOp, err := cloud.service.GlobalOperations.Get(project, opName).Context(ctx).Do()
1102+
waitOp, err := cloud.service.GlobalOperations.Wait(project, opName).Context(ctx).Do()
1103+
// In case of service unavailable do not propogate the error so ExponentialBackoff will retry
1104+
if err != nil && waitOp.HttpErrorStatusCode == 503 {
1105+
klog.Errorf("WaitForGlobalOp(op: %s, err: %v) failed to poll the operation", opName, err)
1106+
return false, nil
1107+
}
10951108
if err != nil {
1096-
klog.Errorf("waitForGlobalOp(op: %s) failed to poll the operation", opName)
1109+
klog.Errorf("waitForGlobalOp(op: %s, err: %v) failed to poll the operation", opName, err)
10971110
return false, err
10981111
}
1099-
done, err := opIsDone(pollOp)
1112+
done, err := opIsDone(waitOp)
11001113
return done, err
11011114
})
11021115
}

test/k8s-integration/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,8 @@ func generateGCETestSkip(testParams *testParameters) string {
639639
skipString := "\\[Disruptive\\]|\\[Serial\\]"
640640
// Skip mount options test until we fix the invalid mount options for xfs.
641641
skipString = skipString + "|csi-gcepd-sc-xfs.*provisioning.should.provision.storage.with.mount.options"
642+
// Skip VolumeAttributesClass tests while it's a beta feature.
643+
skipString = skipString + "|\\[Feature:VolumeAttributesClass\\]"
642644

643645
v := apimachineryversion.MustParseSemantic(testParams.clusterVersion)
644646

@@ -745,6 +747,8 @@ func generateGKETestSkip(testParams *testParameters) string {
745747

746748
// Skip mount options test until we fix the invalid mount options for xfs.
747749
skipString = skipString + "|csi-gcepd-sc-xfs.*provisioning.should.provision.storage.with.mount.options"
750+
// Skip VolumeAttributesClass tests while it's a beta feature.
751+
skipString = skipString + "|\\[Feature:VolumeAttributesClass\\]"
748752

749753
// Skip rwop test when node version is less than 1.32. Test was added only
750754
// in 1.32 and above, see tags in

0 commit comments

Comments
 (0)