Fix values being ignored when reusing values on upgrade

Signed-off-by: Karuppiah Natarajan <karuppiah7890@gmail.com>

Co-authored-by: Nandhagopal Ezhilmaran <nandhagr8@gmail.com>
pull/6134/head
Karuppiah Natarajan 5 years ago
parent 8f8d581149
commit 6d02079016
No known key found for this signature in database
GPG Key ID: C674A28337662A96

@ -300,7 +300,7 @@ func (u *Upgrade) upgradeRelease(current, target *release.Release) error {
// request values are not altered.
func (u *Upgrade) reuseValues(chart *chart.Chart, current *release.Release) error {
if u.ResetValues {
// If ResetValues is set, we comletely ignore current.Config.
// If ResetValues is set, we completely ignore current.Config.
u.cfg.Log("resetting values to the chart's original version")
return nil
}
@ -315,7 +315,7 @@ func (u *Upgrade) reuseValues(chart *chart.Chart, current *release.Release) erro
return errors.Wrap(err, "failed to rebuild old values")
}
u.rawValues = chartutil.CoalesceTables(current.Config, u.rawValues)
u.rawValues = chartutil.CoalesceTables(u.rawValues, current.Config)
chart.Values = oldVals

@ -107,3 +107,53 @@ func TestUpgradeRelease_Atomic(t *testing.T) {
is.Contains(err.Error(), "an error occurred while rolling back the release")
})
}
func TestUpgradeRelease_ReuseValues(t *testing.T) {
is := assert.New(t)
t.Run("reuse values should work with values", func(t *testing.T) {
upAction := upgradeAction(t)
existingValues := map[string]interface{}{
"name": "value",
"maxHeapSize": "128m",
"replicas": 2,
}
newValues := map[string]interface{}{
"name": "newValue",
"maxHeapSize": "512m",
"cpu": "12m",
}
expectedValues := map[string]interface{}{
"name": "newValue",
"maxHeapSize": "512m",
"cpu": "12m",
"replicas": 2,
}
rel := releaseStub()
rel.Name = "nuketown"
rel.Info.Status = release.StatusDeployed
rel.Config = existingValues
err := upAction.cfg.Releases.Create(rel)
is.NoError(err)
upAction.ReuseValues = true
// setting newValues and upgrading
upAction.rawValues = newValues
res, err := upAction.Run(rel.Name, buildChart())
is.NoError(err)
// Now make sure it is actually upgraded
updatedRes, err := upAction.cfg.Releases.Get(res.Name, 2)
is.NoError(err)
if updatedRes == nil {
is.Fail("Updated Release is nil")
return
}
is.Equal(release.StatusDeployed, updatedRes.Info.Status)
is.Equal(expectedValues, updatedRes.Config)
})
}

Loading…
Cancel
Save