feat(helm): add --reset-values flag to 'helm upgrade'

The --reset-values flag on upgrade instructs Tiller to reset the
upgraded release to the chart's built-in values.yaml, and ignore the
last install's overridden values.

Closes #1569
pull/1814/head
Matt Butcher 8 years ago
parent 6d6e88a86e
commit c32b2ddcdf
No known key found for this signature in database
GPG Key ID: DCD5F5E5EF32C345

@ -192,6 +192,8 @@ message UpdateReleaseRequest {
bool recreate = 6; bool recreate = 6;
// timeout specifies the max amount of time any kubernetes client command can run. // timeout specifies the max amount of time any kubernetes client command can run.
int64 timeout = 7; int64 timeout = 7;
// ResetValues will cause Tiller to ignore stored values, resetting to default values.
bool reset_values = 8;
} }
// UpdateReleaseResponse is the response to an update request. // UpdateReleaseResponse is the response to an update request.

@ -64,6 +64,7 @@ type upgradeCmd struct {
namespace string namespace string
version string version string
timeout int64 timeout int64
resetValues bool
} }
func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command { func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command {
@ -104,6 +105,7 @@ func newUpgradeCmd(client helm.Interface, out io.Writer) *cobra.Command {
f.StringVar(&upgrade.namespace, "namespace", "default", "namespace to install the release into (only used if --install is set)") f.StringVar(&upgrade.namespace, "namespace", "default", "namespace to install the release into (only used if --install is set)")
f.StringVar(&upgrade.version, "version", "", "specify the exact chart version to use. If this is not specified, the latest version is used") f.StringVar(&upgrade.version, "version", "", "specify the exact chart version to use. If this is not specified, the latest version is used")
f.Int64Var(&upgrade.timeout, "timeout", 300, "time in seconds to wait for any individual kubernetes operation (like Jobs for hooks)") f.Int64Var(&upgrade.timeout, "timeout", 300, "time in seconds to wait for any individual kubernetes operation (like Jobs for hooks)")
f.BoolVar(&upgrade.resetValues, "reset-values", false, "when upgrading, reset the values to the ones built into the chart")
f.MarkDeprecated("disable-hooks", "use --no-hooks instead") f.MarkDeprecated("disable-hooks", "use --no-hooks instead")
@ -156,7 +158,8 @@ func (u *upgradeCmd) run() error {
helm.UpgradeDryRun(u.dryRun), helm.UpgradeDryRun(u.dryRun),
helm.UpgradeRecreate(u.recreate), helm.UpgradeRecreate(u.recreate),
helm.UpgradeDisableHooks(u.disableHooks), helm.UpgradeDisableHooks(u.disableHooks),
helm.UpgradeTimeout(u.timeout)) helm.UpgradeTimeout(u.timeout),
helm.ResetValues(u.resetValues))
if err != nil { if err != nil {
return fmt.Errorf("UPGRADE FAILED: %v", prettyError(err)) return fmt.Errorf("UPGRADE FAILED: %v", prettyError(err))
} }

@ -93,6 +93,13 @@ func TestUpgradeCmd(t *testing.T) {
resp: releaseMock(&releaseOptions{name: "funny-bunny", version: 3, chart: ch2}), resp: releaseMock(&releaseOptions{name: "funny-bunny", version: 3, chart: ch2}),
expected: "Release \"funny-bunny\" has been upgraded. Happy Helming!\n", expected: "Release \"funny-bunny\" has been upgraded. Happy Helming!\n",
}, },
{
name: "upgrade a release with --reset-values",
args: []string{"funny-bunny", chartPath},
flags: []string{"--reset-values", "true"},
resp: releaseMock(&releaseOptions{name: "funny-bunny", version: 4, chart: ch2}),
expected: "Release \"funny-bunny\" has been upgraded. Happy Helming!\n",
},
{ {
name: "install a release with 'upgrade --install'", name: "install a release with 'upgrade --install'",
args: []string{"zany-bunny", chartPath}, args: []string{"zany-bunny", chartPath},

@ -134,6 +134,7 @@ func (h *Client) UpdateRelease(rlsName string, chstr string, opts ...UpdateOptio
req.Name = rlsName req.Name = rlsName
req.DisableHooks = h.opts.disableHooks req.DisableHooks = h.opts.disableHooks
req.Recreate = h.opts.recreate req.Recreate = h.opts.recreate
req.ResetValues = h.opts.resetValues
ctx := NewContext() ctx := NewContext()
if h.opts.before != nil { if h.opts.before != nil {

@ -64,6 +64,8 @@ type options struct {
before func(context.Context, proto.Message) error before func(context.Context, proto.Message) error
// release history options are applied directly to the get release history request // release history options are applied directly to the get release history request
histReq rls.GetHistoryRequest histReq rls.GetHistoryRequest
// resetValues instructs Tiller to reset values to their defaults.
resetValues bool
} }
// Host specifies the host address of the Tiller release server, (default = ":44134"). // Host specifies the host address of the Tiller release server, (default = ":44134").
@ -270,6 +272,12 @@ func UpgradeDryRun(dry bool) UpdateOption {
} }
} }
func ResetValues(reset bool) UpdateOption {
return func(opts *options) {
opts.resetValues = reset
}
}
// UpgradeRecreate will (if true) recreate pods after upgrade. // UpgradeRecreate will (if true) recreate pods after upgrade.
func UpgradeRecreate(recreate bool) UpdateOption { func UpgradeRecreate(recreate bool) UpdateOption {
return func(opts *options) { return func(opts *options) {

@ -250,6 +250,8 @@ type UpdateReleaseRequest struct {
Recreate bool `protobuf:"varint,6,opt,name=recreate" json:"recreate,omitempty"` Recreate bool `protobuf:"varint,6,opt,name=recreate" json:"recreate,omitempty"`
// timeout specifies the max amount of time any kubernetes client command can run. // timeout specifies the max amount of time any kubernetes client command can run.
Timeout int64 `protobuf:"varint,7,opt,name=timeout" json:"timeout,omitempty"` Timeout int64 `protobuf:"varint,7,opt,name=timeout" json:"timeout,omitempty"`
// ResetValues will cause Tiller to ignore stored values, resetting to default values.
ResetValues bool `protobuf:"varint,8,opt,name=reset_values,json=resetValues" json:"reset_values,omitempty"`
} }
func (m *UpdateReleaseRequest) Reset() { *m = UpdateReleaseRequest{} } func (m *UpdateReleaseRequest) Reset() { *m = UpdateReleaseRequest{} }
@ -892,72 +894,73 @@ var _ReleaseService_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("hapi/services/tiller.proto", fileDescriptor0) } func init() { proto.RegisterFile("hapi/services/tiller.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 1058 bytes of a gzipped FileDescriptorProto // 1075 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x57, 0xdd, 0x6e, 0xe3, 0xc4, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x57, 0xdd, 0x6e, 0xe3, 0x44,
0x17, 0xaf, 0xf3, 0xe1, 0x24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 0xb5, 0x53, 0x41, 0xc9, 0xc2, 0x5e, 0x13,
0xe4, 0xff, 0x6f, 0xbe, 0xf8, 0x37, 0x00, 0x00, 0xff, 0xff, 0xae, 0xe0, 0xb8, 0xc3, 0xb0, 0x0d, 0x94, 0xde, 0x35, 0xd6, 0x04, 0x95, 0xea, 0x11, 0xce, 0xd6, 0x33, 0xf8, 0xa5, 0xae, 0xf4, 0x6e,
0x00, 0x00, 0x4c, 0xfe, 0x17, 0xe8, 0xeb, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x83, 0x62, 0xce, 0x77, 0xd3,
0x0d, 0x00, 0x00,
} }

@ -323,11 +323,26 @@ func (s *ReleaseServer) performUpdate(originalRelease, updatedRelease *release.R
return res, nil return res, nil
} }
// reuseValues copies values from the current release to a new release if the new release does not have any values. // reuseValues copies values from the current release to a new release if the
// new release does not have any values.
// //
// If the request already has values, or if there are no values in the current release, this does nothing. // If the request already has values, or if there are no values in the current
// release, this does nothing.
//
// This is skipped if the req.ResetValues flag is set, in which case the
// request values are not altered.
func (s *ReleaseServer) reuseValues(req *services.UpdateReleaseRequest, current *release.Release) { func (s *ReleaseServer) reuseValues(req *services.UpdateReleaseRequest, current *release.Release) {
if (req.Values == nil || req.Values.Raw == "" || req.Values.Raw == "{}\n") && current.Config != nil && current.Config.Raw != "" && current.Config.Raw != "{}\n" { if req.ResetValues {
// If ResetValues is set, we comletely ignore current.Config.
log.Print("Reset values to the chart's original version.")
return
}
// If req.Values is empty, but current. config is not, copy current into the
// request.
if (req.Values == nil || req.Values.Raw == "" || req.Values.Raw == "{}\n") &&
current.Config != nil &&
current.Config.Raw != "" &&
current.Config.Raw != "{}\n" {
log.Printf("Copying values from %s (v%d) to new release.", current.Name, current.Version) log.Printf("Copying values from %s (v%d) to new release.", current.Name, current.Version)
req.Values = current.Config req.Values = current.Config
} }

@ -667,6 +667,32 @@ func TestUpdateRelease(t *testing.T) {
t.Errorf("Expected release version to be %v, got %v", 2, res.Release.Version) t.Errorf("Expected release version to be %v, got %v", 2, res.Release.Version)
} }
} }
func TestUpdateReleaseResetValues(t *testing.T) {
c := helm.NewContext()
rs := rsFixture()
rel := releaseStub()
rs.env.Releases.Create(rel)
req := &services.UpdateReleaseRequest{
Name: rel.Name,
Chart: &chart.Chart{
Metadata: &chart.Metadata{Name: "hello"},
Templates: []*chart.Template{
{Name: "templates/hello", Data: []byte("hello: world")},
{Name: "templates/hooks", Data: []byte(manifestWithUpgradeHooks)},
},
},
ResetValues: true,
}
res, err := rs.UpdateRelease(c, req)
if err != nil {
t.Fatalf("Failed updated: %s", err)
}
// This should have been unset. Config: &chart.Config{Raw: `name: value`},
if res.Release.Config != nil && res.Release.Config.Raw != "" {
t.Errorf("Expected chart config to be empty, got %q", res.Release.Config.Raw)
}
}
func TestUpdateReleaseFailure(t *testing.T) { func TestUpdateReleaseFailure(t *testing.T) {
c := helm.NewContext() c := helm.NewContext()

Loading…
Cancel
Save