Repository navigation
Watch only the step's own pod in the Kubernetes backend - #7600
Merged
xoxys merged 6 commits intoNov 25, 2026
Merged
Conversation
WaitStep and TailStep each start a pod informer for one pod, but the informer listed and watched every pod in the namespace. Each informer keeps its own cache, so the agent's memory grew with the number of steps waited on in parallel times the number of pods in the namespace, including large environment values such as CI_SCRIPT of unrelated pods. Select the step's pod with a metadata.name field selector, so the API server sends only that pod to each informer. The handlers already ignore every other pod, so behavior is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7600 +/- ##
==========================================
+ Coverage 66.87% 67.00% +0.13%
==========================================
Files 451 451
Lines 22646 22652 +6
==========================================
+ Hits 15145 15179 +34
+ Misses 7501 7473 -28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6543
reviewed
Nov 20, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
@xoxys this looks plausible but you know k8s better :) |
xoxys
approved these changes
Nov 25, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
WaitStepandTailStepeach create a pod informer to follow one pod, but the informer lists and watches every pod in the namespace. Each informer keeps its own cache, so the agent holds one copy of all the namespace's pods for every step it's waiting on or tailing. That includes large environment values of unrelated pods, likeCI_SCRIPTandCI_PIPELINE_FILES. With many parallel steps, the agent's memory grows with steps × pods and can exceed its limit.In a local replay on v3.19.0 that drove the real
TailStepwith 56 concurrent watchers over 61 pods, the informers retained 111 MiB of extra heap. With the field selector, it was 4.1 MiB.This adds a
metadata.namefield selector throughWithTweakListOptions, so the API server returns only the step's pod. The selector applies to the initial list, the watch, and streaming lists (sendInitialEvents). The event handlers already ignore every other pod, so behavior is unchanged.May help with #4228.
Tests:
TestStepInformersSelectOnlyTheirPodchecks that the list and watch requests from bothWaitStepandTailStepselect only the step's pod. It fails without the change.Note:
TestAffinityFromCliContextfails onmainwhen run with-count> 1. It's unrelated to this change, and passes in a normal single run.