Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2fa10f8a
Commit
2fa10f8a
authored
Sep 28, 2015
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete job when namespace is deleted
parent
f8a9943d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
namespace_controller.go
pkg/controller/namespace/namespace_controller.go
+18
-0
namespace_controller_test.go
pkg/controller/namespace/namespace_controller_test.go
+1
-0
No files found.
pkg/controller/namespace/namespace_controller.go
View file @
2fa10f8a
...
...
@@ -201,6 +201,10 @@ func deleteAllContent(kubeClient client.Interface, experimentalMode bool, namesp
if
err
!=
nil
{
return
estimate
,
err
}
err
=
deleteJobs
(
kubeClient
.
Experimental
(),
namespace
)
if
err
!=
nil
{
return
estimate
,
err
}
err
=
deleteDeployments
(
kubeClient
.
Experimental
(),
namespace
)
if
err
!=
nil
{
return
estimate
,
err
...
...
@@ -465,6 +469,20 @@ func deleteDaemonSets(expClient client.ExperimentalInterface, ns string) error {
return
nil
}
func
deleteJobs
(
expClient
client
.
ExperimentalInterface
,
ns
string
)
error
{
items
,
err
:=
expClient
.
Jobs
(
ns
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
if
err
!=
nil
{
return
err
}
for
i
:=
range
items
.
Items
{
err
:=
expClient
.
Jobs
(
ns
)
.
Delete
(
items
.
Items
[
i
]
.
Name
,
nil
)
if
err
!=
nil
&&
!
errors
.
IsNotFound
(
err
)
{
return
err
}
}
return
nil
}
func
deleteDeployments
(
expClient
client
.
ExperimentalInterface
,
ns
string
)
error
{
items
,
err
:=
expClient
.
Deployments
(
ns
)
.
List
(
labels
.
Everything
(),
fields
.
Everything
())
if
err
!=
nil
{
...
...
pkg/controller/namespace/namespace_controller_test.go
View file @
2fa10f8a
...
...
@@ -113,6 +113,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, experimentalMode bool) {
strings
.
Join
([]
string
{
"list"
,
"horizontalpodautoscalers"
,
""
},
"-"
),
strings
.
Join
([]
string
{
"list"
,
"daemonsets"
,
""
},
"-"
),
strings
.
Join
([]
string
{
"list"
,
"deployments"
,
""
},
"-"
),
strings
.
Join
([]
string
{
"list"
,
"jobs"
,
""
},
"-"
),
)
}
...
...
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