Skip to content

TAS: filter irrelevant non-TAS pod updates - #10488

Merged
k8s-ci-robot merged 1 commit into
kubernetes-sigs:mainfrom
MatteoFari:fix/10269-non-tas-usage-reconciler
Apr 16, 2026
Merged

k8s-ci-robot merged 1 commit into
kubernetes-sigs:mainfrom
MatteoFari:fix/10269-non-tas-usage-reconciler

Conversation

@MatteoFari

@MatteoFari MatteoFari commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug
/area tas

What this PR does / why we need it:

Filters Pod updates that do not matter in NonTasUsageReconciler.

Before this change, the controller reconciled every update for scheduled non-TAS Pods. Now it only reconciles when a non-TAS Pod gets scheduled, moves to a different node, or finishes.

Which issue(s) this PR fixes:

Fixes #10269

Special notes for your reviewer:

Does this PR introduce a user-facing change?

TAS: reduce the churn on the TAS-enabled controller, called NonTasUsageReconciler, by skipping triggering
of the Reconcile on Pod changes which are irrelevant from the controller point-of-view.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. area/tas Topology-Aware Scheduling labels Apr 15, 2026
@netlify

netlify Bot commented Apr 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 74a0c89
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-kueue/deploys/69e07e58b2bf3f00088f3639

@k8s-ci-robot
k8s-ci-robot requested review from kannon92 and pajakd April 15, 2026 08:01
@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 Apr 15, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @MatteoFari. 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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.

Details

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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 15, 2026
@mimowo

mimowo commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

/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 Apr 15, 2026
Comment on lines +93 to +104
func shouldReconcilePodUpdate(oldPod, newPod *corev1.Pod) bool {
if !filterPod(newPod) {
return false
}
if oldPod.Spec.NodeName != newPod.Spec.NodeName {
return true
}
if !utilpod.IsTerminated(oldPod) && utilpod.IsTerminated(newPod) {
return true
}
return false
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this works well, so I can merge, but let me ask you an opinion about the alternative. I think the alternative will be easier to follow:

func belongsToNonTASCache(pod *corev1.Pod) bool {
	if utiltas.IsTAS(pod) {
		return false
	} else if len(pod.Spec.NodeName) == 0 {
		return false
	} else if util.IsTerminated(pod) {
        return false
    }
	return true
}

Then:

Create: return belongsToNonTASCache(newPod)
Update: return belongsToNonTASCache(oldPod) != belongsToNonTASCache(newPod)
Delete: return belongsToNonTASCache(oldPod)

So basically in this way the Create and Delete are just special cases for Update, because in case of Create we can assume belongsToNonTASCache(oldPod=nil) = false, and in case of Delete analogously belongsToNonTASCache(newPod=nil) = false, so the other needs to be true.

cc let me also cc @gabesaba who worked on the original impl.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the alternative is easier to follow too.

One thing I am a bit unsure about is the case where the Pod changes from belonging to the non-TAS cache to not belonging anymore, while the new Pod is still not terminated. Right now Reconcile always fetches the Pod and calls TASCache().Update(&pod, log), and that cache update does not enforce belongsToNonTASCache on its own.

So I think it is safe only if we also handle that case by deleting the Pod from the cache instead of updating it. Otherwise a transition like scheduled non-TAS -> scheduled TAS could still reconcile, but then add/update the new Pod in the cache instead of removing it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We had this discussion during the original implementation, and decided that we don't need to handle the non-TAS to TAS case: #8484 (comment)

@mimowo mimowo Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indeed, but "don't need to handle" does not imply "don't handle", and my attention back then wasn't focused on the corner case.

Now looking at this it seems support that only requires if belongsToNonTASCache() Update else DeletePodByKey() inside the Reconcile.

And at the expense of the single "if" we also express the intention better, so that the reader of the Reconcile function does not need to worry what is the transitioning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This sounds good to me. It mitigates cache corruption risk by explicitly handling all cases (even ones that require unexpected/adversarial user intervention)

@mimowo mimowo Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@MatteoFari let's update as per #10488 (comment) + the extra "if" in the Reconcile. Feel free to still keep ShouldReconcilePodUpdate as the wrapper for the transition detection check.

@mimowo

mimowo commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Signed-off-by: Matteo Fari <matteofari06@gmail.com>
@MatteoFari
MatteoFari force-pushed the fix/10269-non-tas-usage-reconciler branch from e921413 to 74a0c89 Compare April 16, 2026 06:14

@mimowo mimowo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you 👍
/lgtm
/approve
/cherrypick release-0.17
/cherrypick release-0.16

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 16, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: cf8fb320761cabbbec4826526b66389b67cef319

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MatteoFari, mimowo

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

The pull request process is described here

Details 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 Apr 16, 2026
@mimowo

mimowo commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

/release-note-edit

TAS: reduce the churn on the TAS-enabled controller, called NonTasUsageReconciler, by skipping triggering
of the Reconcile on Pod changes which are irrelevant from the controller point-of-view.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Apr 16, 2026
@k8s-ci-robot
k8s-ci-robot merged commit 6f79126 into kubernetes-sigs:main Apr 16, 2026
32 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.18 milestone Apr 16, 2026
@mimowo

mimowo commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

/cherrypick release-0.17
/cherrypick release-0.16

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown
Contributor

@mimowo: new pull request created: #10507

Details

In response to this:

/cherrypick release-0.17
/cherrypick release-0.16

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-infra-cherrypick-robot

Copy link
Copy Markdown
Contributor

@mimowo: new pull request created: #10508

Details

In response to this:

/cherrypick release-0.17
/cherrypick release-0.16

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.

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. area/tas Topology-Aware Scheduling cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Large heap retained by zap logger clones in reconcile loops (19K-pod cluster)

6 participants