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

WIP: reset admission check after deactivation #3350

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

KPostOffice
Copy link

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #3346

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE


@k8s-ci-robot
Copy link
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 28, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 28, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @KPostOffice!

It looks like this is your first PR to kubernetes-sigs/kueue 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kueue has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 28, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @KPostOffice. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 28, 2024
Copy link

netlify bot commented Oct 28, 2024

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 74a0fb3
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/672a9e6a9d67fd0008a8451c

@tenzen-y
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 28, 2024
@KPostOffice KPostOffice force-pushed the resetACOnWLDeactivation branch 2 times, most recently from 4db1187 to 6f7c974 Compare October 28, 2024 23:31
@mimowo
Copy link
Contributor

mimowo commented Oct 29, 2024

cc @PBundyra

@mimowo
Copy link
Contributor

mimowo commented Oct 31, 2024

@KPostOffice PTAL at the failures, maybe we could include as bugfix in 0.9.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: KPostOffice
Once this PR has been reviewed and has the lgtm label, please assign mimowo for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 4, 2024
@KPostOffice KPostOffice force-pushed the resetACOnWLDeactivation branch 2 times, most recently from dc8bc5a to a559886 Compare November 5, 2024 00:06
@mimowo
Copy link
Contributor

mimowo commented Nov 5, 2024

cc @PBundyra for a review pass. It seems the failing integration tests are for BookingExpired. PTAL.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a scenario for deactivated test, to observe transition from DeactivationTarget -> EvictedByDeactivation and resetting Workload's AdmissionChecks and RequeueState

checks[i] = kueue.AdmissionCheckState{
Name: checks[i].Name,
State: kueue.CheckStatePending,
LastTransitionTime: metav1.NewTime(time.Now()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use a clock used in WorkloadController?

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 5, 2024
@@ -204,6 +204,7 @@ func (r *WorkloadReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
wl.Status.RequeueState = nil
updated = true
}
updated = updated || workload.ResetChecksOnDeactivation(&wl)
Copy link
Contributor

Choose a reason for hiding this comment

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

swap the order: workload.ResetChecksOnDeactivation(&wl) || updated
otherwise ResetChecksOnDeactivation may not be called if updated is already true.

Copy link
Author

Choose a reason for hiding this comment

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

Ah, true. Thanks for catching 👍🏻

@k8s-ci-robot
Copy link
Contributor

@KPostOffice: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kueue-test-unit-main 74a0fb3 link true /test pull-kueue-test-unit-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Comment on lines +206 to 207
updated = workload.ResetChecksOnDeactivation(&wl) || updated
if updated {
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
updated = workload.ResetChecksOnDeactivation(&wl) || updated
if updated {
if workload.ResetChecksOnDeactivation(&wl, r.clock.Now()) || updated {

Comment on lines +30 to +33
var (
realClock = clock.RealClock{}
)

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
var (
realClock = clock.RealClock{}
)

I don’t think this will work well. We need to use the same clock as WorkloadReconciler, so we can replace it with FakeClock in tests.

Message: "Reset to Pending after eviction. Previously: " + string(checks[i].State),
}
}
}

func ResetChecksOnDeactivation(w *kueue.Workload) bool {
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
func ResetChecksOnDeactivation(w *kueue.Workload) bool {
func ResetChecksOnDeactivation(w *kueue.Workload, now time.Time) bool {

checks[i] = kueue.AdmissionCheckState{
Name: checks[i].Name,
State: kueue.CheckStatePending,
LastTransitionTime: metav1.NewTime(realClock.Now()),
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
LastTransitionTime: metav1.NewTime(realClock.Now()),
LastTransitionTime: metav1.NewTime(now),

Message: "Reset to Pending after eviction. Previously: " + string(checks[i].State),
}
}
}

func ResetChecksOnDeactivation(w *kueue.Workload) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need a new function for this, it is virtually the same as ResetChecksOnEviction, the only differences being time as a new arg and skipping of updating for Pending.

So, I would suggest to just update the existing function and reuse in this context. Deactivation is a special case of Eviction, so I think the name is also fine.

Copy link
Contributor

@PBundyra PBundyra Nov 6, 2024

Choose a reason for hiding this comment

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

Please adjust tests description according to your change

@@ -443,7 +435,7 @@ var _ = ginkgo.Describe("Provisioning", ginkgo.Ordered, ginkgo.ContinueOnFailure
gomega.Eventually(func(g gomega.Gomega) {
g.Expect(k8sClient.Get(ctx, wlKey, &updatedWl)).To(gomega.Succeed())
g.Expect(workload.IsEvictedByDeactivation(&updatedWl)).To(gomega.BeTrue())
util.ExpectEvictedWorkloadsTotalMetric(cq.Name, kueue.WorkloadEvictedByDeactivation, 1)
util.ExpectEvictedWorkloadsTotalMetric(cq.Name, kueue.WorkloadEvictedByDeactivation+kueue.WorkloadEvictedByAdmissionCheck, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the metric kueue.WorkloadEvictedByAdmissionCheck increased in this scenario?

@mimowo
Copy link
Contributor

mimowo commented Nov 6, 2024

cool to see all integration and e2e tests passing already 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

AdmissionChecks should be "reset" (set to pending) on workload deactivation
6 participants