mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Dynamic provisioning V2 controller, provisioners, docs and tests.
This commit is contained in:
@@ -18,12 +18,11 @@ package persistentvolume
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/client/cache"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// persistentVolumeOrderedIndex is a cache.Store that keeps persistent volumes
|
||||
@@ -126,11 +125,16 @@ func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *api.PersistentVo
|
||||
// filter out:
|
||||
// - volumes bound to another claim
|
||||
// - volumes whose labels don't match the claim's selector, if specified
|
||||
// - volumes in Class that is not requested
|
||||
if volume.Spec.ClaimRef != nil {
|
||||
continue
|
||||
} else if selector != nil && !selector.Matches(labels.Set(volume.Labels)) {
|
||||
continue
|
||||
}
|
||||
claimClass := getClaimClass(claim)
|
||||
if claimClass != "" && claimClass != getVolumeClass(volume) {
|
||||
continue
|
||||
}
|
||||
|
||||
volumeQty := volume.Spec.Capacity[api.ResourceStorage]
|
||||
volumeSize := volumeQty.Value()
|
||||
@@ -142,17 +146,6 @@ func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *api.PersistentVo
|
||||
}
|
||||
}
|
||||
|
||||
// We want to provision volumes if the annotation is set even if there
|
||||
// is matching PV. Therefore, do not look for available PV and let
|
||||
// a new volume to be provisioned.
|
||||
//
|
||||
// When provisioner creates a new PV to this claim, an exact match
|
||||
// pre-bound to the claim will be found by the checks above during
|
||||
// subsequent claim sync.
|
||||
if hasAnnotation(claim.ObjectMeta, annClass) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if smallestVolume != nil {
|
||||
// Found a matching volume
|
||||
return smallestVolume, nil
|
||||
|
||||
Reference in New Issue
Block a user