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
ce4ae51e
Commit
ce4ae51e
authored
Sep 06, 2016
by
Michelle Noorali
Committed by
GitHub
Sep 06, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1146 from michelleN/bug/1133-fix-delete
fix(kube): delete should skip resources not found
parents
60b41888
f062cff5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
7 deletions
+52
-7
client.go
pkg/kube/client.go
+14
-6
client_test.go
pkg/kube/client_test.go
+38
-1
No files found.
pkg/kube/client.go
View file @
ce4ae51e
...
...
@@ -215,25 +215,33 @@ func (c *Client) Update(namespace string, currentReader, targetReader io.Reader)
func
(
c
*
Client
)
Delete
(
namespace
string
,
reader
io
.
Reader
)
error
{
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
)
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Delete
(
info
.
Namespace
,
info
.
Name
)
return
skipIfNotFound
(
err
)
}
return
err
}
log
.
Printf
(
"Using reaper for deleting %s"
,
info
.
Name
)
err
=
reaper
.
Stop
(
info
.
Namespace
,
info
.
Name
,
0
,
nil
)
if
err
!=
nil
&&
errors
.
IsNotFound
(
err
)
{
log
.
Printf
(
"%v"
,
err
)
return
nil
}
return
err
return
skipIfNotFound
(
err
)
})
}
func
skipIfNotFound
(
err
error
)
error
{
if
err
!=
nil
&&
errors
.
IsNotFound
(
err
)
{
log
.
Printf
(
"%v"
,
err
)
return
nil
}
return
err
}
// WatchUntilReady watches the resource given in the reader, and waits until it is ready.
//
// This function is mainly for hook implementations. It watches for a resource to
...
...
pkg/kube/client_test.go
View file @
ce4ae51e
...
...
@@ -126,11 +126,48 @@ func TestReal(t *testing.T) {
t
.
Fatal
(
err
)
}
if
err
:=
New
(
nil
)
.
Delete
(
"test"
,
strings
.
NewReader
(
guestbookManifest
));
err
!=
nil
{
testSvcEndpointManifest
:=
testServiceManifest
+
"
\n
---
\n
"
+
testEndpointManifest
c
:=
New
(
nil
)
if
err
:=
c
.
Create
(
"test-delete"
,
strings
.
NewReader
(
testSvcEndpointManifest
));
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
c
.
Delete
(
"test-delete"
,
strings
.
NewReader
(
testEndpointManifest
));
err
!=
nil
{
t
.
Fatal
(
err
)
}
// ensures that delete does not fail if a resource is not found
if
err
:=
c
.
Delete
(
"test-delete"
,
strings
.
NewReader
(
testSvcEndpointManifest
));
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
const
testServiceManifest
=
`
kind: Service
apiVersion: v1
metadata:
name: my-service
spec:
selector:
app: myapp
ports:
- port: 80
protocol: TCP
targetPort: 9376
`
const
testEndpointManifest
=
`
kind: Endpoints
apiVersion: v1
metadata:
name: my-service
subsets:
- addresses:
- ip: "1.2.3.4"
ports:
- port: 9376
`
const
guestbookManifest
=
`
apiVersion: v1
kind: Service
...
...
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