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
bf7106f6
Unverified
Commit
bf7106f6
authored
Mar 19, 2019
by
Fernando Barbosa
Committed by
Timofey Kirillov
Mar 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cleanup on fail after wait
Signed-off-by:
Timofey Kirillov
<
timofey.kirillov@flant.com
>
parent
5ffe4ce5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
client.go
pkg/kube/client.go
+23
-14
No files found.
pkg/kube/client.go
View file @
bf7106f6
...
@@ -35,7 +35,7 @@ import (
...
@@ -35,7 +35,7 @@ import (
appsv1beta1
"k8s.io/api/apps/v1beta1"
appsv1beta1
"k8s.io/api/apps/v1beta1"
appsv1beta2
"k8s.io/api/apps/v1beta2"
appsv1beta2
"k8s.io/api/apps/v1beta2"
batch
"k8s.io/api/batch/v1"
batch
"k8s.io/api/batch/v1"
"k8s.io/api/core/v1"
v1
"k8s.io/api/core/v1"
extv1beta1
"k8s.io/api/extensions/v1beta1"
extv1beta1
"k8s.io/api/extensions/v1beta1"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
...
@@ -370,18 +370,8 @@ func (c *Client) UpdateWithOptions(namespace string, originalReader, targetReade
...
@@ -370,18 +370,8 @@ func (c *Client) UpdateWithOptions(namespace string, originalReader, targetReade
cleanupErrors
:=
[]
string
{}
cleanupErrors
:=
[]
string
{}
if
opts
.
CleanupOnFail
{
if
opts
.
CleanupOnFail
&&
(
err
!=
nil
||
len
(
updateErrors
)
!=
0
)
{
if
err
!=
nil
||
len
(
updateErrors
)
!=
0
{
cleanupErrors
=
c
.
cleanup
(
newlyCreatedResources
)
for
_
,
info
:=
range
newlyCreatedResources
{
kind
:=
info
.
Mapping
.
GroupVersionKind
.
Kind
c
.
Log
(
"Deleting newly created %s with the name %q in %s..."
,
kind
,
info
.
Name
,
info
.
Namespace
)
if
err
:=
deleteResource
(
info
);
err
!=
nil
{
c
.
Log
(
"Error deleting newly created %s with the name %q in %s: %s"
,
kind
,
info
.
Name
,
info
.
Namespace
,
err
)
cleanupErrors
=
append
(
cleanupErrors
,
err
.
Error
())
}
}
}
}
}
switch
{
switch
{
...
@@ -412,11 +402,30 @@ func (c *Client) UpdateWithOptions(namespace string, originalReader, targetReade
...
@@ -412,11 +402,30 @@ func (c *Client) UpdateWithOptions(namespace string, originalReader, targetReade
}
}
}
}
if
opts
.
ShouldWait
{
if
opts
.
ShouldWait
{
return
c
.
waitForResources
(
time
.
Duration
(
opts
.
Timeout
)
*
time
.
Second
,
target
)
err
:=
c
.
waitForResources
(
time
.
Duration
(
opts
.
Timeout
)
*
time
.
Second
,
target
)
if
opts
.
CleanupOnFail
&&
err
!=
nil
{
cleanupErrors
=
c
.
cleanup
(
newlyCreatedResources
)
return
fmt
.
Errorf
(
strings
.
Join
(
append
([]
string
{
err
.
Error
()},
cleanupErrors
...
),
" && "
))
}
return
err
}
}
return
nil
return
nil
}
}
func
(
c
*
Client
)
cleanup
(
newlyCreatedResources
[]
*
resource
.
Info
)
(
cleanupErrors
[]
string
)
{
for
_
,
info
:=
range
newlyCreatedResources
{
kind
:=
info
.
Mapping
.
GroupVersionKind
.
Kind
c
.
Log
(
"Deleting newly created %s with the name %q in %s..."
,
kind
,
info
.
Name
,
info
.
Namespace
)
if
err
:=
deleteResource
(
info
);
err
!=
nil
{
c
.
Log
(
"Error deleting newly created %s with the name %q in %s: %s"
,
kind
,
info
.
Name
,
info
.
Namespace
,
err
)
cleanupErrors
=
append
(
cleanupErrors
,
err
.
Error
())
}
}
return
}
// Delete deletes Kubernetes resources from an io.reader.
// Delete deletes Kubernetes resources from an io.reader.
//
//
// Namespace will set the namespace.
// Namespace will set the namespace.
...
...
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