Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
5a5a44ec
Commit
5a5a44ec
authored
Sep 28, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(*): add rollback to a release version
closes #1244
parent
becc1200
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
7 deletions
+58
-7
tiller.proto
_proto/hapi/services/tiller.proto
+2
-1
rollback.go
cmd/helm/rollback.go
+10
-3
rollback_test.go
cmd/helm/rollback_test.go
+6
-1
release_server.go
cmd/tiller/release_server.go
+11
-1
release_server_test.go
cmd/tiller/release_server_test.go
+21
-0
option.go
pkg/helm/option.go
+8
-1
tiller.pb.go
pkg/proto/hapi/services/tiller.pb.go
+0
-0
No files found.
_proto/hapi/services/tiller.proto
View file @
5a5a44ec
...
@@ -183,7 +183,6 @@ message UpdateReleaseRequest {
...
@@ -183,7 +183,6 @@ message UpdateReleaseRequest {
hapi.chart.Config
values
=
3
;
hapi.chart.Config
values
=
3
;
// dry_run, if true, will run through the release logic, but neither create
// dry_run, if true, will run through the release logic, but neither create
bool
dry_run
=
4
;
bool
dry_run
=
4
;
// DisableHooks causes the server to skip running any hooks for the upgrade.
// DisableHooks causes the server to skip running any hooks for the upgrade.
bool
disable_hooks
=
5
;
bool
disable_hooks
=
5
;
}
}
...
@@ -200,6 +199,8 @@ message RollbackReleaseRequest {
...
@@ -200,6 +199,8 @@ message RollbackReleaseRequest {
bool
dry_run
=
2
;
bool
dry_run
=
2
;
// DisableHooks causes the server to skip running any hooks for the rollback
// DisableHooks causes the server to skip running any hooks for the rollback
bool
disable_hooks
=
3
;
bool
disable_hooks
=
3
;
// Version is the version of the release to deploy.
int32
version
=
4
;
}
}
// RollbackReleaseResponse is the response to an update request.
// RollbackReleaseResponse is the response to an update request.
...
...
cmd/helm/rollback.go
View file @
5a5a44ec
...
@@ -26,12 +26,13 @@ import (
...
@@ -26,12 +26,13 @@ import (
)
)
const
rollbackDesc
=
`
const
rollbackDesc
=
`
This command rolls back a release to the previous
ver
sion.
This command rolls back a release to the previous
revi
sion.
The argument of the rollback command is the name of a release.
The argument of the rollback command is the name of a release.
`
`
type
rollbackCmd
struct
{
type
rollbackCmd
struct
{
name
string
name
string
version
int32
dryRun
bool
dryRun
bool
disableHooks
bool
disableHooks
bool
out
io
.
Writer
out
io
.
Writer
...
@@ -46,7 +47,7 @@ func newRollbackCmd(c helm.Interface, out io.Writer) *cobra.Command {
...
@@ -46,7 +47,7 @@ func newRollbackCmd(c helm.Interface, out io.Writer) *cobra.Command {
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"rollback [RELEASE]"
,
Use
:
"rollback [RELEASE]"
,
Short
:
"roll back a release to
the previous ver
sion"
,
Short
:
"roll back a release to
a previous revi
sion"
,
Long
:
rollbackDesc
,
Long
:
rollbackDesc
,
PersistentPreRunE
:
setupConnection
,
PersistentPreRunE
:
setupConnection
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
...
@@ -60,13 +61,19 @@ func newRollbackCmd(c helm.Interface, out io.Writer) *cobra.Command {
...
@@ -60,13 +61,19 @@ func newRollbackCmd(c helm.Interface, out io.Writer) *cobra.Command {
}
}
f
:=
cmd
.
Flags
()
f
:=
cmd
.
Flags
()
f
.
Int32Var
(
&
rollback
.
version
,
"revision"
,
0
,
"revision to deploy"
)
f
.
BoolVar
(
&
rollback
.
dryRun
,
"dry-run"
,
false
,
"simulate a rollback"
)
f
.
BoolVar
(
&
rollback
.
dryRun
,
"dry-run"
,
false
,
"simulate a rollback"
)
f
.
BoolVar
(
&
rollback
.
disableHooks
,
"no-hooks"
,
false
,
"prevent hooks from running during rollback"
)
f
.
BoolVar
(
&
rollback
.
disableHooks
,
"no-hooks"
,
false
,
"prevent hooks from running during rollback"
)
return
cmd
return
cmd
}
}
func
(
r
*
rollbackCmd
)
run
()
error
{
func
(
r
*
rollbackCmd
)
run
()
error
{
_
,
err
:=
r
.
client
.
RollbackRelease
(
r
.
name
,
helm
.
RollbackDryRun
(
r
.
dryRun
),
helm
.
RollbackDisableHooks
(
r
.
disableHooks
))
_
,
err
:=
r
.
client
.
RollbackRelease
(
r
.
name
,
helm
.
RollbackDryRun
(
r
.
dryRun
),
helm
.
RollbackDisableHooks
(
r
.
disableHooks
),
helm
.
RollbackVersion
(
r
.
version
),
)
if
err
!=
nil
{
if
err
!=
nil
{
return
prettyError
(
err
)
return
prettyError
(
err
)
}
}
...
...
cmd/helm/rollback_test.go
View file @
5a5a44ec
...
@@ -29,7 +29,12 @@ func TestRollbackCmd(t *testing.T) {
...
@@ -29,7 +29,12 @@ func TestRollbackCmd(t *testing.T) {
{
{
name
:
"rollback a release"
,
name
:
"rollback a release"
,
args
:
[]
string
{
"funny-honey"
},
args
:
[]
string
{
"funny-honey"
},
resp
:
nil
,
flags
:
[]
string
{
"revision"
,
"1"
},
expected
:
"Rollback was a success! Happy Helming!"
,
},
{
name
:
"rollback a release without version"
,
args
:
[]
string
{
"funny-honey"
},
expected
:
"Rollback was a success! Happy Helming!"
,
expected
:
"Rollback was a success! Happy Helming!"
,
},
},
}
}
...
...
cmd/tiller/release_server.go
View file @
5a5a44ec
...
@@ -461,7 +461,17 @@ func (s *releaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
...
@@ -461,7 +461,17 @@ func (s *releaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
previousRelease
,
err
:=
s
.
env
.
Releases
.
Get
(
req
.
Name
,
currentRelease
.
Version
-
1
)
v
:=
req
.
Version
if
v
==
0
{
v
=
currentRelease
.
Version
-
1
}
if
v
<
1
{
return
nil
,
nil
,
errors
.
New
(
"cannot rollback to version < 1"
)
}
log
.
Printf
(
"rolling back %s to version %d"
,
req
.
Name
,
v
)
previousRelease
,
err
:=
s
.
env
.
Releases
.
Get
(
req
.
Name
,
v
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
...
cmd/tiller/release_server_test.go
View file @
5a5a44ec
...
@@ -664,6 +664,27 @@ func TestRollbackReleaseNoHooks(t *testing.T) {
...
@@ -664,6 +664,27 @@ func TestRollbackReleaseNoHooks(t *testing.T) {
}
}
}
}
func
TestRollbackWithReleaseVersion
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
RollbackReleaseRequest
{
Name
:
rel
.
Name
,
DisableHooks
:
true
,
Version
:
1
,
}
_
,
err
:=
rs
.
RollbackRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed rollback: %s"
,
err
)
}
}
func
TestRollbackRelease
(
t
*
testing
.
T
)
{
func
TestRollbackRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rs
:=
rsFixture
()
...
...
pkg/helm/option.go
View file @
5a5a44ec
...
@@ -196,6 +196,13 @@ func RollbackDryRun(dry bool) RollbackOption {
...
@@ -196,6 +196,13 @@ func RollbackDryRun(dry bool) RollbackOption {
}
}
}
}
// RollbackVersion sets the version of the release to deploy.
func
RollbackVersion
(
ver
int32
)
RollbackOption
{
return
func
(
opts
*
options
)
{
opts
.
rollbackReq
.
Version
=
ver
}
}
// UpgradeDisableHooks will disable hooks for an upgrade operation.
// UpgradeDisableHooks will disable hooks for an upgrade operation.
func
UpgradeDisableHooks
(
disable
bool
)
UpdateOption
{
func
UpgradeDisableHooks
(
disable
bool
)
UpdateOption
{
return
func
(
opts
*
options
)
{
return
func
(
opts
*
options
)
{
...
@@ -333,7 +340,7 @@ func (o *options) rpcRollbackRelease(rlsName string, rlc rls.ReleaseServiceClien
...
@@ -333,7 +340,7 @@ func (o *options) rpcRollbackRelease(rlsName string, rlc rls.ReleaseServiceClien
o
.
rollbackReq
.
DryRun
=
o
.
dryRun
o
.
rollbackReq
.
DryRun
=
o
.
dryRun
o
.
rollbackReq
.
Name
=
rlsName
o
.
rollbackReq
.
Name
=
rlsName
return
rlc
.
RollbackRelease
(
context
.
TODO
(),
&
o
.
rollbackReq
)
return
rlc
.
RollbackRelease
(
NewContext
(),
&
o
.
rollbackReq
)
}
}
// Executes tiller.GetReleaseStatus RPC.
// Executes tiller.GetReleaseStatus RPC.
...
...
pkg/proto/hapi/services/tiller.pb.go
View file @
5a5a44ec
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment