Skip to content

Commit 1b2f74b

Browse files
committed
lower threshold on backoff for sanity tests
1 parent cd8a6d2 commit 1b2f74b

File tree

6 files changed

+21
-14
lines changed

6 files changed

+21
-14
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ var (
4242
httpEndpoint = flag.String("http-endpoint", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled.")
4343
metricsPath = flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.")
4444

45-
extraVolumeLabelsStr = flag.String("extra-labels", "", "Extra labels to attach to each PD created. It is a comma separated list of key value pairs like '<key1>=<value1>,<key2>=<value2>'. See https://cloud.google.com/compute/docs/labeling-resources for details")
45+
errorBackoffInitialDurationMs = flag.Int("backoff-initial-duration-ms", 200, "The amount of ms for the initial duration of the backoff condition for controller publish/unpublish CSI operations. Default is 200.")
46+
errorBackoffMaxDurationMs = flag.Int("backoff-max-duration-ms", 300000, "The amount of ms for the max duration of the backoff condition for controller publish/unpublish CSI operations. Default is 300000 (5m).")
47+
extraVolumeLabelsStr = flag.String("extra-labels", "", "Extra labels to attach to each PD created. It is a comma separated list of key value pairs like '<key1>=<value1>,<key2>=<value2>'. See https://cloud.google.com/compute/docs/labeling-resources for details")
4648

4749
attachDiskBackoffDuration = flag.Duration("attach-disk-backoff-duration", 5*time.Second, "Duration for attachDisk backoff")
4850
attachDiskBackoffFactor = flag.Float64("attach-disk-backoff-factor", 0.0, "Factor for attachDisk backoff")
@@ -122,7 +124,9 @@ func handle() {
122124
if err != nil {
123125
klog.Fatalf("Failed to get cloud provider: %v", err)
124126
}
125-
controllerServer = driver.NewControllerServer(gceDriver, cloudProvider)
127+
initialBackoffDuration := time.Duration(*errorBackoffInitialDurationMs) * time.Millisecond
128+
maxBackoffDuration := time.Duration(*errorBackoffMaxDurationMs) * time.Microsecond
129+
controllerServer = driver.NewControllerServer(gceDriver, cloudProvider, initialBackoffDuration, maxBackoffDuration)
126130
} else if *cloudConfigFilePath != "" {
127131
klog.Warningf("controller service is disabled but cloud config given - it has no effect")
128132
}

pkg/gce-pd-csi-driver/controller.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ import (
3737
gce "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/compute"
3838
)
3939

40-
const (
41-
errorBackoffInitialDuration = 200 * time.Millisecond
42-
errorBackoffMaxDuration = 5 * time.Minute
43-
)
44-
4540
type GCEControllerServer struct {
4641
Driver *GCEDriver
4742
CloudProvider gce.GCECompute
@@ -517,7 +512,7 @@ func (gceCS *GCEControllerServer) executeControllerPublishVolume(ctx context.Con
517512

518513
attached, err := diskIsAttachedAndCompatible(deviceName, instance, volumeCapability, readWrite)
519514
if err != nil {
520-
return nil, status.Error(codes.AlreadyExists, fmt.Sprintf("Disk %v already published to node %v but incompatbile: %v", volKey.Name, nodeID, err))
515+
return nil, status.Error(codes.AlreadyExists, fmt.Sprintf("Disk %v already published to node %v but incompatible: %v", volKey.Name, nodeID, err))
521516
}
522517
if attached {
523518
// Volume is attached to node. Success!
@@ -1596,8 +1591,8 @@ func pickRandAndConsecutive(slice []string, n int) ([]string, error) {
15961591
return ret, nil
15971592
}
15981593

1599-
func newCsiErrorBackoff() *csiErrorBackoff {
1600-
return &csiErrorBackoff{flowcontrol.NewBackOff(errorBackoffInitialDuration, errorBackoffMaxDuration)}
1594+
func newCsiErrorBackoff(initialDuration, errorBackoffMaxDuration time.Duration) *csiErrorBackoff {
1595+
return &csiErrorBackoff{flowcontrol.NewBackOff(initialDuration, errorBackoffMaxDuration)}
16011596
}
16021597

16031598
func (_ *csiErrorBackoff) backoffId(nodeId, volumeId string) csiErrorBackoffId {

pkg/gce-pd-csi-driver/controller_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,8 @@ type backoffTesterConfig struct {
21492149
}
21502150

21512151
func newFakeCsiErrorBackoff(tc *clock.FakeClock) *csiErrorBackoff {
2152+
errorBackoffInitialDuration := 200 * time.Millisecond
2153+
errorBackoffMaxDuration := 5 * time.Minute
21522154
return &csiErrorBackoff{flowcontrol.NewFakeBackOff(errorBackoffInitialDuration, errorBackoffMaxDuration, tc)}
21532155
}
21542156

pkg/gce-pd-csi-driver/gce-pd-driver.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package gceGCEDriver
1616

1717
import (
1818
"fmt"
19+
"time"
1920

2021
csi "github.com/container-storage-interface/spec/lib/go/csi"
2122
"google.golang.org/grpc/codes"
@@ -148,13 +149,13 @@ func NewNodeServer(gceDriver *GCEDriver, mounter *mount.SafeFormatAndMount, devi
148149
}
149150
}
150151

151-
func NewControllerServer(gceDriver *GCEDriver, cloudProvider gce.GCECompute) *GCEControllerServer {
152+
func NewControllerServer(gceDriver *GCEDriver, cloudProvider gce.GCECompute, errorBackoffInitialDuration, errorBackoffMaxDuration time.Duration) *GCEControllerServer {
152153
return &GCEControllerServer{
153154
Driver: gceDriver,
154155
CloudProvider: cloudProvider,
155156
seen: map[string]int{},
156157
volumeLocks: common.NewVolumeLocks(),
157-
errorBackoff: newCsiErrorBackoff(),
158+
errorBackoff: newCsiErrorBackoff(errorBackoffInitialDuration, errorBackoffMaxDuration),
158159
}
159160
}
160161

pkg/gce-pd-csi-driver/gce-pd-driver_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package gceGCEDriver
1616

1717
import (
1818
"testing"
19+
"time"
1920

2021
gce "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/compute"
2122
)
@@ -43,7 +44,10 @@ func initBlockingGCEDriver(t *testing.T, cloudDisks []*gce.CloudDisk, readyToExe
4344
func initGCEDriverWithCloudProvider(t *testing.T, cloudProvider gce.GCECompute) *GCEDriver {
4445
vendorVersion := "test-vendor"
4546
gceDriver := GetGCEDriver()
46-
controllerServer := NewControllerServer(gceDriver, cloudProvider)
47+
errorBackoffInitialDuration := 200 * time.Millisecond
48+
errorBackoffMaxDuration := 5 * time.Minute
49+
50+
controllerServer := NewControllerServer(gceDriver, cloudProvider, errorBackoffInitialDuration, errorBackoffMaxDuration)
4751
err := gceDriver.SetupGCEDriver(driver, vendorVersion, nil, nil, controllerServer, nil)
4852
if err != nil {
4953
t.Fatalf("Failed to setup GCE Driver: %v", err)

test/sanity/sanity_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"path"
2222
"strings"
2323
"testing"
24+
"time"
2425

2526
"github.com/google/uuid"
2627
"google.golang.org/grpc"
@@ -64,7 +65,7 @@ func TestSanity(t *testing.T) {
6465

6566
//Initialize GCE Driver
6667
identityServer := driver.NewIdentityServer(gceDriver)
67-
controllerServer := driver.NewControllerServer(gceDriver, cloudProvider)
68+
controllerServer := driver.NewControllerServer(gceDriver, cloudProvider, 1*time.Millisecond)
6869
nodeServer := driver.NewNodeServer(gceDriver, mounter, deviceUtils, metadataservice.NewFakeService(), mountmanager.NewFakeStatter(mounter))
6970
err = gceDriver.SetupGCEDriver(driverName, vendorVersion, extraLabels, identityServer, controllerServer, nodeServer)
7071
if err != nil {

0 commit comments

Comments
 (0)