Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
🟡 Changes recommended
The no-op comparison still triggers UpdateRecord for managedFields-only updates because resourceVersion also changes, and the new test omits that real-world behavior.
1 open issue
What changed in this PR
Adds opt-in field stripping to the watcher so archived Tekton runs use less database space and send smaller payloads to the Results API.
Changes:
- Adds
--strip_fieldsconfiguration with startup validation that protects object identity fields. - Removes configured fields before record comparison and storage, preserving numeric precision.
- Adds parsing, stripping, and record-update tests, plus usage documentation.
| File | Description |
|---|---|
pkg/watcher/results/results.go |
Applies field stripping before record comparison and storage. |
pkg/watcher/results/results_test.go |
Tests stored field removal and unchanged-record behavior. |
pkg/watcher/reconciler/config.go |
Adds parsed field paths to watcher configuration. |
pkg/watcher/convert/strip.go |
Implements path validation and JSON field removal. |
pkg/watcher/convert/strip_test.go |
Tests parsing, protected fields, traversal, and numeric precision. |
docs/watcher/README.md |
Documents flag usage, defaults, and limitations. |
cmd/watcher/main.go |
Registers and validates the new watcher flag. |
Review effort: Balanced
| if data != nil && len(c.StripFields) > 0 { | ||
| // Strip before comparing with the stored data, so that a change | ||
| // limited to stripped fields does not cause an update. | ||
| if data.Value, err = convert.StripFields(data.Value, c.StripFields); err != nil { |
There was a problem hiding this comment.
Right, the resourceVersion bump makes it differ. I went with documenting that it has to be stripped too, and added a test for both cases, in 7c9e717.
Records store the whole run object, including fields such as metadata.managedFields that are rarely useful in the archive but take a lot of database space. The new strip_fields flag takes a comma-separated list of dot-separated field paths that the watcher removes from PipelineRuns, TaskRuns and CustomRuns before storing them. The fields are stripped before the comparison with the stored record, so a change limited to stripped fields does not trigger an update. Fields that identify the object cannot be stripped. The flag is empty by default, which keeps the current behavior. Fixes tektoncd#1368
…only updates Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
7c9e717 to
b463575
Compare
|
@enarha - Keeping this in the watcher saves network traffic, but records created directly through the Results API will not be filtered. Is watcher-only behavior the intended scope of this feature, or should field stripping be enforced consistently for all Record writers by the API server? |
|
Could the main documentation example include both |
|
How should users strip a specific annotation whose key contains dots, such as |
| } | ||
|
|
||
| func deletePath(obj map[string]any, path []string) { | ||
| for _, key := range path[:len(path)-1] { |
There was a problem hiding this comment.
Could StripFields safely ignore or reject empty paths? It is an exported function, and passing something like [][]string{{}} can cause deletePath to panic. A simple length check would make it safer.
There was a problem hiding this comment.
Good catch, empty paths are skipped now in 1843522, with a test.
Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
|
Updated the README example to strip resourceVersion together with managedFields. For annotation keys with dots you can now escape them with a backslash, like |

Changes
Fixes #1368
Adds an opt-in
--strip_fieldsflag to the watcher. It takes a comma-separated list of dot-separated paths, likemetadata.managedFields,status.provenance, and removes them from PipelineRuns, TaskRuns and CustomRuns before they're stored. It's the same idea as the managedFields trimming in tektoncd/pipeline#9316, but here it saves DB space.The stripping happens before the watcher compares the object with the stored record, so a change that only touches stripped fields (managedFields changes on every status update) doesn't cause an extra UpdateRecord. Paths only go through objects, not lists, and missing paths are ignored.
apiVersion,kind,metadata.name,metadata.namespaceandmetadata.uid, or a parent likemetadata, are rejected at startup since the record needs them. Numbers are decoded withUseNumber, so big integers keep their exact value.I put it in the watcher instead of the API server so the fields aren't sent over the wire either. Happy to move it if you'd rather have it server side.
Tests:
TestParseFieldPathsandTestStripFieldscover parsing, the protected fields, nested and missing paths, lists and large numbers.TestUpsertRecordStripFieldschecks that the stored record has no managedFields and that a managedFields-only change doesn't update it. Docs are indocs/watcher/README.md./kind feature
Submitter Checklist
Release Notes