Repository: kubernetes-sigs/gcp-compute-persistent-disk-csi-driver
Pull request #1094 (2022-12-01 20:17:11)

Disable per volume backoff behavior for sanity tests
<!--  Thanks for sending a pull request!  Here are some tips for you:

1. If this is your first time, please read our contributor guidelines: https://git.k8s.io/community/contributors/guide#your-first-contribution and developer guide https://git.k8s.io/community/contributors/devel/development.md#development-guide
2. Follow the instructions for writing a release note: https://git.k8s.io/community/contributors/guide/release-notes.md
3. If the PR is unfinished, see how to mark it: https://git.k8s.io/community/contributors/guide/pull-requests.md#marking-unfinished-pull-requests
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind api-change
> /kind bug
> /kind cleanup
> /kind design
> /kind documentation

kind failing-test

> /kind feature
> /kind flake

**What this PR does / why we need it**:
Lower threshold for backoff in pd sanity tests

This is a follow up to https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/pull/1087. It lowers the threshold for backoff in sanity tests even more since we were seeing flakes in some PR gating tests, namely https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/pull/1092.

I will run the sanity tests a few times in this CL before merging.

**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->
Fixes #

**Special notes for your reviewer**:

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->
```release-note
NONE
```



Patch:
diff --git a/pkg/common/parameters.go b/pkg/common/parameters.go
index b2bde107..8dc20d3c 100644
--- a/pkg/common/parameters.go
+++ b/pkg/common/parameters.go
@@ -56,6 +56,11 @@ const (
 	tagKeyCreatedForSnapshotName        = "kubernetes.io/created-for/volumesnapshot/name"
 	tagKeyCreatedForSnapshotNamespace   = "kubernetes.io/created-for/volumesnapshot/namespace"
 	tagKeyCreatedForSnapshotContentName = "kubernetes.io/created-for/volumesnapshotcontent/name"
+
+	// Keys for labels to tag to PV
+	labelKeyCreatedForClaimNamespace = "kubernetes_io_created-for_pvc_namespace"
+	labelKeyCreatedForClaimName      = "kubernetes_io_created-for_pvc_name"
+	labelKeyCreatedForVolumeName     = "kubernetes_io_created-for_pv_name"
 )
 
 // DiskParameters contains normalized and defaulted disk parameters
@@ -122,10 +127,13 @@ func ExtractAndDefaultParameters(parameters map[string]string, driverName string
 			p.DiskEncryptionKMSKey = v
 		case ParameterKeyPVCName:
 			p.Tags[tagKeyCreatedForClaimName] = v
+			p.Labels[labelKeyCreatedForClaimName] = v
 		case ParameterKeyPVCNamespace:
 			p.Tags[tagKeyCreatedForClaimNamespace] = v
+			p.Labels[labelKeyCreatedForClaimNamespace] = v
 		case ParameterKeyPVName:
 			p.Tags[tagKeyCreatedForVolumeName] = v
+			p.Labels[labelKeyCreatedForVolumeName] = v
 		case ParameterKeyLabels:
 			paramLabels, err := ConvertLabelsStringToMap(v)
 			if err != nil {


Test patch:
diff --git a/pkg/common/parameters_test.go b/pkg/common/parameters_test.go
index c9832731..b896d0b9 100644
--- a/pkg/common/parameters_test.go
+++ b/pkg/common/parameters_test.go
@@ -107,7 +107,7 @@ func TestExtractAndDefaultParameters(t *testing.T) {
 				ReplicationType:      "none",
 				DiskEncryptionKMSKey: "",
 				Tags:                 map[string]string{tagKeyCreatedForClaimName: "testPVCName", tagKeyCreatedForClaimNamespace: "testPVCNamespace", tagKeyCreatedForVolumeName: "testPVName", tagKeyCreatedBy: "testDriver"},
-				Labels:               map[string]string{},
+				Labels:               map[string]string{labelKeyCreatedForClaimName: "testPVCName", labelKeyCreatedForClaimNamespace: "testPVCNamespace", labelKeyCreatedForVolumeName: "testPVName"},
 			},
 		},
 		{
@@ -146,6 +146,30 @@ func TestExtractAndDefaultParameters(t *testing.T) {
 				Labels:               map[string]string{"key1": "value1", "label-1": "value-a", "label-2": "label-value-2"},
 			},
 		},
+		{
+			name:       "PVC labels",
+			parameters: map[string]string{ParameterKeyPVCName: "testPVCName", ParameterKeyPVCNamespace: "testPVCNamespace", ParameterKeyPVName: "testPVName"},
+			labels:     map[string]string{},
+			expectParams: DiskParameters{
+				DiskType:             "pd-standard",
+				ReplicationType:      "none",
+				DiskEncryptionKMSKey: "",
+				Tags:                 map[string]string{tagKeyCreatedForClaimName: "testPVCName", tagKeyCreatedForClaimNamespace: "testPVCNamespace", tagKeyCreatedForVolumeName: "testPVName", tagKeyCreatedBy: "testDriver"},
+				Labels:               map[string]string{labelKeyCreatedForClaimName: "testPVCName", labelKeyCreatedForClaimNamespace: "testPVCNamespace", labelKeyCreatedForVolumeName: "testPVName"},
+			},
+		},
+		{
+			name:       "PVC labels-override",
+			parameters: map[string]string{ParameterKeyPVCName: "testPVCName", ParameterKeyPVCNamespace: "testPVCNamespace", ParameterKeyPVName: "testPVName"},
+			labels:     map[string]string{labelKeyCreatedForClaimNamespace: "test-override"},
+			expectParams: DiskParameters{
+				DiskType:             "pd-standard",
+				ReplicationType:      "none",
+				DiskEncryptionKMSKey: "",
+				Tags:                 map[string]string{tagKeyCreatedForClaimName: "testPVCName", tagKeyCreatedForClaimNamespace: "testPVCNamespace", tagKeyCreatedForVolumeName: "testPVName", tagKeyCreatedBy: "testDriver"},
+				Labels:               map[string]string{labelKeyCreatedForClaimName: "testPVCName", labelKeyCreatedForClaimNamespace: "testPVCNamespace", labelKeyCreatedForVolumeName: "testPVName"},
+			},
+		},
 	}
 
 	for _, tc := range tests {
diff --git a/test/sanity/sanity_test.go b/test/sanity/sanity_test.go
index 597a8a4e..5ac10f3a 100644
--- a/test/sanity/sanity_test.go
+++ b/test/sanity/sanity_test.go
@@ -66,7 +66,7 @@ func TestSanity(t *testing.T) {
 
 	//Initialize GCE Driver
 	identityServer := driver.NewIdentityServer(gceDriver)
-	controllerServer := driver.NewControllerServer(gceDriver, cloudProvider, 1*time.Millisecond, 5*time.Minute)
+	controllerServer := driver.NewControllerServer(gceDriver, cloudProvider, 0, 5*time.Minute)
 	nodeServer := driver.NewNodeServer(gceDriver, mounter, deviceUtils, metadataservice.NewFakeService(), mountmanager.NewFakeStatter(mounter))
 	err = gceDriver.SetupGCEDriver(driverName, vendorVersion, extraLabels, identityServer, controllerServer, nodeServer)
 	if err != nil {