generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define ClusterQueueSnapshot and CohortSnapshot types #2519
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package cache | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/resource" | ||
"k8s.io/apimachinery/pkg/labels" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
|
||
kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1" | ||
"sigs.k8s.io/kueue/pkg/metrics" | ||
"sigs.k8s.io/kueue/pkg/resources" | ||
"sigs.k8s.io/kueue/pkg/workload" | ||
) | ||
|
||
type ClusterQueueSnapshot struct { | ||
alculquicondor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Name string | ||
Cohort *CohortSnapshot | ||
ResourceGroups []ResourceGroup | ||
Usage resources.FlavorResourceQuantities | ||
Workloads map[string]*workload.Info | ||
WorkloadsNotReady sets.Set[string] | ||
NamespaceSelector labels.Selector | ||
Preemption kueue.ClusterQueuePreemption | ||
FairWeight resource.Quantity | ||
FlavorFungibility kueue.FlavorFungibility | ||
// Aggregates AdmissionChecks from both .spec.AdmissionChecks and .spec.AdmissionCheckStrategy | ||
// Sets hold ResourceFlavors to which an AdmissionCheck should apply. | ||
// In case its empty, it means an AdmissionCheck should apply to all ResourceFlavor | ||
AdmissionChecks map[string]sets.Set[kueue.ResourceFlavorReference] | ||
Status metrics.ClusterQueueStatus | ||
// GuaranteedQuota records how much resource quota the ClusterQueue reserved | ||
// when feature LendingLimit is enabled and flavor's lendingLimit is not nil. | ||
GuaranteedQuota resources.FlavorResourceQuantities | ||
// AllocatableResourceGeneration will be increased when some admitted workloads are | ||
// deleted, or the resource groups are changed. | ||
AllocatableResourceGeneration int64 | ||
|
||
// Lendable holds the total lendable quota for the resources of the ClusterQueue, independent of the flavor. | ||
Lendable map[corev1.ResourceName]int64 | ||
} | ||
|
||
// RGByResource returns the ResourceGroup which contains capacity | ||
// for the resource, or nil if the CQ doesn't provide this resource. | ||
func (c *ClusterQueueSnapshot) RGByResource(resource corev1.ResourceName) *ResourceGroup { | ||
for i := range c.ResourceGroups { | ||
if c.ResourceGroups[i].CoveredResources.Has(resource) { | ||
return &c.ResourceGroups[i] | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// The methods below implement several interfaces. See | ||
// dominantResourceShareNode, resourceGroupNode, and netQuotaNode. | ||
|
||
func (c *ClusterQueueSnapshot) hasCohort() bool { | ||
return c.Cohort != nil | ||
} | ||
func (c *ClusterQueueSnapshot) fairWeight() *resource.Quantity { | ||
return &c.FairWeight | ||
} | ||
func (c *ClusterQueueSnapshot) lendableResourcesInCohort() map[corev1.ResourceName]int64 { | ||
return c.Cohort.Lendable | ||
} | ||
|
||
func (c *ClusterQueueSnapshot) usageFor(fr resources.FlavorResource) int64 { | ||
return c.Usage.For(fr) | ||
} | ||
|
||
func (c *ClusterQueueSnapshot) resourceGroups() []ResourceGroup { | ||
return c.ResourceGroups | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all of the fields still needed in this struct?