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
5262e1e8
Commit
5262e1e8
authored
Oct 25, 2016
by
fibonacci1729
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(998): append to history on install --replace
parent
a34472d1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
11 deletions
+52
-11
release_server.go
cmd/tiller/release_server.go
+51
-10
release_server_test.go
cmd/tiller/release_server_test.go
+1
-1
No files found.
cmd/tiller/release_server.go
View file @
5262e1e8
...
...
@@ -213,13 +213,21 @@ func (s *releaseServer) GetReleaseStatus(c ctx.Context, req *services.GetRelease
}
var
rel
*
release
.
Release
var
err
error
if
req
.
Version
<=
0
{
if
rel
,
err
=
s
.
env
.
Releases
.
Deployed
(
req
.
Name
);
err
!=
nil
{
h
,
err
:=
s
.
env
.
Releases
.
History
(
req
.
Name
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"getting deployed release '%s': %s"
,
req
.
Name
,
err
)
}
if
len
(
h
)
<
1
{
return
nil
,
errMissingRelease
}
relutil
.
Reverse
(
h
,
relutil
.
SortByRevision
)
rel
=
h
[
0
]
}
else
{
var
err
error
if
rel
,
err
=
s
.
env
.
Releases
.
Get
(
req
.
Name
,
req
.
Version
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"getting release '%s' (v%d): %s"
,
req
.
Name
,
req
.
Version
,
err
)
}
...
...
@@ -502,7 +510,6 @@ func (s *releaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
return
nil
,
nil
,
err
}
// Store a new release object with previous release's configuration
// Store a new release object with previous release's configuration
target
:=
&
release
.
Release
{
Name
:
req
.
Name
,
...
...
@@ -536,9 +543,14 @@ func (s *releaseServer) uniqName(start string, reuse bool) (string, error) {
return
""
,
fmt
.
Errorf
(
"release name %q exceeds max length of %d"
,
start
,
releaseNameMaxLen
)
}
if
rel
,
err
:=
s
.
env
.
Releases
.
Get
(
start
,
1
);
err
==
driver
.
ErrReleaseNotFound
{
h
,
err
:=
s
.
env
.
Releases
.
History
(
start
)
if
err
!=
nil
||
len
(
h
)
<
1
{
return
start
,
nil
}
else
if
st
:=
rel
.
Info
.
Status
.
Code
;
reuse
&&
(
st
==
release
.
Status_DELETED
||
st
==
release
.
Status_FAILED
)
{
}
relutil
.
Reverse
(
h
,
relutil
.
SortByRevision
)
rel
:=
h
[
0
]
if
st
:=
rel
.
Info
.
Status
.
Code
;
reuse
&&
(
st
==
release
.
Status_DELETED
||
st
==
release
.
Status_FAILED
)
{
// Allowe re-use of names if the previous release is marked deleted.
log
.
Printf
(
"reusing name %q"
,
start
)
return
start
,
nil
...
...
@@ -737,22 +749,50 @@ func (s *releaseServer) performRelease(r *release.Release, req *services.Install
}
}
switch
h
,
err
:=
s
.
env
.
Releases
.
History
(
req
.
Name
);
{
// if this is a replace operation, append to the release history
case
req
.
ReuseName
&&
err
==
nil
&&
len
(
h
)
>=
1
:
// get latest release revision
relutil
.
Reverse
(
h
,
relutil
.
SortByRevision
)
// old release
old
:=
h
[
0
]
// update old release status
old
.
Info
.
Status
.
Code
=
release
.
Status_SUPERSEDED
s
.
recordRelease
(
old
,
true
)
// update new release with next revision number
// so as to append to the old release's history
r
.
Version
=
old
.
Version
+
1
if
err
:=
s
.
performKubeUpdate
(
old
,
r
);
err
!=
nil
{
log
.
Printf
(
"warning: Release replace %q failed: %s"
,
r
.
Name
,
err
)
old
.
Info
.
Status
.
Code
=
release
.
Status_SUPERSEDED
r
.
Info
.
Status
.
Code
=
release
.
Status_FAILED
s
.
recordRelease
(
old
,
true
)
s
.
recordRelease
(
r
,
false
)
return
res
,
err
}
default
:
// nothing to replace, create as normal
// regular manifests
kubeCli
:=
s
.
env
.
KubeClient
b
:=
bytes
.
NewBufferString
(
r
.
Manifest
)
if
err
:=
kubeCli
.
Create
(
r
.
Namespace
,
b
);
err
!=
nil
{
if
err
:=
s
.
env
.
KubeClient
.
Create
(
r
.
Namespace
,
b
);
err
!=
nil
{
log
.
Printf
(
"warning: Release %q failed: %s"
,
r
.
Name
,
err
)
r
.
Info
.
Status
.
Code
=
release
.
Status_FAILED
s
.
recordRelease
(
r
,
req
.
ReuseNam
e
)
s
.
recordRelease
(
r
,
fals
e
)
return
res
,
fmt
.
Errorf
(
"release %s failed: %s"
,
r
.
Name
,
err
)
}
}
// post-install hooks
if
!
req
.
DisableHooks
{
if
err
:=
s
.
execHook
(
r
.
Hooks
,
r
.
Name
,
r
.
Namespace
,
postInstall
);
err
!=
nil
{
log
.
Printf
(
"warning: Release %q failed post-install: %s"
,
r
.
Name
,
err
)
r
.
Info
.
Status
.
Code
=
release
.
Status_FAILED
s
.
recordRelease
(
r
,
req
.
ReuseNam
e
)
s
.
recordRelease
(
r
,
fals
e
)
return
res
,
err
}
}
...
...
@@ -765,7 +805,8 @@ func (s *releaseServer) performRelease(r *release.Release, req *services.Install
// One possible strategy would be to do a timed retry to see if we can get
// this stored in the future.
r
.
Info
.
Status
.
Code
=
release
.
Status_DEPLOYED
s
.
recordRelease
(
r
,
req
.
ReuseName
)
s
.
recordRelease
(
r
,
false
)
return
res
,
nil
}
...
...
cmd/tiller/release_server_test.go
View file @
5262e1e8
...
...
@@ -548,7 +548,7 @@ func TestInstallReleaseReuseName(t *testing.T) {
t
.
Errorf
(
"expected %q, got %q"
,
rel
.
Name
,
res
.
Release
.
Name
)
}
getreq
:=
&
services
.
GetReleaseStatusRequest
{
Name
:
rel
.
Name
,
Version
:
1
}
getreq
:=
&
services
.
GetReleaseStatusRequest
{
Name
:
rel
.
Name
,
Version
:
0
}
getres
,
err
:=
rs
.
GetReleaseStatus
(
c
,
getreq
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to retrieve release: %s"
,
err
)
...
...
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