func fitsFlavorLimits(name corev1.ResourceName, val int64, cq *cache.ClusterQueue, flavor *cache.FlavorInfo) (bool, int64) {
	used := cq.UsedResources[name][flavor.Name]
	if used+val > flavor.Ceiling {
		// Past borrowing limit.
		return false, 0
	}
	cohortUsed := used
	cohortTotal := flavor.Guaranteed
	if cq.Cohort != nil {
		cohortUsed = cq.Cohort.UsedResources[name][flavor.Name]
		cohortTotal = cq.Cohort.RequestableResources[name][flavor.Name]
	}
	borrow := used + val - flavor.Guaranteed
	if borrow < 0 {
		borrow = 0
	}
	if cohortUsed+val > cohortTotal {
		// Doesn't fit even with borrowing.
		// TODO(PostMVP): preemption could help if borrow == 0
		return false, 0
	}
	return true, borrow
}
// fitsFlavorLimits returns whether a requested resource fits in a specific flavor's quota limits.
// If it fits, also returns any borrowing required.
fitsFlavorLimits returns whether a requested resource fits in a specific flavor's quota limits.
If it fits, also returns any borrowing required.
// fitsFlavorLimits returns whether a requested resource fits in a specific flavor ' s quota limits . // If it fits also returns any borrowing required .
func fitsFlavorLimits(name corev1.ResourceName, val int64, cq *cache.ClusterQueue, flavor *cache.FlavorInfo) (bool, int64) {
	used := cq.UsedResources[name][flavor.Name]
	if used+val > flavor.Ceiling {
		return false, 0
	}
	cohortUsed := used
	cohortTotal := flavor.Guaranteed
	if cq.Cohort != nil {
		cohortUsed = cq.Cohort.UsedResources[name][flavor.Name]
		cohortTotal = cq.Cohort.RequestableResources[name][flavor.Name]
	}
	borrow := used + val - flavor.Guaranteed
	if borrow < 0 {
		borrow = 0
	}
	if cohortUsed+val > cohortTotal {
		return false, 0
	}
	return true, borrow
}
func fitsFlavorLimits ( name corev1 . ResourceName , val int64 , cq * cache . ClusterQueue , flavor * cache . FlavorInfo ) ( bool , int64 ) { used := cq . UsedResources [ name ] [ flavor . Name ] if used + val > flavor . Ceiling { return false , 0 } cohortUsed := used cohortTotal := flavor . Guaranteed if cq . Cohort != nil { cohortUsed = cq . Cohort . UsedResources [ name ] [ flavor . Name ] cohortTotal = cq . Cohort . RequestableResources [ name ] [ flavor . Name ] } borrow := used + val - flavor . Guaranteed if borrow < 0 { borrow = 0 } if cohortUsed + val > cohortTotal { return false , 0 } return true , borrow }
fitsFlavorLimits returns whether a requested resource fits in a specific flavor's quota limits.
fitsFlavorLimits returns whether a requested resource fits in a specific flavor ' s quota limits .
// Past borrowing limit. // Doesn't fit even with borrowing. // TODO(PostMVP): preemption could help if borrow == 0