Prioritizing nodes based on volume capacity: unit tests

This commit is contained in:
Yecheng Fu
2021-03-02 10:25:35 +08:00
parent 21a43586e7
commit d791f7feef
5 changed files with 696 additions and 76 deletions

View File

@@ -87,20 +87,20 @@ func (b *BindingInfo) StorageClassName() string {
return b.pv.Spec.StorageClassName
}
// VolumeResource represents volume resource.
type VolumeResource struct {
// StorageResource represents storage resource.
type StorageResource struct {
Requested int64
Capacity int64
}
// VolumeResource returns volume resource.
func (b *BindingInfo) VolumeResource() *VolumeResource {
// StorageResource returns storage resource.
func (b *BindingInfo) StorageResource() *StorageResource {
// both fields are mandatory
requestedQty := b.pvc.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
capacitQty := b.pv.Spec.Capacity[v1.ResourceName(v1.ResourceStorage)]
return &VolumeResource{
capacityQty := b.pv.Spec.Capacity[v1.ResourceName(v1.ResourceStorage)]
return &StorageResource{
Requested: requestedQty.Value(),
Capacity: capacitQty.Value(),
Capacity: capacityQty.Value(),
}
}