mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #105245 from yibozhuang/lost-pvc-prefilter-optimization
Scheduler volumebinding plugin - handle Lost PVC as UnschedulableAndUnresolvable
This commit is contained in:
commit
6c292ce270
@ -135,6 +135,13 @@ func (pvcb pvcBuilder) withRequestStorage(request resource.Quantity) pvcBuilder
|
||||
return pvcb
|
||||
}
|
||||
|
||||
func (pvcb pvcBuilder) withPhase(phase v1.PersistentVolumeClaimPhase) pvcBuilder {
|
||||
pvcb.PersistentVolumeClaim.Status = v1.PersistentVolumeClaimStatus{
|
||||
Phase: phase,
|
||||
}
|
||||
return pvcb
|
||||
}
|
||||
|
||||
type podBuilder struct {
|
||||
*v1.Pod
|
||||
}
|
||||
|
@ -150,6 +150,10 @@ func (pl *VolumeBinding) podHasPVCs(pod *v1.Pod) (bool, error) {
|
||||
return hasPVC, err
|
||||
}
|
||||
|
||||
if pvc.Status.Phase == v1.ClaimLost {
|
||||
return hasPVC, fmt.Errorf("persistentvolumeclaim %q bound to non-existent persistentvolume %q", pvc.Name, pvc.Spec.VolumeName)
|
||||
}
|
||||
|
||||
if pvc.DeletionTimestamp != nil {
|
||||
return hasPVC, fmt.Errorf("persistentvolumeclaim %q is being deleted", pvc.Name)
|
||||
}
|
||||
|
@ -266,6 +266,23 @@ func TestVolumeBinding(t *testing.T) {
|
||||
0,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "pv not found claim lost",
|
||||
pod: makePod("pod-a").withPVCVolume("pvc-a", "").Pod,
|
||||
nodes: []*v1.Node{
|
||||
makeNode("node-a").Node,
|
||||
},
|
||||
pvcs: []*v1.PersistentVolumeClaim{
|
||||
makePVC("pvc-a", waitSC.Name).withBoundPV("pv-a").withPhase(v1.ClaimLost).PersistentVolumeClaim,
|
||||
},
|
||||
wantPreFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, `persistentvolumeclaim "pvc-a" bound to non-existent persistentvolume "pv-a"`),
|
||||
wantFilterStatus: []*framework.Status{
|
||||
nil,
|
||||
},
|
||||
wantScores: []int64{
|
||||
0,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "local volumes with close capacity are preferred",
|
||||
pod: makePod("pod-a").withPVCVolume("pvc-a", "").Pod,
|
||||
|
Loading…
Reference in New Issue
Block a user