Skip to content

[v0.14] Prevent false drift from null field rendering #4997

Merged
thardeck merged 2 commits into
rancher:release/v0.14from
p-se:issue-4969-0.14
Apr 17, 2026
Merged

[v0.14] Prevent false drift from null field rendering #4997
thardeck merged 2 commits into
rancher:release/v0.14from
p-se:issue-4969-0.14

Conversation

@p-se
Copy link
Copy Markdown
Contributor

@p-se p-se commented Apr 16, 2026

Cherry-pick from #4664

Refers to #4969

Additional Information

Checklist

  • I have updated the documentation via a pull request in the fleet-product-docs repository.

* Prevent false drift from Helm v4 null field rendering

Helm v4 can emit explicit null values for omitted fields (e.g.,
spec.strategy.rollingUpdate: null), while Helm v3 omitted these
fields entirely. When combined with Kubernetes server-side defaulting,
this creates false drift detection: the merge patch interprets null
as "delete this field," conflicting with defaulted live resources.

Solution:
- Add normalizeNullPatch to recursively strip null-valued fields from
  merge patches before drift comparison
- Handle nested structures (maps and arrays) to cover all potential
  Helm v4 null emissions beyond just deployment strategy

* Add fast-path optimization for null patch normalization in diff.go

Add bytes.Contains fast-path check before expensive unmarshal/walk/
marshal operations when patch doesn't contain 'null'. This provides
~55x performance improvement for patches without nulls:

- WithoutNulls: 127.9 ns/op (vs 7063 ns/op with nulls)
- 97% fewer allocations (1 vs 72 allocs/op)
- 97% less memory (176 B vs 5404 B per op)

Also add benchmark tests and fast-path test coverage.

(cherry picked from commit 7a7732f)

Refers to rancher#4969
@p-se p-se requested a review from a team as a code owner April 16, 2026 14:12
@kkaempf kkaempf added this to the v2.13.5 milestone Apr 16, 2026
@kkaempf kkaempf added this to Fleet Apr 16, 2026
@kkaempf kkaempf moved this to 👀 In review in Fleet Apr 16, 2026
@kkaempf
Copy link
Copy Markdown
Collaborator

kkaempf commented Apr 16, 2026

Why are we backporting a Helm v4 fix to Fleet 0.14 ? 🤔

@p-se
Copy link
Copy Markdown
Contributor Author

p-se commented Apr 16, 2026

Why are we backporting a Helm v4 fix to Fleet 0.14 ? 🤔

As it turned out, the cause is not Helm 4, but an issue that we have introduced and backported down to Fleet v0.11. But the changes are the right one to fix this issue anyway.

@kkaempf
Copy link
Copy Markdown
Collaborator

kkaempf commented Apr 16, 2026

Ok, then please adapt the title to reflect that.

@p-se p-se changed the title [v0.14] Prevent false drift from Helm v4 null field rendering [v0.14] Prevent false drift from null field rendering Apr 16, 2026
@thardeck thardeck merged commit fcd6873 into rancher:release/v0.14 Apr 17, 2026
35 of 37 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Fleet Apr 17, 2026
thardeck added a commit that referenced this pull request Apr 17, 2026
thardeck added a commit that referenced this pull request Apr 17, 2026
* Revert "[v0.14] Prevent false drift from null field rendering  (#4997)"

This reverts commit fcd6873.

* Revert "[v0.14] Remove k8s.io/kubernetes, use client-go scheme (#4902)"

This reverts commit 58f0054.

* Align k8s.io/kubernetes to v1.34.6 to match other k8s libraries

After reverting the k8s.io/kubernetes removal (PR #4902), bump
k8s.io/kubernetes from v1.34.5 to v1.34.6 and update all replace
directives to v0.34.6, matching the kubernetes dependencies that were
already at v0.34.6 on this branch (bumped in #4901).

Refs: #4969
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Grafana in modified state after installing via HelmOps in Fleet 0.14.5 and 0.13.10-beta.1

3 participants