mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Remove wrappers around storage-related listers in the predicate
Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
This commit is contained in:
parent
e4bb49a231
commit
3bfdcf56e6
@ -23,6 +23,9 @@ import (
|
|||||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
|
corelisters "k8s.io/client-go/listers/core/v1"
|
||||||
|
storagelisters "k8s.io/client-go/listers/storage/v1"
|
||||||
|
v1beta1storagelisters "k8s.io/client-go/listers/storage/v1beta1"
|
||||||
csitrans "k8s.io/csi-translation-lib"
|
csitrans "k8s.io/csi-translation-lib"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
|
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
|
||||||
@ -43,10 +46,10 @@ type InTreeToCSITranslator interface {
|
|||||||
|
|
||||||
// CSIMaxVolumeLimitChecker defines predicate needed for counting CSI volumes
|
// CSIMaxVolumeLimitChecker defines predicate needed for counting CSI volumes
|
||||||
type CSIMaxVolumeLimitChecker struct {
|
type CSIMaxVolumeLimitChecker struct {
|
||||||
csiNodeInfo CSINodeInfo
|
csiNodeLister v1beta1storagelisters.CSINodeLister
|
||||||
pvInfo PersistentVolumeInfo
|
pvLister corelisters.PersistentVolumeLister
|
||||||
pvcInfo PersistentVolumeClaimInfo
|
pvcLister corelisters.PersistentVolumeClaimLister
|
||||||
scInfo StorageClassInfo
|
scLister storagelisters.StorageClassLister
|
||||||
|
|
||||||
randomVolumeIDPrefix string
|
randomVolumeIDPrefix string
|
||||||
|
|
||||||
@ -55,12 +58,12 @@ type CSIMaxVolumeLimitChecker struct {
|
|||||||
|
|
||||||
// NewCSIMaxVolumeLimitPredicate returns a predicate for counting CSI volumes
|
// NewCSIMaxVolumeLimitPredicate returns a predicate for counting CSI volumes
|
||||||
func NewCSIMaxVolumeLimitPredicate(
|
func NewCSIMaxVolumeLimitPredicate(
|
||||||
csiNodeInfo CSINodeInfo, pvInfo PersistentVolumeInfo, pvcInfo PersistentVolumeClaimInfo, scInfo StorageClassInfo) FitPredicate {
|
csiNodeLister v1beta1storagelisters.CSINodeLister, pvLister corelisters.PersistentVolumeLister, pvcLister corelisters.PersistentVolumeClaimLister, scLister storagelisters.StorageClassLister) FitPredicate {
|
||||||
c := &CSIMaxVolumeLimitChecker{
|
c := &CSIMaxVolumeLimitChecker{
|
||||||
csiNodeInfo: csiNodeInfo,
|
csiNodeLister: csiNodeLister,
|
||||||
pvInfo: pvInfo,
|
pvLister: pvLister,
|
||||||
pvcInfo: pvcInfo,
|
pvcLister: pvcLister,
|
||||||
scInfo: scInfo,
|
scLister: scLister,
|
||||||
randomVolumeIDPrefix: rand.String(32),
|
randomVolumeIDPrefix: rand.String(32),
|
||||||
translator: csitrans.New(),
|
translator: csitrans.New(),
|
||||||
}
|
}
|
||||||
@ -100,7 +103,7 @@ func (c *CSIMaxVolumeLimitChecker) attachableLimitPredicate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If CSINode doesn't exist, the predicate may read the limits from Node object
|
// If CSINode doesn't exist, the predicate may read the limits from Node object
|
||||||
csiNode, err := c.csiNodeInfo.GetCSINodeInfo(node.Name)
|
csiNode, err := c.csiNodeLister.Get(node.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: return the error once CSINode is created by default (2 releases)
|
// TODO: return the error once CSINode is created by default (2 releases)
|
||||||
klog.V(5).Infof("Could not get a CSINode object for the node: %v", err)
|
klog.V(5).Infof("Could not get a CSINode object for the node: %v", err)
|
||||||
@ -169,7 +172,7 @@ func (c *CSIMaxVolumeLimitChecker) filterAttachableVolumes(
|
|||||||
return fmt.Errorf("PersistentVolumeClaim had no name")
|
return fmt.Errorf("PersistentVolumeClaim had no name")
|
||||||
}
|
}
|
||||||
|
|
||||||
pvc, err := c.pvcInfo.GetPersistentVolumeClaimInfo(namespace, pvcName)
|
pvc, err := c.pvcLister.PersistentVolumeClaims(namespace).Get(pvcName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(5).Infof("Unable to look up PVC info for %s/%s", namespace, pvcName)
|
klog.V(5).Infof("Unable to look up PVC info for %s/%s", namespace, pvcName)
|
||||||
@ -202,7 +205,7 @@ func (c *CSIMaxVolumeLimitChecker) getCSIDriverInfo(csiNode *storagev1beta1.CSIN
|
|||||||
return c.getCSIDriverInfoFromSC(csiNode, pvc)
|
return c.getCSIDriverInfoFromSC(csiNode, pvc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pv, err := c.pvInfo.GetPersistentVolumeInfo(pvName)
|
pv, err := c.pvLister.Get(pvName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(5).Infof("Unable to look up PV info for PVC %s/%s and PV %s", namespace, pvcName, pvName)
|
klog.V(5).Infof("Unable to look up PV info for PVC %s/%s and PV %s", namespace, pvcName, pvName)
|
||||||
// If we can't fetch PV associated with PVC, may be it got deleted
|
// If we can't fetch PV associated with PVC, may be it got deleted
|
||||||
@ -259,7 +262,7 @@ func (c *CSIMaxVolumeLimitChecker) getCSIDriverInfoFromSC(csiNode *storagev1beta
|
|||||||
return "", ""
|
return "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
storageClass, err := c.scInfo.GetStorageClassInfo(scName)
|
storageClass, err := c.scLister.Get(scName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(5).Infof("Could not get StorageClass for PVC %s/%s: %v", namespace, pvcName, err)
|
klog.V(5).Infof("Could not get StorageClass for PVC %s/%s: %v", namespace, pvcName, err)
|
||||||
return "", ""
|
return "", ""
|
||||||
|
@ -160,75 +160,6 @@ type NodeInfo interface {
|
|||||||
// The failure information is given by the error.
|
// The failure information is given by the error.
|
||||||
type FitPredicate func(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
|
type FitPredicate func(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
|
||||||
|
|
||||||
// CSINodeInfo interface represents anything that can get CSINode object from node name.
|
|
||||||
type CSINodeInfo interface {
|
|
||||||
GetCSINodeInfo(nodeName string) (*v1beta1storage.CSINode, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ CSINodeInfo = &CachedCSINodeInfo{}
|
|
||||||
|
|
||||||
// CachedCSINodeInfo implements CSINodeInfoInfo
|
|
||||||
type CachedCSINodeInfo struct {
|
|
||||||
v1beta1storagelisters.CSINodeLister
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCSINodeInfo returns a persistent volume object by PV ID.
|
|
||||||
func (c *CachedCSINodeInfo) GetCSINodeInfo(nodeName string) (*v1beta1storage.CSINode, error) {
|
|
||||||
return c.Get(nodeName)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PersistentVolumeInfo interface represents anything that can get persistent volume object by PV ID.
|
|
||||||
type PersistentVolumeInfo interface {
|
|
||||||
GetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ PersistentVolumeInfo = &CachedPersistentVolumeInfo{}
|
|
||||||
|
|
||||||
// CachedPersistentVolumeInfo implements PersistentVolumeInfo
|
|
||||||
type CachedPersistentVolumeInfo struct {
|
|
||||||
corelisters.PersistentVolumeLister
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPersistentVolumeInfo returns a persistent volume object by PV ID.
|
|
||||||
func (c *CachedPersistentVolumeInfo) GetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error) {
|
|
||||||
return c.Get(pvID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PersistentVolumeClaimInfo interface represents anything that can get a PVC object in
|
|
||||||
// specified namespace with specified name.
|
|
||||||
type PersistentVolumeClaimInfo interface {
|
|
||||||
GetPersistentVolumeClaimInfo(namespace string, name string) (*v1.PersistentVolumeClaim, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ PersistentVolumeClaimInfo = &CachedPersistentVolumeClaimInfo{}
|
|
||||||
|
|
||||||
// CachedPersistentVolumeClaimInfo implements PersistentVolumeClaimInfo
|
|
||||||
type CachedPersistentVolumeClaimInfo struct {
|
|
||||||
corelisters.PersistentVolumeClaimLister
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPersistentVolumeClaimInfo fetches the claim in specified namespace with specified name.
|
|
||||||
func (c *CachedPersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo(namespace string, name string) (*v1.PersistentVolumeClaim, error) {
|
|
||||||
return c.PersistentVolumeClaims(namespace).Get(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// StorageClassInfo interface represents anything that can get a storage class object by class name.
|
|
||||||
type StorageClassInfo interface {
|
|
||||||
GetStorageClassInfo(className string) (*storage.StorageClass, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ StorageClassInfo = &CachedStorageClassInfo{}
|
|
||||||
|
|
||||||
// CachedStorageClassInfo implements StorageClassInfo
|
|
||||||
type CachedStorageClassInfo struct {
|
|
||||||
storagelisters.StorageClassLister
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetStorageClassInfo get StorageClass by class name.
|
|
||||||
func (c *CachedStorageClassInfo) GetStorageClassInfo(className string) (*storage.StorageClass, error) {
|
|
||||||
return c.Get(className)
|
|
||||||
}
|
|
||||||
|
|
||||||
func isVolumeConflict(volume v1.Volume, pod *v1.Pod) bool {
|
func isVolumeConflict(volume v1.Volume, pod *v1.Pod) bool {
|
||||||
// fast path if there is no conflict checking targets.
|
// fast path if there is no conflict checking targets.
|
||||||
if volume.GCEPersistentDisk == nil && volume.AWSElasticBlockStore == nil && volume.RBD == nil && volume.ISCSI == nil {
|
if volume.GCEPersistentDisk == nil && volume.AWSElasticBlockStore == nil && volume.RBD == nil && volume.ISCSI == nil {
|
||||||
@ -301,10 +232,10 @@ type MaxPDVolumeCountChecker struct {
|
|||||||
filter VolumeFilter
|
filter VolumeFilter
|
||||||
volumeLimitKey v1.ResourceName
|
volumeLimitKey v1.ResourceName
|
||||||
maxVolumeFunc func(node *v1.Node) int
|
maxVolumeFunc func(node *v1.Node) int
|
||||||
csiNodeInfo CSINodeInfo
|
csiNodeLister v1beta1storagelisters.CSINodeLister
|
||||||
pvInfo PersistentVolumeInfo
|
pvLister corelisters.PersistentVolumeLister
|
||||||
pvcInfo PersistentVolumeClaimInfo
|
pvcLister corelisters.PersistentVolumeClaimLister
|
||||||
scInfo StorageClassInfo
|
scLister storagelisters.StorageClassLister
|
||||||
|
|
||||||
// The string below is generated randomly during the struct's initialization.
|
// The string below is generated randomly during the struct's initialization.
|
||||||
// It is used to prefix volumeID generated inside the predicate() method to
|
// It is used to prefix volumeID generated inside the predicate() method to
|
||||||
@ -333,8 +264,8 @@ type VolumeFilter struct {
|
|||||||
// The predicate looks for both volumes used directly, as well as PVC volumes that are backed by relevant volume
|
// The predicate looks for both volumes used directly, as well as PVC volumes that are backed by relevant volume
|
||||||
// types, counts the number of unique volumes, and rejects the new pod if it would place the total count over
|
// types, counts the number of unique volumes, and rejects the new pod if it would place the total count over
|
||||||
// the maximum.
|
// the maximum.
|
||||||
func NewMaxPDVolumeCountPredicate(filterName string, csiNodeInfo CSINodeInfo, scInfo StorageClassInfo,
|
func NewMaxPDVolumeCountPredicate(filterName string, csiNodeLister v1beta1storagelisters.CSINodeLister, scLister storagelisters.StorageClassLister,
|
||||||
pvInfo PersistentVolumeInfo, pvcInfo PersistentVolumeClaimInfo) FitPredicate {
|
pvLister corelisters.PersistentVolumeLister, pvcLister corelisters.PersistentVolumeClaimLister) FitPredicate {
|
||||||
var filter VolumeFilter
|
var filter VolumeFilter
|
||||||
var volumeLimitKey v1.ResourceName
|
var volumeLimitKey v1.ResourceName
|
||||||
|
|
||||||
@ -362,10 +293,10 @@ func NewMaxPDVolumeCountPredicate(filterName string, csiNodeInfo CSINodeInfo, sc
|
|||||||
filter: filter,
|
filter: filter,
|
||||||
volumeLimitKey: volumeLimitKey,
|
volumeLimitKey: volumeLimitKey,
|
||||||
maxVolumeFunc: getMaxVolumeFunc(filterName),
|
maxVolumeFunc: getMaxVolumeFunc(filterName),
|
||||||
csiNodeInfo: csiNodeInfo,
|
csiNodeLister: csiNodeLister,
|
||||||
pvInfo: pvInfo,
|
pvLister: pvLister,
|
||||||
pvcInfo: pvcInfo,
|
pvcLister: pvcLister,
|
||||||
scInfo: scInfo,
|
scLister: scLister,
|
||||||
randomVolumeIDPrefix: rand.String(32),
|
randomVolumeIDPrefix: rand.String(32),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +369,7 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []v1.Volume, namespace s
|
|||||||
// to avoid conflicts with existing volume IDs.
|
// to avoid conflicts with existing volume IDs.
|
||||||
pvID := fmt.Sprintf("%s-%s/%s", c.randomVolumeIDPrefix, namespace, pvcName)
|
pvID := fmt.Sprintf("%s-%s/%s", c.randomVolumeIDPrefix, namespace, pvcName)
|
||||||
|
|
||||||
pvc, err := c.pvcInfo.GetPersistentVolumeClaimInfo(namespace, pvcName)
|
pvc, err := c.pvcLister.PersistentVolumeClaims(namespace).Get(pvcName)
|
||||||
if err != nil || pvc == nil {
|
if err != nil || pvc == nil {
|
||||||
// If the PVC is invalid, we don't count the volume because
|
// If the PVC is invalid, we don't count the volume because
|
||||||
// there's no guarantee that it belongs to the running predicate.
|
// there's no guarantee that it belongs to the running predicate.
|
||||||
@ -459,7 +390,7 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []v1.Volume, namespace s
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
pv, err := c.pvInfo.GetPersistentVolumeInfo(pvName)
|
pv, err := c.pvLister.Get(pvName)
|
||||||
if err != nil || pv == nil {
|
if err != nil || pv == nil {
|
||||||
// If the PV is invalid and PVC belongs to the running predicate,
|
// If the PV is invalid and PVC belongs to the running predicate,
|
||||||
// log the error and count the PV towards the PV limit.
|
// log the error and count the PV towards the PV limit.
|
||||||
@ -485,7 +416,7 @@ func (c *MaxPDVolumeCountChecker) matchProvisioner(pvc *v1.PersistentVolumeClaim
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
storageClass, err := c.scInfo.GetStorageClassInfo(*pvc.Spec.StorageClassName)
|
storageClass, err := c.scLister.Get(*pvc.Spec.StorageClassName)
|
||||||
if err != nil || storageClass == nil {
|
if err != nil || storageClass == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -515,7 +446,7 @@ func (c *MaxPDVolumeCountChecker) predicate(pod *v1.Pod, meta PredicateMetadata,
|
|||||||
return false, nil, fmt.Errorf("node not found")
|
return false, nil, fmt.Errorf("node not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
csiNode, err := c.csiNodeInfo.GetCSINodeInfo(node.Name)
|
csiNode, err := c.csiNodeLister.Get(node.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// we don't fail here because the CSINode object is only necessary
|
// we don't fail here because the CSINode object is only necessary
|
||||||
// for determining whether the migration is enabled or not
|
// for determining whether the migration is enabled or not
|
||||||
@ -681,9 +612,9 @@ var CinderVolumeFilter = VolumeFilter{
|
|||||||
|
|
||||||
// VolumeZoneChecker contains information to check the volume zone for a predicate.
|
// VolumeZoneChecker contains information to check the volume zone for a predicate.
|
||||||
type VolumeZoneChecker struct {
|
type VolumeZoneChecker struct {
|
||||||
pvInfo PersistentVolumeInfo
|
pvLister corelisters.PersistentVolumeLister
|
||||||
pvcInfo PersistentVolumeClaimInfo
|
pvcLister corelisters.PersistentVolumeClaimLister
|
||||||
classInfo StorageClassInfo
|
scLister storagelisters.StorageClassLister
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewVolumeZonePredicate evaluates if a pod can fit due to the volumes it requests, given
|
// NewVolumeZonePredicate evaluates if a pod can fit due to the volumes it requests, given
|
||||||
@ -700,11 +631,11 @@ type VolumeZoneChecker struct {
|
|||||||
// determining the zone of a volume during scheduling, and that is likely to
|
// determining the zone of a volume during scheduling, and that is likely to
|
||||||
// require calling out to the cloud provider. It seems that we are moving away
|
// require calling out to the cloud provider. It seems that we are moving away
|
||||||
// from inline volume declarations anyway.
|
// from inline volume declarations anyway.
|
||||||
func NewVolumeZonePredicate(pvInfo PersistentVolumeInfo, pvcInfo PersistentVolumeClaimInfo, classInfo StorageClassInfo) FitPredicate {
|
func NewVolumeZonePredicate(pvLister corelisters.PersistentVolumeLister, pvcLister corelisters.PersistentVolumeClaimLister, scLister storagelisters.StorageClassLister) FitPredicate {
|
||||||
c := &VolumeZoneChecker{
|
c := &VolumeZoneChecker{
|
||||||
pvInfo: pvInfo,
|
pvLister: pvLister,
|
||||||
pvcInfo: pvcInfo,
|
pvcLister: pvcLister,
|
||||||
classInfo: classInfo,
|
scLister: scLister,
|
||||||
}
|
}
|
||||||
return c.predicate
|
return c.predicate
|
||||||
}
|
}
|
||||||
@ -745,7 +676,7 @@ func (c *VolumeZoneChecker) predicate(pod *v1.Pod, meta PredicateMetadata, nodeI
|
|||||||
if pvcName == "" {
|
if pvcName == "" {
|
||||||
return false, nil, fmt.Errorf("PersistentVolumeClaim had no name")
|
return false, nil, fmt.Errorf("PersistentVolumeClaim had no name")
|
||||||
}
|
}
|
||||||
pvc, err := c.pvcInfo.GetPersistentVolumeClaimInfo(namespace, pvcName)
|
pvc, err := c.pvcLister.PersistentVolumeClaims(namespace).Get(pvcName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
@ -758,7 +689,7 @@ func (c *VolumeZoneChecker) predicate(pod *v1.Pod, meta PredicateMetadata, nodeI
|
|||||||
if pvName == "" {
|
if pvName == "" {
|
||||||
scName := v1helper.GetPersistentVolumeClaimClass(pvc)
|
scName := v1helper.GetPersistentVolumeClaimClass(pvc)
|
||||||
if len(scName) > 0 {
|
if len(scName) > 0 {
|
||||||
class, _ := c.classInfo.GetStorageClassInfo(scName)
|
class, _ := c.scLister.Get(scName)
|
||||||
if class != nil {
|
if class != nil {
|
||||||
if class.VolumeBindingMode == nil {
|
if class.VolumeBindingMode == nil {
|
||||||
return false, nil, fmt.Errorf("VolumeBindingMode not set for StorageClass %q", scName)
|
return false, nil, fmt.Errorf("VolumeBindingMode not set for StorageClass %q", scName)
|
||||||
@ -772,7 +703,7 @@ func (c *VolumeZoneChecker) predicate(pod *v1.Pod, meta PredicateMetadata, nodeI
|
|||||||
return false, nil, fmt.Errorf("PersistentVolumeClaim was not found: %q", pvcName)
|
return false, nil, fmt.Errorf("PersistentVolumeClaim was not found: %q", pvcName)
|
||||||
}
|
}
|
||||||
|
|
||||||
pv, err := c.pvInfo.GetPersistentVolumeInfo(pvName)
|
pv, err := c.pvLister.Get(pvName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ import (
|
|||||||
appslisters "k8s.io/client-go/listers/apps/v1"
|
appslisters "k8s.io/client-go/listers/apps/v1"
|
||||||
corelisters "k8s.io/client-go/listers/core/v1"
|
corelisters "k8s.io/client-go/listers/core/v1"
|
||||||
policylisters "k8s.io/client-go/listers/policy/v1beta1"
|
policylisters "k8s.io/client-go/listers/policy/v1beta1"
|
||||||
|
storagelisters "k8s.io/client-go/listers/storage/v1"
|
||||||
|
v1beta1storagelisters "k8s.io/client-go/listers/storage/v1beta1"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"
|
||||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
||||||
@ -46,10 +48,10 @@ type PluginFactoryArgs struct {
|
|||||||
StatefulSetLister appslisters.StatefulSetLister
|
StatefulSetLister appslisters.StatefulSetLister
|
||||||
PDBLister policylisters.PodDisruptionBudgetLister
|
PDBLister policylisters.PodDisruptionBudgetLister
|
||||||
NodeLister schedulerlisters.NodeLister
|
NodeLister schedulerlisters.NodeLister
|
||||||
CSINodeInfo predicates.CSINodeInfo
|
CSINodeLister v1beta1storagelisters.CSINodeLister
|
||||||
PVInfo predicates.PersistentVolumeInfo
|
PVLister corelisters.PersistentVolumeLister
|
||||||
PVCInfo predicates.PersistentVolumeClaimInfo
|
PVCLister corelisters.PersistentVolumeClaimLister
|
||||||
StorageClassInfo predicates.StorageClassInfo
|
StorageClassLister storagelisters.StorageClassLister
|
||||||
VolumeBinder *volumebinder.VolumeBinder
|
VolumeBinder *volumebinder.VolumeBinder
|
||||||
HardPodAffinitySymmetricWeight int32
|
HardPodAffinitySymmetricWeight int32
|
||||||
}
|
}
|
||||||
|
@ -51,40 +51,40 @@ func init() {
|
|||||||
scheduler.RegisterFitPredicateFactory(
|
scheduler.RegisterFitPredicateFactory(
|
||||||
predicates.NoVolumeZoneConflictPred,
|
predicates.NoVolumeZoneConflictPred,
|
||||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||||
return predicates.NewVolumeZonePredicate(args.PVInfo, args.PVCInfo, args.StorageClassInfo)
|
return predicates.NewVolumeZonePredicate(args.PVLister, args.PVCLister, args.StorageClassLister)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
// Fit is determined by whether or not there would be too many AWS EBS volumes attached to the node
|
// Fit is determined by whether or not there would be too many AWS EBS volumes attached to the node
|
||||||
scheduler.RegisterFitPredicateFactory(
|
scheduler.RegisterFitPredicateFactory(
|
||||||
predicates.MaxEBSVolumeCountPred,
|
predicates.MaxEBSVolumeCountPred,
|
||||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.EBSVolumeFilterType, args.CSINodeInfo, args.StorageClassInfo, args.PVInfo, args.PVCInfo)
|
return predicates.NewMaxPDVolumeCountPredicate(predicates.EBSVolumeFilterType, args.CSINodeLister, args.StorageClassLister, args.PVLister, args.PVCLister)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
// Fit is determined by whether or not there would be too many GCE PD volumes attached to the node
|
// Fit is determined by whether or not there would be too many GCE PD volumes attached to the node
|
||||||
scheduler.RegisterFitPredicateFactory(
|
scheduler.RegisterFitPredicateFactory(
|
||||||
predicates.MaxGCEPDVolumeCountPred,
|
predicates.MaxGCEPDVolumeCountPred,
|
||||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.GCEPDVolumeFilterType, args.CSINodeInfo, args.StorageClassInfo, args.PVInfo, args.PVCInfo)
|
return predicates.NewMaxPDVolumeCountPredicate(predicates.GCEPDVolumeFilterType, args.CSINodeLister, args.StorageClassLister, args.PVLister, args.PVCLister)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
// Fit is determined by whether or not there would be too many Azure Disk volumes attached to the node
|
// Fit is determined by whether or not there would be too many Azure Disk volumes attached to the node
|
||||||
scheduler.RegisterFitPredicateFactory(
|
scheduler.RegisterFitPredicateFactory(
|
||||||
predicates.MaxAzureDiskVolumeCountPred,
|
predicates.MaxAzureDiskVolumeCountPred,
|
||||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.AzureDiskVolumeFilterType, args.CSINodeInfo, args.StorageClassInfo, args.PVInfo, args.PVCInfo)
|
return predicates.NewMaxPDVolumeCountPredicate(predicates.AzureDiskVolumeFilterType, args.CSINodeLister, args.StorageClassLister, args.PVLister, args.PVCLister)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
scheduler.RegisterFitPredicateFactory(
|
scheduler.RegisterFitPredicateFactory(
|
||||||
predicates.MaxCSIVolumeCountPred,
|
predicates.MaxCSIVolumeCountPred,
|
||||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||||
return predicates.NewCSIMaxVolumeLimitPredicate(args.CSINodeInfo, args.PVInfo, args.PVCInfo, args.StorageClassInfo)
|
return predicates.NewCSIMaxVolumeLimitPredicate(args.CSINodeLister, args.PVLister, args.PVCLister, args.StorageClassLister)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
scheduler.RegisterFitPredicateFactory(
|
scheduler.RegisterFitPredicateFactory(
|
||||||
predicates.MaxCinderVolumeCountPred,
|
predicates.MaxCinderVolumeCountPred,
|
||||||
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
func(args scheduler.PluginFactoryArgs) predicates.FitPredicate {
|
||||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.CinderVolumeFilterType, args.CSINodeInfo, args.StorageClassInfo, args.PVInfo, args.PVCInfo)
|
return predicates.NewMaxPDVolumeCountPredicate(predicates.CinderVolumeFilterType, args.CSINodeLister, args.StorageClassLister, args.PVLister, args.PVCLister)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -594,10 +594,10 @@ func (c *Configurator) getAlgorithmArgs() (*PluginFactoryArgs, *plugins.ConfigPr
|
|||||||
StatefulSetLister: c.statefulSetLister,
|
StatefulSetLister: c.statefulSetLister,
|
||||||
PDBLister: c.pdbLister,
|
PDBLister: c.pdbLister,
|
||||||
NodeLister: c.schedulerCache,
|
NodeLister: c.schedulerCache,
|
||||||
CSINodeInfo: &predicates.CachedCSINodeInfo{CSINodeLister: c.csiNodeLister},
|
CSINodeLister: c.csiNodeLister,
|
||||||
PVInfo: &predicates.CachedPersistentVolumeInfo{PersistentVolumeLister: c.pVLister},
|
PVLister: c.pVLister,
|
||||||
PVCInfo: &predicates.CachedPersistentVolumeClaimInfo{PersistentVolumeClaimLister: c.pVCLister},
|
PVCLister: c.pVCLister,
|
||||||
StorageClassInfo: &predicates.CachedStorageClassInfo{StorageClassLister: c.storageClassLister},
|
StorageClassLister: c.storageClassLister,
|
||||||
VolumeBinder: c.volumeBinder,
|
VolumeBinder: c.volumeBinder,
|
||||||
HardPodAffinitySymmetricWeight: c.hardPodAffinitySymmetricWeight,
|
HardPodAffinitySymmetricWeight: c.hardPodAffinitySymmetricWeight,
|
||||||
}, &plugins.ConfigProducerArgs{}
|
}, &plugins.ConfigProducerArgs{}
|
||||||
|
@ -52,20 +52,12 @@ func (pl *AzureDiskLimits) Filter(ctx context.Context, _ *framework.CycleState,
|
|||||||
// NewAzureDisk returns function that initializes a new plugin and returns it.
|
// NewAzureDisk returns function that initializes a new plugin and returns it.
|
||||||
func NewAzureDisk(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
func NewAzureDisk(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
||||||
informerFactory := handle.SharedInformerFactory()
|
informerFactory := handle.SharedInformerFactory()
|
||||||
csiNodeInfo := &predicates.CachedCSINodeInfo{
|
csiNodeLister := informerFactory.Storage().V1beta1().CSINodes().Lister()
|
||||||
CSINodeLister: informerFactory.Storage().V1beta1().CSINodes().Lister(),
|
pvLister := informerFactory.Core().V1().PersistentVolumes().Lister()
|
||||||
}
|
pvcLister := informerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||||
pvInfo := &predicates.CachedPersistentVolumeInfo{
|
scLister := informerFactory.Storage().V1().StorageClasses().Lister()
|
||||||
PersistentVolumeLister: informerFactory.Core().V1().PersistentVolumes().Lister(),
|
|
||||||
}
|
|
||||||
pvcInfo := &predicates.CachedPersistentVolumeClaimInfo{
|
|
||||||
PersistentVolumeClaimLister: informerFactory.Core().V1().PersistentVolumeClaims().Lister(),
|
|
||||||
}
|
|
||||||
classInfo := &predicates.CachedStorageClassInfo{
|
|
||||||
StorageClassLister: informerFactory.Storage().V1().StorageClasses().Lister(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return &AzureDiskLimits{
|
return &AzureDiskLimits{
|
||||||
predicate: predicates.NewMaxPDVolumeCountPredicate(predicates.AzureDiskVolumeFilterType, csiNodeInfo, classInfo, pvInfo, pvcInfo),
|
predicate: predicates.NewMaxPDVolumeCountPredicate(predicates.AzureDiskVolumeFilterType, csiNodeLister, scLister, pvLister, pvcLister),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -52,20 +52,11 @@ func (pl *CinderLimits) Filter(ctx context.Context, _ *framework.CycleState, pod
|
|||||||
// NewCinder returns function that initializes a new plugin and returns it.
|
// NewCinder returns function that initializes a new plugin and returns it.
|
||||||
func NewCinder(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
func NewCinder(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
||||||
informerFactory := handle.SharedInformerFactory()
|
informerFactory := handle.SharedInformerFactory()
|
||||||
csiNodeInfo := &predicates.CachedCSINodeInfo{
|
csiNodeLister := informerFactory.Storage().V1beta1().CSINodes().Lister()
|
||||||
CSINodeLister: informerFactory.Storage().V1beta1().CSINodes().Lister(),
|
pvLister := informerFactory.Core().V1().PersistentVolumes().Lister()
|
||||||
}
|
pvcLister := informerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||||
pvInfo := &predicates.CachedPersistentVolumeInfo{
|
scLister := informerFactory.Storage().V1().StorageClasses().Lister()
|
||||||
PersistentVolumeLister: informerFactory.Core().V1().PersistentVolumes().Lister(),
|
|
||||||
}
|
|
||||||
pvcInfo := &predicates.CachedPersistentVolumeClaimInfo{
|
|
||||||
PersistentVolumeClaimLister: informerFactory.Core().V1().PersistentVolumeClaims().Lister(),
|
|
||||||
}
|
|
||||||
classInfo := &predicates.CachedStorageClassInfo{
|
|
||||||
StorageClassLister: informerFactory.Storage().V1().StorageClasses().Lister(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return &CinderLimits{
|
return &CinderLimits{
|
||||||
predicate: predicates.NewMaxPDVolumeCountPredicate(predicates.CinderVolumeFilterType, csiNodeInfo, classInfo, pvInfo, pvcInfo),
|
predicate: predicates.NewMaxPDVolumeCountPredicate(predicates.CinderVolumeFilterType, csiNodeLister, scLister, pvLister, pvcLister),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -52,20 +52,12 @@ func (pl *CSILimits) Filter(ctx context.Context, _ *framework.CycleState, pod *v
|
|||||||
// NewCSI initializes a new plugin and returns it.
|
// NewCSI initializes a new plugin and returns it.
|
||||||
func NewCSI(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
func NewCSI(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
||||||
informerFactory := handle.SharedInformerFactory()
|
informerFactory := handle.SharedInformerFactory()
|
||||||
csiNodeInfo := &predicates.CachedCSINodeInfo{
|
csiNodeLister := informerFactory.Storage().V1beta1().CSINodes().Lister()
|
||||||
CSINodeLister: informerFactory.Storage().V1beta1().CSINodes().Lister(),
|
pvLister := informerFactory.Core().V1().PersistentVolumes().Lister()
|
||||||
}
|
pvcLister := informerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||||
pvInfo := &predicates.CachedPersistentVolumeInfo{
|
scLister := informerFactory.Storage().V1().StorageClasses().Lister()
|
||||||
PersistentVolumeLister: informerFactory.Core().V1().PersistentVolumes().Lister(),
|
|
||||||
}
|
|
||||||
pvcInfo := &predicates.CachedPersistentVolumeClaimInfo{
|
|
||||||
PersistentVolumeClaimLister: informerFactory.Core().V1().PersistentVolumeClaims().Lister(),
|
|
||||||
}
|
|
||||||
classInfo := &predicates.CachedStorageClassInfo{
|
|
||||||
StorageClassLister: informerFactory.Storage().V1().StorageClasses().Lister(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return &CSILimits{
|
return &CSILimits{
|
||||||
predicate: predicates.NewCSIMaxVolumeLimitPredicate(csiNodeInfo, pvInfo, pvcInfo, classInfo),
|
predicate: predicates.NewCSIMaxVolumeLimitPredicate(csiNodeLister, pvLister, pvcLister, scLister),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -52,20 +52,12 @@ func (pl *EBSLimits) Filter(ctx context.Context, _ *framework.CycleState, pod *v
|
|||||||
// NewEBS returns function that initializes a new plugin and returns it.
|
// NewEBS returns function that initializes a new plugin and returns it.
|
||||||
func NewEBS(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
func NewEBS(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
||||||
informerFactory := handle.SharedInformerFactory()
|
informerFactory := handle.SharedInformerFactory()
|
||||||
csiNodeInfo := &predicates.CachedCSINodeInfo{
|
csiNodeLister := informerFactory.Storage().V1beta1().CSINodes().Lister()
|
||||||
CSINodeLister: informerFactory.Storage().V1beta1().CSINodes().Lister(),
|
pvLister := informerFactory.Core().V1().PersistentVolumes().Lister()
|
||||||
}
|
pvcLister := informerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||||
pvInfo := &predicates.CachedPersistentVolumeInfo{
|
scLister := informerFactory.Storage().V1().StorageClasses().Lister()
|
||||||
PersistentVolumeLister: informerFactory.Core().V1().PersistentVolumes().Lister(),
|
|
||||||
}
|
|
||||||
pvcInfo := &predicates.CachedPersistentVolumeClaimInfo{
|
|
||||||
PersistentVolumeClaimLister: informerFactory.Core().V1().PersistentVolumeClaims().Lister(),
|
|
||||||
}
|
|
||||||
classInfo := &predicates.CachedStorageClassInfo{
|
|
||||||
StorageClassLister: informerFactory.Storage().V1().StorageClasses().Lister(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return &EBSLimits{
|
return &EBSLimits{
|
||||||
predicate: predicates.NewMaxPDVolumeCountPredicate(predicates.EBSVolumeFilterType, csiNodeInfo, classInfo, pvInfo, pvcInfo),
|
predicate: predicates.NewMaxPDVolumeCountPredicate(predicates.EBSVolumeFilterType, csiNodeLister, scLister, pvLister, pvcLister),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -52,20 +52,12 @@ func (pl *GCEPDLimits) Filter(ctx context.Context, _ *framework.CycleState, pod
|
|||||||
// NewGCEPD returns function that initializes a new plugin and returns it.
|
// NewGCEPD returns function that initializes a new plugin and returns it.
|
||||||
func NewGCEPD(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
func NewGCEPD(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
||||||
informerFactory := handle.SharedInformerFactory()
|
informerFactory := handle.SharedInformerFactory()
|
||||||
csiNodeInfo := &predicates.CachedCSINodeInfo{
|
csiNodeLister := informerFactory.Storage().V1beta1().CSINodes().Lister()
|
||||||
CSINodeLister: informerFactory.Storage().V1beta1().CSINodes().Lister(),
|
pvLister := informerFactory.Core().V1().PersistentVolumes().Lister()
|
||||||
}
|
pvcLister := informerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||||
pvInfo := &predicates.CachedPersistentVolumeInfo{
|
scLister := informerFactory.Storage().V1().StorageClasses().Lister()
|
||||||
PersistentVolumeLister: informerFactory.Core().V1().PersistentVolumes().Lister(),
|
|
||||||
}
|
|
||||||
pvcInfo := &predicates.CachedPersistentVolumeClaimInfo{
|
|
||||||
PersistentVolumeClaimLister: informerFactory.Core().V1().PersistentVolumeClaims().Lister(),
|
|
||||||
}
|
|
||||||
classInfo := &predicates.CachedStorageClassInfo{
|
|
||||||
StorageClassLister: informerFactory.Storage().V1().StorageClasses().Lister(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return &GCEPDLimits{
|
return &GCEPDLimits{
|
||||||
predicate: predicates.NewMaxPDVolumeCountPredicate(predicates.GCEPDVolumeFilterType, csiNodeInfo, classInfo, pvInfo, pvcInfo),
|
predicate: predicates.NewMaxPDVolumeCountPredicate(predicates.GCEPDVolumeFilterType, csiNodeLister, scLister, pvLister, pvcLister),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -52,16 +52,10 @@ func (pl *VolumeZone) Filter(ctx context.Context, _ *framework.CycleState, pod *
|
|||||||
// New initializes a new plugin and returns it.
|
// New initializes a new plugin and returns it.
|
||||||
func New(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
func New(_ *runtime.Unknown, handle framework.FrameworkHandle) (framework.Plugin, error) {
|
||||||
informerFactory := handle.SharedInformerFactory()
|
informerFactory := handle.SharedInformerFactory()
|
||||||
pvInfo := &predicates.CachedPersistentVolumeInfo{
|
pvLister := informerFactory.Core().V1().PersistentVolumes().Lister()
|
||||||
PersistentVolumeLister: informerFactory.Core().V1().PersistentVolumes().Lister(),
|
pvcLister := informerFactory.Core().V1().PersistentVolumeClaims().Lister()
|
||||||
}
|
scLister := informerFactory.Storage().V1().StorageClasses().Lister()
|
||||||
pvcInfo := &predicates.CachedPersistentVolumeClaimInfo{
|
|
||||||
PersistentVolumeClaimLister: informerFactory.Core().V1().PersistentVolumeClaims().Lister(),
|
|
||||||
}
|
|
||||||
classInfo := &predicates.CachedStorageClassInfo{
|
|
||||||
StorageClassLister: informerFactory.Storage().V1().StorageClasses().Lister(),
|
|
||||||
}
|
|
||||||
return &VolumeZone{
|
return &VolumeZone{
|
||||||
predicate: predicates.NewVolumeZonePredicate(pvInfo, pvcInfo, classInfo),
|
predicate: predicates.NewVolumeZonePredicate(pvLister, pvcLister, scLister),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/listers/apps/v1:go_default_library",
|
"//staging/src/k8s.io/client-go/listers/apps/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
|
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
|
||||||
|
"//staging/src/k8s.io/client-go/listers/storage/v1:go_default_library",
|
||||||
|
"//staging/src/k8s.io/client-go/listers/storage/v1beta1:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
appslisters "k8s.io/client-go/listers/apps/v1"
|
appslisters "k8s.io/client-go/listers/apps/v1"
|
||||||
corelisters "k8s.io/client-go/listers/core/v1"
|
corelisters "k8s.io/client-go/listers/core/v1"
|
||||||
|
storagelisters "k8s.io/client-go/listers/storage/v1"
|
||||||
|
v1beta1storagelisters "k8s.io/client-go/listers/storage/v1beta1"
|
||||||
schedulerlisters "k8s.io/kubernetes/pkg/scheduler/listers"
|
schedulerlisters "k8s.io/kubernetes/pkg/scheduler/listers"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -205,7 +207,7 @@ type PersistentVolumeClaimLister []*v1.PersistentVolumeClaim
|
|||||||
|
|
||||||
var _ corelisters.PersistentVolumeClaimLister = PersistentVolumeClaimLister{}
|
var _ corelisters.PersistentVolumeClaimLister = PersistentVolumeClaimLister{}
|
||||||
|
|
||||||
// List returns not implemented error.
|
// List lists all PersistentVolumeClaims in the indexer.
|
||||||
func (f PersistentVolumeClaimLister) List(selector labels.Selector) (ret []*v1.PersistentVolumeClaim, err error) {
|
func (f PersistentVolumeClaimLister) List(selector labels.Selector) (ret []*v1.PersistentVolumeClaim, err error) {
|
||||||
return nil, fmt.Errorf("not implemented")
|
return nil, fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
@ -240,6 +242,8 @@ func (f persistentVolumeClaimNamespaceLister) List(selector labels.Selector) (re
|
|||||||
// PersistentVolumeClaimInfo declares a []v1.PersistentVolumeClaim type for testing.
|
// PersistentVolumeClaimInfo declares a []v1.PersistentVolumeClaim type for testing.
|
||||||
type PersistentVolumeClaimInfo []v1.PersistentVolumeClaim
|
type PersistentVolumeClaimInfo []v1.PersistentVolumeClaim
|
||||||
|
|
||||||
|
var _ corelisters.PersistentVolumeClaimLister = PersistentVolumeClaimInfo{}
|
||||||
|
|
||||||
// GetPersistentVolumeClaimInfo gets PVC matching the namespace and PVC ID.
|
// GetPersistentVolumeClaimInfo gets PVC matching the namespace and PVC ID.
|
||||||
func (pvcs PersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo(namespace string, pvcID string) (*v1.PersistentVolumeClaim, error) {
|
func (pvcs PersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo(namespace string, pvcID string) (*v1.PersistentVolumeClaim, error) {
|
||||||
for _, pvc := range pvcs {
|
for _, pvc := range pvcs {
|
||||||
@ -250,6 +254,23 @@ func (pvcs PersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo(namespace str
|
|||||||
return nil, fmt.Errorf("Unable to find persistent volume claim: %s/%s", namespace, pvcID)
|
return nil, fmt.Errorf("Unable to find persistent volume claim: %s/%s", namespace, pvcID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List gets PVC matching the namespace and PVC ID.
|
||||||
|
func (pvcs PersistentVolumeClaimInfo) List(selector labels.Selector) (ret []*v1.PersistentVolumeClaim, err error) {
|
||||||
|
return nil, fmt.Errorf("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// PersistentVolumeClaims returns a fake PersistentVolumeClaimLister object.
|
||||||
|
func (pvcs PersistentVolumeClaimInfo) PersistentVolumeClaims(namespace string) corelisters.PersistentVolumeClaimNamespaceLister {
|
||||||
|
ps := make([]*v1.PersistentVolumeClaim, len(pvcs))
|
||||||
|
for i := range pvcs {
|
||||||
|
ps[i] = &pvcs[i]
|
||||||
|
}
|
||||||
|
return &persistentVolumeClaimNamespaceLister{
|
||||||
|
pvcs: ps,
|
||||||
|
namespace: namespace,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NodeLister declares a *v1.Node type for testing.
|
// NodeLister declares a *v1.Node type for testing.
|
||||||
type NodeLister []*v1.Node
|
type NodeLister []*v1.Node
|
||||||
|
|
||||||
@ -263,6 +284,8 @@ func (nodes NodeLister) GetNodeInfo(nodeName string) (*v1.Node, error) {
|
|||||||
return nil, fmt.Errorf("Unable to find node: %s", nodeName)
|
return nil, fmt.Errorf("Unable to find node: %s", nodeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ v1beta1storagelisters.CSINodeLister = CSINodeInfo{}
|
||||||
|
|
||||||
// CSINodeInfo declares a storagev1beta1.CSINode type for testing.
|
// CSINodeInfo declares a storagev1beta1.CSINode type for testing.
|
||||||
type CSINodeInfo storagev1beta1.CSINode
|
type CSINodeInfo storagev1beta1.CSINode
|
||||||
|
|
||||||
@ -272,9 +295,22 @@ func (n CSINodeInfo) GetCSINodeInfo(name string) (*storagev1beta1.CSINode, error
|
|||||||
return &csiNode, nil
|
return &csiNode, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get returns a fake CSINode object.
|
||||||
|
func (n CSINodeInfo) Get(name string) (*storagev1beta1.CSINode, error) {
|
||||||
|
csiNode := storagev1beta1.CSINode(n)
|
||||||
|
return &csiNode, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists all CSINodes in the indexer.
|
||||||
|
func (n CSINodeInfo) List(selector labels.Selector) (ret []*storagev1beta1.CSINode, err error) {
|
||||||
|
return nil, fmt.Errorf("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
// PersistentVolumeInfo declares a []v1.PersistentVolume type for testing.
|
// PersistentVolumeInfo declares a []v1.PersistentVolume type for testing.
|
||||||
type PersistentVolumeInfo []v1.PersistentVolume
|
type PersistentVolumeInfo []v1.PersistentVolume
|
||||||
|
|
||||||
|
var _ corelisters.PersistentVolumeLister = PersistentVolumeInfo{}
|
||||||
|
|
||||||
// GetPersistentVolumeInfo returns a fake PV object in the fake PVs by PV ID.
|
// GetPersistentVolumeInfo returns a fake PV object in the fake PVs by PV ID.
|
||||||
func (pvs PersistentVolumeInfo) GetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error) {
|
func (pvs PersistentVolumeInfo) GetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error) {
|
||||||
for _, pv := range pvs {
|
for _, pv := range pvs {
|
||||||
@ -285,9 +321,26 @@ func (pvs PersistentVolumeInfo) GetPersistentVolumeInfo(pvID string) (*v1.Persis
|
|||||||
return nil, fmt.Errorf("Unable to find persistent volume: %s", pvID)
|
return nil, fmt.Errorf("Unable to find persistent volume: %s", pvID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get returns a fake PV object in the fake PVs by PV ID.
|
||||||
|
func (pvs PersistentVolumeInfo) Get(pvID string) (*v1.PersistentVolume, error) {
|
||||||
|
for _, pv := range pvs {
|
||||||
|
if pv.Name == pvID {
|
||||||
|
return &pv, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("Unable to find persistent volume: %s", pvID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists all PersistentVolumes in the indexer.
|
||||||
|
func (pvs PersistentVolumeInfo) List(selector labels.Selector) ([]*v1.PersistentVolume, error) {
|
||||||
|
return nil, fmt.Errorf("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
// StorageClassInfo declares a []storagev1.StorageClass type for testing.
|
// StorageClassInfo declares a []storagev1.StorageClass type for testing.
|
||||||
type StorageClassInfo []storagev1.StorageClass
|
type StorageClassInfo []storagev1.StorageClass
|
||||||
|
|
||||||
|
var _ storagelisters.StorageClassLister = StorageClassInfo{}
|
||||||
|
|
||||||
// GetStorageClassInfo returns a fake storage class object in the fake storage classes by name.
|
// GetStorageClassInfo returns a fake storage class object in the fake storage classes by name.
|
||||||
func (classes StorageClassInfo) GetStorageClassInfo(name string) (*storagev1.StorageClass, error) {
|
func (classes StorageClassInfo) GetStorageClassInfo(name string) (*storagev1.StorageClass, error) {
|
||||||
for _, sc := range classes {
|
for _, sc := range classes {
|
||||||
@ -297,3 +350,18 @@ func (classes StorageClassInfo) GetStorageClassInfo(name string) (*storagev1.Sto
|
|||||||
}
|
}
|
||||||
return nil, fmt.Errorf("Unable to find storage class: %s", name)
|
return nil, fmt.Errorf("Unable to find storage class: %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get returns a fake storage class object in the fake storage classes by name.
|
||||||
|
func (classes StorageClassInfo) Get(name string) (*storagev1.StorageClass, error) {
|
||||||
|
for _, sc := range classes {
|
||||||
|
if sc.Name == name {
|
||||||
|
return &sc, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("Unable to find storage class: %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists all StorageClass in the indexer.
|
||||||
|
func (classes StorageClassInfo) List(selector labels.Selector) ([]*storagev1.StorageClass, error) {
|
||||||
|
return nil, fmt.Errorf("not implemented")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user