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
ea4dcbab
Commit
ea4dcbab
authored
Jul 27, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(kube): reap related resources on delete
parent
bd5a9753
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
client.go
pkg/kube/client.go
+14
-5
No files found.
pkg/kube/client.go
View file @
ea4dcbab
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"k8s.io/kubernetes/pkg/kubectl"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
...
@@ -60,7 +61,19 @@ func (c *Client) Create(namespace string, reader io.Reader) error {
...
@@ -60,7 +61,19 @@ func (c *Client) Create(namespace string, reader io.Reader) error {
//
//
// Namespace will set the namespace
// Namespace will set the namespace
func
(
c
*
Client
)
Delete
(
namespace
string
,
reader
io
.
Reader
)
error
{
func
(
c
*
Client
)
Delete
(
namespace
string
,
reader
io
.
Reader
)
error
{
return
perform
(
c
,
namespace
,
reader
,
deleteResource
)
return
perform
(
c
,
namespace
,
reader
,
func
(
info
*
resource
.
Info
)
error
{
log
.
Printf
(
"Starting delete for %s"
,
info
.
Name
)
reaper
,
err
:=
c
.
Reaper
(
info
.
Mapping
)
if
err
!=
nil
{
// If there is no reaper for this resources, delete it.
if
kubectl
.
IsNoSuchReaperError
(
err
)
{
return
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Delete
(
info
.
Namespace
,
info
.
Name
)
}
return
err
}
log
.
Printf
(
"Using reaper for deleting %s"
,
info
.
Name
)
return
reaper
.
Stop
(
info
.
Namespace
,
info
.
Name
,
0
,
nil
)
})
}
}
// WatchUntilReady watches the resource given in the reader, and waits until it is ready.
// WatchUntilReady watches the resource given in the reader, and waits until it is ready.
...
@@ -123,10 +136,6 @@ func createResource(info *resource.Info) error {
...
@@ -123,10 +136,6 @@ func createResource(info *resource.Info) error {
return
err
return
err
}
}
func
deleteResource
(
info
*
resource
.
Info
)
error
{
return
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Delete
(
info
.
Namespace
,
info
.
Name
)
}
func
watchUntilReady
(
info
*
resource
.
Info
)
error
{
func
watchUntilReady
(
info
*
resource
.
Info
)
error
{
w
,
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
WatchSingle
(
info
.
Namespace
,
info
.
Name
,
info
.
ResourceVersion
)
w
,
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
WatchSingle
(
info
.
Namespace
,
info
.
Name
,
info
.
ResourceVersion
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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