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
a1898cbd
Commit
a1898cbd
authored
Aug 25, 2016
by
Michelle Noorali
Committed by
GitHub
Aug 25, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1099 from michelleN/upgrade-errors
ref(*): return resource update errors
parents
76defc62
c7bec344
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
21 deletions
+31
-21
upgrade.go
cmd/helm/upgrade.go
+1
-1
release_server.go
cmd/tiller/release_server.go
+1
-1
client.go
pkg/kube/client.go
+29
-19
No files found.
cmd/helm/upgrade.go
View file @
a1898cbd
...
...
@@ -125,7 +125,7 @@ func (u *upgradeCmd) run() error {
_
,
err
=
u
.
client
.
UpdateRelease
(
u
.
release
,
chartPath
,
helm
.
UpdateValueOverrides
(
rawVals
),
helm
.
UpgradeDryRun
(
u
.
dryRun
),
helm
.
UpgradeDisableHooks
(
u
.
disableHooks
))
if
err
!=
nil
{
return
prettyError
(
err
)
return
fmt
.
Errorf
(
"UPGRADE FAILED: %v"
,
prettyError
(
err
)
)
}
success
:=
u
.
release
+
" has been upgraded. Happy Helming!
\n
"
...
...
cmd/tiller/release_server.go
View file @
a1898cbd
...
...
@@ -224,7 +224,7 @@ func (s *releaseServer) performUpdate(originalRelease, updatedRelease *release.R
original
:=
bytes
.
NewBufferString
(
originalRelease
.
Manifest
)
modified
:=
bytes
.
NewBufferString
(
updatedRelease
.
Manifest
)
if
err
:=
kubeCli
.
Update
(
updatedRelease
.
Namespace
,
original
,
modified
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Update of %s failed: %s"
,
updatedRelease
.
Name
,
err
)
return
nil
,
err
}
// post-upgrade hooks
...
...
pkg/kube/client.go
View file @
a1898cbd
...
...
@@ -22,6 +22,7 @@ import (
"io"
"log"
"reflect"
"strings"
"time"
"k8s.io/kubernetes/pkg/api"
...
...
@@ -128,13 +129,13 @@ func (c *Client) Get(namespace string, reader io.Reader) (string, error) {
return
buf
.
String
(),
err
}
// Update reads in the current configuration and a
modified
configuration from io.reader
// Update reads in the current configuration and a
target
configuration from io.reader
// and creates resources that don't already exists, updates resources that have been modified
//
and deletes resources from the current configuration that are not present in th
e
//
modified
configuration
//
in the target configuration and deletes resources from the current configuration that ar
e
//
not present in the target
configuration
//
// Namespace will set the namespaces
func
(
c
*
Client
)
Update
(
namespace
string
,
currentReader
,
modified
Reader
io
.
Reader
)
error
{
func
(
c
*
Client
)
Update
(
namespace
string
,
currentReader
,
target
Reader
io
.
Reader
)
error
{
current
:=
c
.
NewBuilder
(
includeThirdPartyAPIs
)
.
ContinueOnError
()
.
NamespaceParam
(
namespace
)
.
...
...
@@ -143,11 +144,11 @@ func (c *Client) Update(namespace string, currentReader, modifiedReader io.Reade
Flatten
()
.
Do
()
modified
:=
c
.
NewBuilder
(
includeThirdPartyAPIs
)
.
target
:=
c
.
NewBuilder
(
includeThirdPartyAPIs
)
.
ContinueOnError
()
.
NamespaceParam
(
namespace
)
.
DefaultNamespace
()
.
Stream
(
modified
Reader
,
""
)
.
Stream
(
target
Reader
,
""
)
.
Flatten
()
.
Do
()
...
...
@@ -156,10 +157,11 @@ func (c *Client) Update(namespace string, currentReader, modifiedReader io.Reade
return
err
}
modifiedInfos
:=
[]
*
resource
.
Info
{}
targetInfos
:=
[]
*
resource
.
Info
{}
updateErrors
:=
[]
string
{}
modified
.
Visit
(
func
(
info
*
resource
.
Info
,
err
error
)
error
{
modifiedInfos
=
append
(
modified
Infos
,
info
)
err
=
target
.
Visit
(
func
(
info
*
resource
.
Info
,
err
error
)
error
{
targetInfos
=
append
(
target
Infos
,
info
)
if
err
!=
nil
{
return
err
}
...
...
@@ -188,15 +190,23 @@ func (c *Client) Update(namespace string, currentReader, modifiedReader io.Reade
if
err
:=
updateResource
(
info
,
currentObj
);
err
!=
nil
{
log
.
Printf
(
"error updating the resource %s:
\n\t
%v"
,
resourceName
,
err
)
return
err
updateErrors
=
append
(
updateErrors
,
err
.
Error
())
}
return
err
return
nil
})
deleteUnwantedResources
(
currentInfos
,
modifiedInfos
)
deleteUnwantedResources
(
currentInfos
,
targetInfos
)
if
err
!=
nil
{
return
err
}
else
if
len
(
updateErrors
)
!=
0
{
return
fmt
.
Errorf
(
strings
.
Join
(
updateErrors
,
" && "
))
}
return
nil
}
// Delete deletes kubernetes resources from an io.reader
...
...
@@ -282,7 +292,7 @@ func deleteResource(info *resource.Info) error {
return
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Delete
(
info
.
Namespace
,
info
.
Name
)
}
func
updateResource
(
modified
*
resource
.
Info
,
currentObj
runtime
.
Object
)
error
{
func
updateResource
(
target
*
resource
.
Info
,
currentObj
runtime
.
Object
)
error
{
encoder
:=
api
.
Codecs
.
LegacyCodec
(
registered
.
EnabledVersions
()
...
)
originalSerialization
,
err
:=
runtime
.
Encode
(
encoder
,
currentObj
)
...
...
@@ -290,7 +300,7 @@ func updateResource(modified *resource.Info, currentObj runtime.Object) error {
return
err
}
editedSerialization
,
err
:=
runtime
.
Encode
(
encoder
,
modified
.
Object
)
editedSerialization
,
err
:=
runtime
.
Encode
(
encoder
,
target
.
Object
)
if
err
!=
nil
{
return
err
}
...
...
@@ -306,7 +316,7 @@ func updateResource(modified *resource.Info, currentObj runtime.Object) error {
}
if
reflect
.
DeepEqual
(
originalJS
,
editedJS
)
{
return
fmt
.
Errorf
(
"Looks like there are no changes for %s"
,
modified
.
Name
)
return
fmt
.
Errorf
(
"Looks like there are no changes for %s"
,
target
.
Name
)
}
patch
,
err
:=
strategicpatch
.
CreateStrategicMergePatch
(
originalJS
,
editedJS
,
currentObj
)
...
...
@@ -315,8 +325,8 @@ func updateResource(modified *resource.Info, currentObj runtime.Object) error {
}
// send patch to server
helper
:=
resource
.
NewHelper
(
modified
.
Client
,
modified
.
Mapping
)
if
_
,
err
=
helper
.
Patch
(
modified
.
Namespace
,
modified
.
Name
,
api
.
StrategicMergePatchType
,
patch
);
err
!=
nil
{
helper
:=
resource
.
NewHelper
(
target
.
Client
,
target
.
Mapping
)
if
_
,
err
=
helper
.
Patch
(
target
.
Namespace
,
target
.
Name
,
api
.
StrategicMergePatchType
,
patch
);
err
!=
nil
{
return
err
}
...
...
@@ -401,10 +411,10 @@ func (c *Client) ensureNamespace(namespace string) error {
return
nil
}
func
deleteUnwantedResources
(
currentInfos
,
modified
Infos
[]
*
resource
.
Info
)
{
func
deleteUnwantedResources
(
currentInfos
,
target
Infos
[]
*
resource
.
Info
)
{
for
_
,
cInfo
:=
range
currentInfos
{
found
:=
false
for
_
,
m
:=
range
modified
Infos
{
for
_
,
m
:=
range
target
Infos
{
if
m
.
Name
==
cInfo
.
Name
{
found
=
true
}
...
...
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