Skip to content
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

Add FairSharing config to Cohort #4288

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

gabesaba
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

Add FairSharing to Cohort API. Update shared structure and respective documentation documentation which are used now by both Cohort and ClusterQueue.

Updating cache and scheduling logic to use this change will be done in subsequent PRs, to keep PR size managable.

Which issue(s) this PR fixes:

Part of #3759

Special notes for your reviewer:

No release note for this change, as we will do a single release note for the entire feature.

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. labels Feb 17, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 17, 2025
Copy link

netlify bot commented Feb 17, 2025

Deploy Preview for kubernetes-sigs-kueue ready!

Name Link
🔨 Latest commit 6c74150
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/67b4aae54f08140008c81aff
😎 Deploy Preview https://deploy-preview-4288--kubernetes-sigs-kueue.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@gabesaba gabesaba force-pushed the cohort_api_fair_sharing branch 2 times, most recently from 6fc9f4e to 23da91e Compare February 17, 2025 14:29
if c.Spec.FairSharing == nil {
c.Spec.FairSharing = &kueue.FairSharing{}
}
c.Spec.FairSharing.Weight = ptr.To(w)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
c.Spec.FairSharing.Weight = ptr.To(w)
c.Spec.FairSharing.Weight = &w

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, also for ClusterQueue.

@PBundyra
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 17, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 973952d7333724994df200d98cb0b3c3012bd58c

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, mostly lgtm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename this to fairsharing.go? Acutally, we use localqueue_type.go not local_queue_type.go.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe even better to fairsharing_types.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -60,6 +60,11 @@ type CohortSpec struct {
//+listType=atomic
//+kubebuilder:validation:MaxItems=16
ResourceGroups []kueuebeta.ResourceGroup `json:"resourceGroups,omitempty"`

// fairSharing defines the properties of the Cohort when
// participating in FairSharing. The values are only relevant
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// participating in FairSharing. The values are only relevant
// participating in FairSharing. The values are only relevant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 64 to 68
// fairSharing defines the properties of the Cohort when
// participating in FairSharing. The values are only relevant
// if FairSharing is enabled in the Kueue configuration.
FairSharing *kueuebeta.FairSharing `json:"fairSharing,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE

This matches to design proposal:

Weights will be added to ClusterQueueSpec and CohortSpec in the following optional struct:
```go
type struct FairSharing {
Weight *Quantity // Default is 1.
}
```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we can move almost cases to UTs to check fingrained rejected reason and improve tests duration.
For integration tests, we can just have one valid and one invalid case each for CRUD operation.
But that is out of the scope of this PR.

Would you mind working on that in a follow-up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember thinking about this when implementing Cohort webhook - the issue is that we are doing some validation using kubebuilder, which I don't think we can exercise during unit tests. Also in ClusterQueue; e.g.

// +kubebuilder:validation:XValidation:rule="!has(self.cohort) && has(self.resourceGroups) ? self.resourceGroups.all(rg, rg.flavors.all(f, f.resources.all(r, !has(r.borrowingLimit)))) : true", message="borrowingLimit must be nil when cohort is empty"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the CEL should be verified in integration testing. But for webhook cases, we can move those to UTs.
That would be useful to reduce long-running CI and testing.

@gabesaba gabesaba force-pushed the cohort_api_fair_sharing branch from 23da91e to 4b2237c Compare February 18, 2025 11:17
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 18, 2025
@PBundyra
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 18, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: c69d8cc6c1fa877dab7109978cc3177e201099db

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one nit

// fairSharing defines the properties of the Cohort when
// participating in FairSharing. The values are only relevant
// if FairSharing is enabled in the Kueue configuration.
FairSharing *kueuebeta.FairSharing `json:"fairSharing,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FairSharing *kueuebeta.FairSharing `json:"fairSharing,omitempty"`
// +optional
FairSharing *kueuebeta.FairSharing `json:"fairSharing,omitempty"`

Indeed, we forget to add +optional marker when we introduce fairSharing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Comment on lines -142 to 145
// fairSharing defines the properties of the ClusterQueue when participating in fair sharing.
// The values are only relevant if fair sharing is enabled in the Kueue configuration.
// fairSharing defines the properties of the ClusterQueue when
// participating in FairSharing. The values are only relevant
// if FairSharing is enabled in the Kueue configuration.
FairSharing *FairSharing `json:"fairSharing,omitempty"`
Copy link
Member

@tenzen-y tenzen-y Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you address +optional marker for CQ in a follow-up PR, and then cherry-pick that to release branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create pull request once this PR merges, so that I do not need to resolve conflict

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
/lgtm
/approve

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabesaba gabesaba force-pushed the cohort_api_fair_sharing branch from 4b2237c to 6c74150 Compare February 18, 2025 15:44
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 18, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 18, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 39af0a096975888e4db470d4f577be12b9b61709

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gabesaba, tenzen-y

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 18, 2025
@k8s-ci-robot k8s-ci-robot merged commit 8b4affc into kubernetes-sigs:main Feb 18, 2025
19 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.11 milestone Feb 18, 2025
@gabesaba gabesaba deleted the cohort_api_fair_sharing branch February 18, 2025 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants