Merge pull request #95909 from pohly/pv-controller-delete-pv-fix

PV controller: don't delete PVs when PVC is not known yet
This commit is contained in:
Kubernetes Prow Robot
2020-11-02 02:00:52 -08:00
committed by GitHub
4 changed files with 80 additions and 9 deletions

View File

@@ -78,6 +78,17 @@ func TestControllerSync(t *testing.T) {
return nil
},
},
{
"5-2-2 - complete bind when PV and PVC both exist",
newVolumeArray("volume5-2", "1Gi", "", "", v1.VolumeAvailable, v1.PersistentVolumeReclaimRetain, classEmpty),
newVolumeArray("volume5-2", "1Gi", "uid5-2", "claim5-2", v1.VolumeBound, v1.PersistentVolumeReclaimRetain, classEmpty, pvutil.AnnBoundByController),
newClaimArray("claim5-2", "uid5-2", "1Gi", "", v1.ClaimPending, nil),
newClaimArray("claim5-2", "uid5-2", "1Gi", "volume5-2", v1.ClaimBound, nil, pvutil.AnnBoundByController, pvutil.AnnBindCompleted),
noevents, noerrors,
func(ctrl *PersistentVolumeController, reactor *pvtesting.VolumeReactor, test controllerTest) error {
return nil
},
},
{
// deleteClaim with a bound claim makes bound volume released.
"5-3 - delete claim",
@@ -273,9 +284,7 @@ func TestControllerSync(t *testing.T) {
},
}
for _, test := range tests {
klog.V(4).Infof("starting test %q", test.name)
doit := func(test controllerTest) {
// Initialize the controller
client := &fake.Clientset{}
@@ -352,6 +361,13 @@ func TestControllerSync(t *testing.T) {
evaluateTestResults(ctrl, reactor.VolumeReactor, test, t)
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
doit(test)
})
}
}
func storeVersion(t *testing.T, prefix string, c cache.Store, version string, expectedReturn bool) {