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
02acaf12
Commit
02acaf12
authored
Dec 05, 2016
by
Matt Butcher
Committed by
GitHub
Dec 05, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1632 from technosophos/fix/1587-no-release-found
fix(tiller): fix spurious "no release found" errors.
parents
68ff4e7b
a5d96c27
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
18 deletions
+50
-18
storage.go
pkg/storage/storage.go
+13
-0
storage_test.go
pkg/storage/storage_test.go
+32
-0
release_server.go
pkg/tiller/release_server.go
+5
-18
No files found.
pkg/storage/storage.go
View file @
02acaf12
...
@@ -139,6 +139,19 @@ func (s *Storage) History(name string) ([]*rspb.Release, error) {
...
@@ -139,6 +139,19 @@ func (s *Storage) History(name string) ([]*rspb.Release, error) {
return
l
,
nil
return
l
,
nil
}
}
func
(
s
*
Storage
)
Last
(
name
string
)
(
*
rspb
.
Release
,
error
)
{
h
,
err
:=
s
.
History
(
name
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
h
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"no revision for release %q"
,
name
)
}
relutil
.
Reverse
(
h
,
relutil
.
SortByRevision
)
return
h
[
0
],
nil
}
// makeKey concatenates a release name and version into
// makeKey concatenates a release name and version into
// a string with format ```<release_name>#v<version>```.
// a string with format ```<release_name>#v<version>```.
// This key is used to uniquely identify storage objects.
// This key is used to uniquely identify storage objects.
...
...
pkg/storage/storage_test.go
View file @
02acaf12
...
@@ -217,6 +217,38 @@ func TestStorageHistory(t *testing.T) {
...
@@ -217,6 +217,38 @@ func TestStorageHistory(t *testing.T) {
}
}
}
}
func
TestStorageLast
(
t
*
testing
.
T
)
{
storage
:=
Init
(
driver
.
NewMemory
())
const
name
=
"angry-bird"
// setup storage with test releases
setup
:=
func
()
{
// release records
rls0
:=
ReleaseTestData
{
Name
:
name
,
Version
:
1
,
Status
:
rspb
.
Status_SUPERSEDED
}
.
ToRelease
()
rls1
:=
ReleaseTestData
{
Name
:
name
,
Version
:
2
,
Status
:
rspb
.
Status_SUPERSEDED
}
.
ToRelease
()
rls2
:=
ReleaseTestData
{
Name
:
name
,
Version
:
3
,
Status
:
rspb
.
Status_SUPERSEDED
}
.
ToRelease
()
rls3
:=
ReleaseTestData
{
Name
:
name
,
Version
:
4
,
Status
:
rspb
.
Status_FAILED
}
.
ToRelease
()
// create the release records in the storage
assertErrNil
(
t
.
Fatal
,
storage
.
Create
(
rls0
),
"Storing release 'angry-bird' (v1)"
)
assertErrNil
(
t
.
Fatal
,
storage
.
Create
(
rls1
),
"Storing release 'angry-bird' (v2)"
)
assertErrNil
(
t
.
Fatal
,
storage
.
Create
(
rls2
),
"Storing release 'angry-bird' (v3)"
)
assertErrNil
(
t
.
Fatal
,
storage
.
Create
(
rls3
),
"Storing release 'angry-bird' (v4)"
)
}
setup
()
h
,
err
:=
storage
.
Last
(
name
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to query for release history (%q): %s
\n
"
,
name
,
err
)
}
if
h
.
Version
!=
4
{
t
.
Errorf
(
"Expected revision 4, got %d"
,
h
.
Version
)
}
}
type
ReleaseTestData
struct
{
type
ReleaseTestData
struct
{
Name
string
Name
string
Version
int32
Version
int32
...
...
pkg/tiller/release_server.go
View file @
02acaf12
...
@@ -241,17 +241,11 @@ func (s *ReleaseServer) GetReleaseStatus(c ctx.Context, req *services.GetRelease
...
@@ -241,17 +241,11 @@ func (s *ReleaseServer) GetReleaseStatus(c ctx.Context, req *services.GetRelease
var
rel
*
release
.
Release
var
rel
*
release
.
Release
if
req
.
Version
<=
0
{
if
req
.
Version
<=
0
{
h
,
err
:=
s
.
env
.
Releases
.
History
(
req
.
Name
)
var
err
error
rel
,
err
=
s
.
env
.
Releases
.
Last
(
req
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"getting deployed release '%s': %s"
,
req
.
Name
,
err
)
return
nil
,
fmt
.
Errorf
(
"getting deployed release %q: %s"
,
req
.
Name
,
err
)
}
if
len
(
h
)
<
1
{
return
nil
,
errMissingRelease
}
}
relutil
.
Reverse
(
h
,
relutil
.
SortByRevision
)
rel
=
h
[
0
]
}
else
{
}
else
{
var
err
error
var
err
error
if
rel
,
err
=
s
.
env
.
Releases
.
Get
(
req
.
Name
,
req
.
Version
);
err
!=
nil
{
if
rel
,
err
=
s
.
env
.
Releases
.
Get
(
req
.
Name
,
req
.
Version
);
err
!=
nil
{
...
@@ -388,7 +382,7 @@ func (s *ReleaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*rele
...
@@ -388,7 +382,7 @@ func (s *ReleaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*rele
}
}
// finds the non-deleted release with the given name
// finds the non-deleted release with the given name
currentRelease
,
err
:=
s
.
env
.
Releases
.
Deployed
(
req
.
Name
)
currentRelease
,
err
:=
s
.
env
.
Releases
.
Last
(
req
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
@@ -516,17 +510,10 @@ func (s *ReleaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
...
@@ -516,17 +510,10 @@ func (s *ReleaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
return
nil
,
nil
,
errInvalidRevision
return
nil
,
nil
,
errInvalidRevision
}
}
// finds the non-deleted release with the given name
crls
,
err
:=
s
.
env
.
Releases
.
Last
(
req
.
Name
)
h
,
err
:=
s
.
env
.
Releases
.
History
(
req
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
if
len
(
h
)
<=
1
{
return
nil
,
nil
,
errors
.
New
(
"no revision to rollback"
)
}
relutil
.
SortByRevision
(
h
)
crls
:=
h
[
len
(
h
)
-
1
]
rbv
:=
req
.
Version
rbv
:=
req
.
Version
if
req
.
Version
==
0
{
if
req
.
Version
==
0
{
...
...
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