Fix --take-ownership

If a resource exists in the cluster and is to be adopted by helm install
--take-ownership, it is left unchanged while helm reports the
installation to have succeeded.

This is due to CRs and CRDs being merged without three-way-merge, which
results in an empty patch.

By using a three-way-merge transparently when --take-ownership is used,
the helm behaves as expected without breaking previous behavior.

Fixes #30622

Signed-off-by: Patrick Seidensal <pseidensal@suse.com>
pull/30616/head
Patrick Seidensal 2 years ago committed by Andrea Tartaglia
parent d6d6fc01f7
commit f7f41ac71f
No known key found for this signature in database

@ -488,6 +488,14 @@ func TestUpdate(t *testing.T) {
}
}
func TestUpdate(t *testing.T) {
testUpdate(t, false)
}
func TestUpdateThreeWayMerge(t *testing.T) {
testUpdate(t, true)
}
func TestBuild(t *testing.T) {
tests := []struct {
name string

@ -125,6 +125,14 @@ func (f *FailingKubeClient) Update(r, modified kube.ResourceList, options ...kub
return f.PrintingKubeClient.Update(r, modified, options...)
}
// Update returns the configured error if set or prints
func (f *FailingKubeClient) UpdateThreeWayMerge(r, modified kube.ResourceList, ignoreMe bool) (*kube.Result, error) {
if f.UpdateError != nil {
return &kube.Result{}, f.UpdateError
}
return f.PrintingKubeClient.Update(r, modified, ignoreMe)
}
// Build returns the configured error if set or prints
func (f *FailingKubeClient) Build(r io.Reader, _ bool) (kube.ResourceList, error) {
if f.BuildError != nil {

@ -52,6 +52,13 @@ type Interface interface {
GetWaiter(ws WaitStrategy) (Waiter, error)
}
// InterfaceThreeWayMerge was introduced to avoid breaking backwards compatibility for Interface implementers.
//
// TODO Helm 4: Remove InterfaceThreeWayMerge and integrate its method(s) into the Interface.
type InterfaceThreeWayMerge interface {
UpdateThreeWayMerge(original, target ResourceList, force bool) (*Result, error)
}
// Waiter defines methods related to waiting for resource states.
type Waiter interface {
// Wait waits up to the given timeout for the specified resources to be ready.

Loading…
Cancel
Save