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
340e8b18
Commit
340e8b18
authored
Jun 01, 2017
by
nikhiljindal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deleting ServiceReaper
parent
43dcf0f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
52 deletions
+14
-52
stop.go
pkg/kubectl/stop.go
+0
-17
stop_test.go
pkg/kubectl/stop_test.go
+14
-35
No files found.
pkg/kubectl/stop.go
View file @
340e8b18
...
@@ -82,9 +82,6 @@ func ReaperFor(kind schema.GroupKind, c internalclientset.Interface) (Reaper, er
...
@@ -82,9 +82,6 @@ func ReaperFor(kind schema.GroupKind, c internalclientset.Interface) (Reaper, er
case
api
.
Kind
(
"Pod"
)
:
case
api
.
Kind
(
"Pod"
)
:
return
&
PodReaper
{
c
.
Core
()},
nil
return
&
PodReaper
{
c
.
Core
()},
nil
case
api
.
Kind
(
"Service"
)
:
return
&
ServiceReaper
{
c
.
Core
()},
nil
case
batch
.
Kind
(
"Job"
)
:
case
batch
.
Kind
(
"Job"
)
:
return
&
JobReaper
{
c
.
Batch
(),
c
.
Core
(),
Interval
,
Timeout
},
nil
return
&
JobReaper
{
c
.
Batch
(),
c
.
Core
(),
Interval
,
Timeout
},
nil
...
@@ -127,9 +124,6 @@ type DeploymentReaper struct {
...
@@ -127,9 +124,6 @@ type DeploymentReaper struct {
type
PodReaper
struct
{
type
PodReaper
struct
{
client
coreclient
.
PodsGetter
client
coreclient
.
PodsGetter
}
}
type
ServiceReaper
struct
{
client
coreclient
.
ServicesGetter
}
type
StatefulSetReaper
struct
{
type
StatefulSetReaper
struct
{
client
appsclient
.
StatefulSetsGetter
client
appsclient
.
StatefulSetsGetter
podClient
coreclient
.
PodsGetter
podClient
coreclient
.
PodsGetter
...
@@ -522,14 +516,3 @@ func (reaper *PodReaper) Stop(namespace, name string, timeout time.Duration, gra
...
@@ -522,14 +516,3 @@ func (reaper *PodReaper) Stop(namespace, name string, timeout time.Duration, gra
}
}
return
pods
.
Delete
(
name
,
gracePeriod
)
return
pods
.
Delete
(
name
,
gracePeriod
)
}
}
func
(
reaper
*
ServiceReaper
)
Stop
(
namespace
,
name
string
,
timeout
time
.
Duration
,
gracePeriod
*
metav1
.
DeleteOptions
)
error
{
services
:=
reaper
.
client
.
Services
(
namespace
)
_
,
err
:=
services
.
Get
(
name
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
err
}
falseVar
:=
false
deleteOptions
:=
&
metav1
.
DeleteOptions
{
OrphanDependents
:
&
falseVar
}
return
services
.
Delete
(
name
,
deleteOptions
)
}
pkg/kubectl/stop_test.go
View file @
340e8b18
...
@@ -558,26 +558,26 @@ func (c *noSuchPod) Get(name string, options metav1.GetOptions) (*api.Pod, error
...
@@ -558,26 +558,26 @@ func (c *noSuchPod) Get(name string, options metav1.GetOptions) (*api.Pod, error
return
nil
,
fmt
.
Errorf
(
"%s does not exist"
,
name
)
return
nil
,
fmt
.
Errorf
(
"%s does not exist"
,
name
)
}
}
type
noDelete
Service
struct
{
type
noDelete
Pod
struct
{
coreclient
.
Service
Interface
coreclient
.
Pod
Interface
}
}
func
(
c
*
noDelete
Service
)
Delete
(
servic
e
string
,
o
*
metav1
.
DeleteOptions
)
error
{
func
(
c
*
noDelete
Pod
)
Delete
(
nam
e
string
,
o
*
metav1
.
DeleteOptions
)
error
{
return
fmt
.
Errorf
(
"I'm afraid I can't do that, Dave"
)
return
fmt
.
Errorf
(
"I'm afraid I can't do that, Dave"
)
}
}
type
reaperFake
struct
{
type
reaperFake
struct
{
*
fake
.
Clientset
*
fake
.
Clientset
noSuchPod
,
noDelete
Service
bool
noSuchPod
,
noDelete
Pod
bool
}
}
func
(
c
*
reaperFake
)
Core
()
coreclient
.
CoreInterface
{
func
(
c
*
reaperFake
)
Core
()
coreclient
.
CoreInterface
{
return
&
reaperCoreFake
{
c
.
Clientset
.
Core
(),
c
.
noSuchPod
,
c
.
noDelete
Service
}
return
&
reaperCoreFake
{
c
.
Clientset
.
Core
(),
c
.
noSuchPod
,
c
.
noDelete
Pod
}
}
}
type
reaperCoreFake
struct
{
type
reaperCoreFake
struct
{
coreclient
.
CoreInterface
coreclient
.
CoreInterface
noSuchPod
,
noDelete
Service
bool
noSuchPod
,
noDelete
Pod
bool
}
}
func
(
c
*
reaperCoreFake
)
Pods
(
namespace
string
)
coreclient
.
PodInterface
{
func
(
c
*
reaperCoreFake
)
Pods
(
namespace
string
)
coreclient
.
PodInterface
{
...
@@ -585,25 +585,16 @@ func (c *reaperCoreFake) Pods(namespace string) coreclient.PodInterface {
...
@@ -585,25 +585,16 @@ func (c *reaperCoreFake) Pods(namespace string) coreclient.PodInterface {
if
c
.
noSuchPod
{
if
c
.
noSuchPod
{
return
&
noSuchPod
{
pods
}
return
&
noSuchPod
{
pods
}
}
}
return
pods
if
c
.
noDeletePod
{
}
return
&
noDeletePod
{
pods
}
func
(
c
*
reaperCoreFake
)
Services
(
namespace
string
)
coreclient
.
ServiceInterface
{
services
:=
c
.
CoreInterface
.
Services
(
namespace
)
if
c
.
noDeleteService
{
return
&
noDeleteService
{
services
}
}
}
return
service
s
return
pod
s
}
}
func
pod
()
*
api
.
Pod
{
func
pod
()
*
api
.
Pod
{
return
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Namespace
:
metav1
.
NamespaceDefault
,
Name
:
"foo"
}}
return
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Namespace
:
metav1
.
NamespaceDefault
,
Name
:
"foo"
}}
}
}
func
service
()
*
api
.
Service
{
return
&
api
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Namespace
:
metav1
.
NamespaceDefault
,
Name
:
"foo"
}}
}
func
TestSimpleStop
(
t
*
testing
.
T
)
{
func
TestSimpleStop
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
fake
*
reaperFake
fake
*
reaperFake
...
@@ -626,18 +617,6 @@ func TestSimpleStop(t *testing.T) {
...
@@ -626,18 +617,6 @@ func TestSimpleStop(t *testing.T) {
},
},
{
{
fake
:
&
reaperFake
{
fake
:
&
reaperFake
{
Clientset
:
fake
.
NewSimpleClientset
(
service
()),
},
kind
:
api
.
Kind
(
"Service"
),
actions
:
[]
testcore
.
Action
{
testcore
.
NewGetAction
(
api
.
Resource
(
"services"
)
.
WithVersion
(
""
),
metav1
.
NamespaceDefault
,
"foo"
),
testcore
.
NewDeleteAction
(
api
.
Resource
(
"services"
)
.
WithVersion
(
""
),
metav1
.
NamespaceDefault
,
"foo"
),
},
expectError
:
false
,
test
:
"stop service succeeds"
,
},
{
fake
:
&
reaperFake
{
Clientset
:
fake
.
NewSimpleClientset
(),
Clientset
:
fake
.
NewSimpleClientset
(),
noSuchPod
:
true
,
noSuchPod
:
true
,
},
},
...
@@ -648,15 +627,15 @@ func TestSimpleStop(t *testing.T) {
...
@@ -648,15 +627,15 @@ func TestSimpleStop(t *testing.T) {
},
},
{
{
fake
:
&
reaperFake
{
fake
:
&
reaperFake
{
Clientset
:
fake
.
NewSimpleClientset
(
service
()),
Clientset
:
fake
.
NewSimpleClientset
(
pod
()),
noDelete
Service
:
true
,
noDelete
Pod
:
true
,
},
},
kind
:
api
.
Kind
(
"
Service
"
),
kind
:
api
.
Kind
(
"
Pod
"
),
actions
:
[]
testcore
.
Action
{
actions
:
[]
testcore
.
Action
{
testcore
.
NewGetAction
(
api
.
Resource
(
"
service
s"
)
.
WithVersion
(
""
),
metav1
.
NamespaceDefault
,
"foo"
),
testcore
.
NewGetAction
(
api
.
Resource
(
"
pod
s"
)
.
WithVersion
(
""
),
metav1
.
NamespaceDefault
,
"foo"
),
},
},
expectError
:
true
,
expectError
:
true
,
test
:
"stop
service
fails, can't delete"
,
test
:
"stop
pod
fails, can't delete"
,
},
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
...
...
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