File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,14 @@ func (r ResourceList) Intersect(rs ResourceList) ResourceList {
7979 return r .Filter (rs .Contains )
8080}
8181
82- // isMatchingInfo returns true if infos match on Name and GroupVersionKind.
82+ // isMatchingInfo returns true if infos match on Name, Namespace, Group and Kind.
83+ //
84+ // IMPORTANT: Version is intentionally excluded from the comparison. Resources
85+ // served by the same CRD at different API versions (e.g. v2beta1 vs v2beta2)
86+ // share the same underlying storage in the Kubernetes API server. Comparing
87+ // the full GroupVersionKind causes Difference() to treat a version change as
88+ // a resource removal + addition, which makes Helm delete the resource it just
89+ // created during upgrades. See https://github.com/helm/helm/issues/31768
8390func isMatchingInfo (a , b * resource.Info ) bool {
84- return a .Name == b .Name && a .Namespace == b .Namespace && a .Mapping .GroupVersionKind == b .Mapping .GroupVersionKind
91+ return a .Name == b .Name && a .Namespace == b .Namespace && a .Mapping .GroupVersionKind . GroupKind () == b .Mapping .GroupVersionKind . GroupKind ()
8592}
Original file line number Diff line number Diff line change @@ -72,8 +72,8 @@ func TestIsMatchingInfo(t *testing.T) {
7272
7373 gvkDiffVersion := schema.GroupVersionKind {Group : "group1" , Version : "diff" , Kind : "pod" }
7474 resourceInfoDiffVersion := resource.Info {Name : "name1" , Namespace : "namespace1" , Mapping : & meta.RESTMapping {GroupVersionKind : gvkDiffVersion }}
75- if isMatchingInfo (& resourceInfo , & resourceInfoDiffVersion ) {
76- t .Error ("expected resources not equal" )
75+ if ! isMatchingInfo (& resourceInfo , & resourceInfoDiffVersion ) {
76+ t .Error ("expected resources with different versions but same group and kind to be equal" )
7777 }
7878
7979 gvkDiffKind := schema.GroupVersionKind {Group : "group1" , Version : "version1" , Kind : "deployment" }
You can’t perform that action at this time.
0 commit comments