Repository: dell/csi-baremetal
Pull request #472 (2021-08-02 10:08:36)

[ISSUE-463] ignore not found pvc and retry it
Signed-off-by: yurkov anton <yurkov-ant@yandex.ru>

## Purpose
### Issue #463

CSI can create PVC later then try to find nodes for pod. If csi-provisioner get response for filter nodes with error, it'll exit with error. But if response without error and empty nodes list, csi-provisioner repeat request.
[kubernetes-csi/external-provisioner](https://github.com/kubernetes-csi/external-provisioner/blob/61317e204eb271d8f47ae7983f97abbb60cbf3a4/vendor/github.com/kubernetes-csi/csi-lib-utils/rpc/common.go#L109) link to request logic.

Probe: The external-provisioner retries calling Probe until the driver reports it's ready. It retries also when it receives timeout from Probe call. The external-provisioner has no limit of retries. It is expected that ReadinessProbe on the driver container will catch case when the driver takes too long time to get ready.

Skipping error if PVC not found.

## PR checklist
- [x] Add link to the issue
- [x] Choose PR label
- [ ] New unit tests added
- [ ] Modified code has meaningful comments
- [ ] All TODOs are linked with the issues
- [ ] All comments are resolved



codecov[bot]: # [Codecov](https://codecov.io/gh/dell/csi-baremetal/pull/472?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell) Report
> Merging [#472](https://codecov.io/gh/dell/csi-baremetal/pull/472?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell) (f4eda55) into [master](https://codecov.io/gh/dell/csi-baremetal/commit/927e745460db9f4fab3123b9bdc10e0176d1a383?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell) (927e745) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/dell/csi-baremetal/pull/472/graphs/tree.svg?width=650&height=150&src=pr&token=4D8WVNWX5O&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell)](https://codecov.io/gh/dell/csi-baremetal/pull/472?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell)

```diff
@@           Coverage Diff           @@
##           master     #472   +/-   ##
=======================================
  Coverage   59.20%   59.20%           
=======================================
  Files          59       59           
  Lines        5954     5954           
=======================================
  Hits         3525     3525           
  Misses       2222     2222           
  Partials      207      207           
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `59.20% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/dell/csi-baremetal/pull/472?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell) | Coverage Δ | |
|---|---|---|
| [pkg/scheduler/extender/extender.go](https://codecov.io/gh/dell/csi-baremetal/pull/472/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell#diff-cGtnL3NjaGVkdWxlci9leHRlbmRlci9leHRlbmRlci5nbw==) | `36.12% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/dell/csi-baremetal/pull/472?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/dell/csi-baremetal/pull/472?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell). Last update [927e745...f4eda55](https://codecov.io/gh/dell/csi-baremetal/pull/472?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dell).


Patch:
diff --git a/pkg/scheduler/extender/extender.go b/pkg/scheduler/extender/extender.go
index c9d667e..90d200a 100644
--- a/pkg/scheduler/extender/extender.go
+++ b/pkg/scheduler/extender/extender.go
@@ -245,7 +245,8 @@ func (e *Extender) gatherCapacityRequestsByProvisioner(ctx context.Context, pod
 			err := e.k8sCache.ReadCR(ctx, v.PersistentVolumeClaim.ClaimName, pod.Namespace, pvc)
 			if err != nil {
 				ll.Errorf("Unable to read PVC %s in NS %s: %v. ", v.PersistentVolumeClaim.ClaimName, pod.Namespace, err)
-				return nil, err
+				// PVC can be created later. csi-provisioner repeat request if not error.
+				return nil, nil
 			}
 			if pvc.Spec.StorageClassName == nil {
 				continue


Test patch:
diff --git a/pkg/scheduler/extender/extender_test.go b/pkg/scheduler/extender/extender_test.go
index 505b0d7..674e9cd 100644
--- a/pkg/scheduler/extender/extender_test.go
+++ b/pkg/scheduler/extender/extender_test.go
@@ -188,7 +188,7 @@ func TestExtender_gatherVolumesByProvisioner_Fail(t *testing.T) {
 	})
 	volumes, err = e.gatherCapacityRequestsByProvisioner(testCtx, &pod)
 	assert.Nil(t, volumes)
-	assert.NotNil(t, err)
+	assert.Nil(t, err) // PVC can be created later
 
 	// PVC doesn't contain information about size
 	pod.Namespace = testNs