-
Notifications
You must be signed in to change notification settings - Fork 268
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
Migrate controllers to v1beta1 #604
Migrate controllers to v1beta1 #604
Conversation
Change-Id: Ic4cc56f07e8ef5caa7b55ac02901a54708c35f20
Change-Id: I9a12e50eaa66c1897406b44e59f9e0813382645d
✅ Deploy Preview for kubernetes-sigs-kueue canceled.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alculquicondor 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 |
/hold cc @ahg-g |
03be22c
to
28aa2ee
Compare
/test pull-kueue-test-integration-main |
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.
Unbelievable effort, but hard to review :)
I think this could have been made easier to review if we introduced the changes to v1beta1 over different PRs (for example, first add v1beta1 as an exact copy of v1alpha2, then do the Workload Admission move, then the ResourceFlavor changes, then the ClusterQueue etc.), the wrappers refactoring could have also been introduced in a separate PR.
As for the logic itself, I wonder if we actually needed to make all those changes at once? maybe by copying the external type to the existing internal types we could have avoided doing all those changes in one go?
Regardless, since this doesn't intend to introduce new behavior, our only hope is that we have enough test coverage for validation :)
qKey := workload.QueueKey(wi.Obj) | ||
if _, ok := c.admittedWorkloadsPerQueue[qKey]; ok { | ||
c.admittedWorkloadsPerQueue[qKey] += int(m) | ||
} | ||
} | ||
|
||
func updateUsage(wi *workload.Info, usedResources ResourceQuantities, m int64) { | ||
func updateUsage(wi *workload.Info, cqUsage FlavorResourceQuantities, m int64) { |
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.
make this a member function of ClusterQueue since it updates the Usage of a CQ?
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.
No, because the snapshot also uses this function to update the usage of the cohort, not just the clusterQueue.
pkg/cache/cache.go
Outdated
} | ||
cqFlv, cqFlvExist := cqUsage[wlResFlv] | ||
if cqFlvExist && wlResExist { | ||
cqFlv[wlRes] += v * m |
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.
a similar check to the previous one is still applicable:
if _, exist := cqFlv[wlRes]; exist {
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.
reverted
v, ok := job.Labels[constants.QueueLabel] | ||
if ok { |
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.
v, ok := job.Labels[constants.QueueLabel] | |
if ok { | |
if v, ok := job.Labels[constants.QueueLabel]; ok { |
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.
Done
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and | |||
limitations under the License. | |||
*/ | |||
|
|||
package v1alpha2 | |||
package webhook |
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.
why did we move them?
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.
Maybe when there are conversion webhooks it'll make sense to the tests to the version, but for now it doesn't make much sense.
should we delete v1alpha2? it is orphaned now, right? |
Yeah, I was too far ahead with changes once I realized the PR was too big :( The wrapping changes was an attempt to make it easier for me to re-write the unit tests.
There are no internal types in CRDs. Only a "storage version", which is v1beta1 now.
Next PR |
we have internal types in the code itself, not sure how much we use the api types directly though in the core logic. |
/hold |
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.
Thank you for the great work!
Maybe for a follow up, we must update the samples:
https://github.com/kubernetes-sigs/kueue/tree/main/config/samples
@@ -210,7 +210,7 @@ clean-manifests = (cd config/components/manager && $(KUSTOMIZE) edit set image c | |||
|
|||
.PHONY: install | |||
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. | |||
$(KUSTOMIZE) build config/components/crd | kubectl apply -f - | |||
$(KUSTOMIZE) build config/components/crd | kubectl apply --server-side -f - |
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.
Maybe for a follow-up, we need to update docs as well.
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.
Yes, that's next step :)
} | ||
|
||
func queueName(job *batchv1.Job) string { | ||
if v, ok := job.Labels[constants.QueueLabel]; ok { | ||
return v | ||
} | ||
return job.Annotations[constants.QueueAnnotation] |
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.
Why take the queue name from annotations? For backward compatible?
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.
Yes
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.
Great :)
/hold cancel |
/hold |
Change-Id: If389945ad5833d8b869823afa1816772af22663c
2e9f12f
to
cfaf110
Compare
squashed in two commits |
/lgtm |
/lgtm |
What type of PR is this?
/kind feature
/kind api-change
What this PR does / why we need it:
Uses the v1beta1 API throughout the code base and changes the storage version.
The code is functionally the same, but there are some differences:
client.Status()
when admitting or evicting workloads.Makes use of APIs introduced in #532 (contained in the first two commits).
Which issue(s) this PR fixes:
Fixes #23
Special notes for your reviewer:
I heavily changed the testing wrappers in a attempt to make the test cases more slim.
The wrappers also add
coveredResources
automatically and panic if you define flavors with different resources.To be done if follow ups: