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
1ac6d8af
Commit
1ac6d8af
authored
Nov 25, 2015
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update reaper, scaler, describer for GroupKind
parent
140df5f8
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
88 additions
and
70 deletions
+88
-70
kubectl
contrib/completions/bash/kubectl
+5
-0
register.go
pkg/api/register.go
+5
-0
register.go
pkg/apis/componentconfig/register.go
+5
-0
register.go
pkg/apis/extensions/register.go
+5
-0
register.go
pkg/apis/metrics/register.go
+5
-0
factory.go
pkg/kubectl/cmd/util/factory.go
+3
-7
describe.go
pkg/kubectl/describe.go
+25
-36
rolling_updater.go
pkg/kubectl/rolling_updater.go
+1
-1
scale.go
pkg/kubectl/scale.go
+5
-4
stop.go
pkg/kubectl/stop.go
+16
-10
stop_test.go
pkg/kubectl/stop_test.go
+6
-5
daemon_set.go
test/e2e/daemon_set.go
+1
-1
job.go
test/e2e/job.go
+3
-3
util.go
test/e2e/util.go
+1
-1
master_utils.go
test/integration/framework/master_utils.go
+2
-2
No files found.
contrib/completions/bash/kubectl
View file @
1ac6d8af
...
@@ -330,7 +330,12 @@ _kubectl_describe()
...
@@ -330,7 +330,12 @@ _kubectl_describe()
must_have_one_flag
=()
must_have_one_flag
=()
must_have_one_noun
=()
must_have_one_noun
=()
must_have_one_noun+
=(
"daemonset"
)
must_have_one_noun+
=(
"deployment"
)
must_have_one_noun+
=(
"endpoints"
)
must_have_one_noun+
=(
"endpoints"
)
must_have_one_noun+
=(
"horizontalpodautoscaler"
)
must_have_one_noun+
=(
"ingress"
)
must_have_one_noun+
=(
"job"
)
must_have_one_noun+
=(
"limitrange"
)
must_have_one_noun+
=(
"limitrange"
)
must_have_one_noun+
=(
"namespace"
)
must_have_one_noun+
=(
"namespace"
)
must_have_one_noun+
=(
"node"
)
must_have_one_noun+
=(
"node"
)
...
...
pkg/api/register.go
View file @
1ac6d8af
...
@@ -27,6 +27,11 @@ var Scheme = runtime.NewScheme()
...
@@ -27,6 +27,11 @@ var Scheme = runtime.NewScheme()
// SchemeGroupVersion is group version used to register these objects
// SchemeGroupVersion is group version used to register these objects
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
""
,
Version
:
""
}
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
""
,
Version
:
""
}
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func
Kind
(
kind
string
)
unversioned
.
GroupKind
{
return
SchemeGroupVersion
.
WithKind
(
kind
)
.
GroupKind
()
}
func
init
()
{
func
init
()
{
Scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
Scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
Pod
{},
&
Pod
{},
...
...
pkg/apis/componentconfig/register.go
View file @
1ac6d8af
...
@@ -28,6 +28,11 @@ func init() {
...
@@ -28,6 +28,11 @@ func init() {
// SchemeGroupVersion is group version used to register these objects
// SchemeGroupVersion is group version used to register these objects
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
"componentconfig"
,
Version
:
""
}
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
"componentconfig"
,
Version
:
""
}
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func
Kind
(
kind
string
)
unversioned
.
GroupKind
{
return
SchemeGroupVersion
.
WithKind
(
kind
)
.
GroupKind
()
}
func
addKnownTypes
()
{
func
addKnownTypes
()
{
// TODO this will get cleaned up with the scheme types are fixed
// TODO this will get cleaned up with the scheme types are fixed
api
.
Scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
api
.
Scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
...
...
pkg/apis/extensions/register.go
View file @
1ac6d8af
...
@@ -24,6 +24,11 @@ import (
...
@@ -24,6 +24,11 @@ import (
// SchemeGroupVersion is group version used to register these objects
// SchemeGroupVersion is group version used to register these objects
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
"extensions"
,
Version
:
""
}
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
"extensions"
,
Version
:
""
}
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func
Kind
(
kind
string
)
unversioned
.
GroupKind
{
return
SchemeGroupVersion
.
WithKind
(
kind
)
.
GroupKind
()
}
func
init
()
{
func
init
()
{
// Register the API.
// Register the API.
addKnownTypes
()
addKnownTypes
()
...
...
pkg/apis/metrics/register.go
View file @
1ac6d8af
...
@@ -29,6 +29,11 @@ func init() {
...
@@ -29,6 +29,11 @@ func init() {
// SchemeGroupVersion is group version used to register these objects
// SchemeGroupVersion is group version used to register these objects
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
"metrics"
,
Version
:
""
}
var
SchemeGroupVersion
=
unversioned
.
GroupVersion
{
Group
:
"metrics"
,
Version
:
""
}
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func
Kind
(
kind
string
)
unversioned
.
GroupKind
{
return
SchemeGroupVersion
.
WithKind
(
kind
)
.
GroupKind
()
}
// Adds the list of known types to api.Scheme.
// Adds the list of known types to api.Scheme.
func
addKnownTypes
()
{
func
addKnownTypes
()
{
// TODO this will get cleaned up with the scheme types are fixed
// TODO this will get cleaned up with the scheme types are fixed
...
...
pkg/kubectl/cmd/util/factory.go
View file @
1ac6d8af
...
@@ -172,15 +172,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
...
@@ -172,15 +172,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
return
nil
,
fmt
.
Errorf
(
"unable to get RESTClient for resource '%s'"
,
mapping
.
Resource
)
return
nil
,
fmt
.
Errorf
(
"unable to get RESTClient for resource '%s'"
,
mapping
.
Resource
)
},
},
Describer
:
func
(
mapping
*
meta
.
RESTMapping
)
(
kubectl
.
Describer
,
error
)
{
Describer
:
func
(
mapping
*
meta
.
RESTMapping
)
(
kubectl
.
Describer
,
error
)
{
gvk
,
err
:=
api
.
RESTMapper
.
KindFor
(
mapping
.
Resource
)
if
err
!=
nil
{
return
nil
,
err
}
client
,
err
:=
clients
.
ClientForVersion
(
mapping
.
GroupVersionKind
.
GroupVersion
()
.
String
())
client
,
err
:=
clients
.
ClientForVersion
(
mapping
.
GroupVersionKind
.
GroupVersion
()
.
String
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
describer
,
ok
:=
kubectl
.
DescriberFor
(
gvk
.
Group
,
mapping
.
GroupVersionKind
.
Kind
,
client
);
ok
{
if
describer
,
ok
:=
kubectl
.
DescriberFor
(
mapping
.
GroupVersionKind
.
GroupKind
()
,
client
);
ok
{
return
describer
,
nil
return
describer
,
nil
}
}
return
nil
,
fmt
.
Errorf
(
"no description has been implemented for %q"
,
mapping
.
Kind
)
return
nil
,
fmt
.
Errorf
(
"no description has been implemented for %q"
,
mapping
.
Kind
)
...
@@ -257,14 +253,14 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
...
@@ -257,14 +253,14 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
kubectl
.
ScalerFor
(
mapping
.
GroupVersionKind
.
Kind
,
client
)
return
kubectl
.
ScalerFor
(
mapping
.
GroupVersionKind
.
GroupKind
()
,
client
)
},
},
Reaper
:
func
(
mapping
*
meta
.
RESTMapping
)
(
kubectl
.
Reaper
,
error
)
{
Reaper
:
func
(
mapping
*
meta
.
RESTMapping
)
(
kubectl
.
Reaper
,
error
)
{
client
,
err
:=
clients
.
ClientForVersion
(
mapping
.
GroupVersionKind
.
GroupVersion
()
.
String
())
client
,
err
:=
clients
.
ClientForVersion
(
mapping
.
GroupVersionKind
.
GroupVersion
()
.
String
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
kubectl
.
ReaperFor
(
mapping
.
GroupVersionKind
.
Kind
,
client
)
return
kubectl
.
ReaperFor
(
mapping
.
GroupVersionKind
.
GroupKind
()
,
client
)
},
},
Validator
:
func
(
validate
bool
,
cacheDir
string
)
(
validation
.
Schema
,
error
)
{
Validator
:
func
(
validate
bool
,
cacheDir
string
)
(
validation
.
Schema
,
error
)
{
if
validate
{
if
validate
{
...
...
pkg/kubectl/describe.go
View file @
1ac6d8af
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fieldpath"
"k8s.io/kubernetes/pkg/fieldpath"
...
@@ -66,32 +67,29 @@ func (e ErrNoDescriber) Error() string {
...
@@ -66,32 +67,29 @@ func (e ErrNoDescriber) Error() string {
return
fmt
.
Sprintf
(
"no describer has been defined for %v"
,
e
.
Types
)
return
fmt
.
Sprintf
(
"no describer has been defined for %v"
,
e
.
Types
)
}
}
func
describerMap
(
c
*
client
.
Client
)
map
[
string
]
Describer
{
func
describerMap
(
c
*
client
.
Client
)
map
[
unversioned
.
GroupKind
]
Describer
{
m
:=
map
[
string
]
Describer
{
m
:=
map
[
unversioned
.
GroupKind
]
Describer
{
"Pod"
:
&
PodDescriber
{
c
},
api
.
Kind
(
"Pod"
)
:
&
PodDescriber
{
c
},
"ReplicationController"
:
&
ReplicationControllerDescriber
{
c
},
api
.
Kind
(
"ReplicationController"
)
:
&
ReplicationControllerDescriber
{
c
},
"Secret"
:
&
SecretDescriber
{
c
},
api
.
Kind
(
"Secret"
)
:
&
SecretDescriber
{
c
},
"Service"
:
&
ServiceDescriber
{
c
},
api
.
Kind
(
"Service"
)
:
&
ServiceDescriber
{
c
},
"ServiceAccount"
:
&
ServiceAccountDescriber
{
c
},
api
.
Kind
(
"ServiceAccount"
)
:
&
ServiceAccountDescriber
{
c
},
"Node"
:
&
NodeDescriber
{
c
},
api
.
Kind
(
"Node"
)
:
&
NodeDescriber
{
c
},
"LimitRange"
:
&
LimitRangeDescriber
{
c
},
api
.
Kind
(
"LimitRange"
)
:
&
LimitRangeDescriber
{
c
},
"ResourceQuota"
:
&
ResourceQuotaDescriber
{
c
},
api
.
Kind
(
"ResourceQuota"
)
:
&
ResourceQuotaDescriber
{
c
},
"PersistentVolume"
:
&
PersistentVolumeDescriber
{
c
},
api
.
Kind
(
"PersistentVolume"
)
:
&
PersistentVolumeDescriber
{
c
},
"PersistentVolumeClaim"
:
&
PersistentVolumeClaimDescriber
{
c
},
api
.
Kind
(
"PersistentVolumeClaim"
)
:
&
PersistentVolumeClaimDescriber
{
c
},
"Namespace"
:
&
NamespaceDescriber
{
c
},
api
.
Kind
(
"Namespace"
)
:
&
NamespaceDescriber
{
c
},
"Endpoints"
:
&
EndpointsDescriber
{
c
},
api
.
Kind
(
"Endpoints"
)
:
&
EndpointsDescriber
{
c
},
extensions
.
Kind
(
"HorizontalPodAutoscaler"
)
:
&
HorizontalPodAutoscalerDescriber
{
c
},
extensions
.
Kind
(
"DaemonSet"
)
:
&
DaemonSetDescriber
{
c
},
extensions
.
Kind
(
"Job"
)
:
&
JobDescriber
{
c
},
extensions
.
Kind
(
"Deployment"
)
:
&
DeploymentDescriber
{
c
},
extensions
.
Kind
(
"Ingress"
)
:
&
IngressDescriber
{
c
},
}
}
return
m
}
func
expDescriberMap
(
c
*
client
.
Client
)
map
[
string
]
Describer
{
return
m
return
map
[
string
]
Describer
{
"HorizontalPodAutoscaler"
:
&
HorizontalPodAutoscalerDescriber
{
c
},
"DaemonSet"
:
&
DaemonSetDescriber
{
c
},
"Job"
:
&
JobDescriber
{
c
},
"Deployment"
:
&
DeploymentDescriber
{
c
},
"Ingress"
:
&
IngressDescriber
{
c
},
}
}
}
// List of all resource types we can describe
// List of all resource types we can describe
...
@@ -99,7 +97,7 @@ func DescribableResources() []string {
...
@@ -99,7 +97,7 @@ func DescribableResources() []string {
keys
:=
make
([]
string
,
0
)
keys
:=
make
([]
string
,
0
)
for
k
:=
range
describerMap
(
nil
)
{
for
k
:=
range
describerMap
(
nil
)
{
resource
:=
strings
.
ToLower
(
k
)
resource
:=
strings
.
ToLower
(
k
.
Kind
)
keys
=
append
(
keys
,
resource
)
keys
=
append
(
keys
,
resource
)
}
}
return
keys
return
keys
...
@@ -107,17 +105,8 @@ func DescribableResources() []string {
...
@@ -107,17 +105,8 @@ func DescribableResources() []string {
// Describer returns the default describe functions for each of the standard
// Describer returns the default describe functions for each of the standard
// Kubernetes types.
// Kubernetes types.
func
DescriberFor
(
group
string
,
kind
string
,
c
*
client
.
Client
)
(
Describer
,
bool
)
{
func
DescriberFor
(
kind
unversioned
.
GroupKind
,
c
*
client
.
Client
)
(
Describer
,
bool
)
{
var
f
Describer
f
,
ok
:=
describerMap
(
c
)[
kind
]
var
ok
bool
switch
group
{
case
""
:
f
,
ok
=
describerMap
(
c
)[
kind
]
case
"extensions"
:
f
,
ok
=
expDescriberMap
(
c
)[
kind
]
}
return
f
,
ok
return
f
,
ok
}
}
...
...
pkg/kubectl/rolling_updater.go
View file @
1ac6d8af
...
@@ -342,7 +342,7 @@ func (r *RollingUpdater) scaleDown(newRc, oldRc *api.ReplicationController, desi
...
@@ -342,7 +342,7 @@ func (r *RollingUpdater) scaleDown(newRc, oldRc *api.ReplicationController, desi
// scalerScaleAndWait scales a controller using a Scaler and a real client.
// scalerScaleAndWait scales a controller using a Scaler and a real client.
func
(
r
*
RollingUpdater
)
scaleAndWaitWithScaler
(
rc
*
api
.
ReplicationController
,
retry
*
RetryParams
,
wait
*
RetryParams
)
(
*
api
.
ReplicationController
,
error
)
{
func
(
r
*
RollingUpdater
)
scaleAndWaitWithScaler
(
rc
*
api
.
ReplicationController
,
retry
*
RetryParams
,
wait
*
RetryParams
)
(
*
api
.
ReplicationController
,
error
)
{
scaler
,
err
:=
ScalerFor
(
"ReplicationController"
,
r
.
c
)
scaler
,
err
:=
ScalerFor
(
api
.
Kind
(
"ReplicationController"
)
,
r
.
c
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Couldn't make scaler: %s"
,
err
)
return
nil
,
fmt
.
Errorf
(
"Couldn't make scaler: %s"
,
err
)
}
}
...
...
pkg/kubectl/scale.go
View file @
1ac6d8af
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
...
@@ -39,13 +40,13 @@ type Scaler interface {
...
@@ -39,13 +40,13 @@ type Scaler interface {
ScaleSimple
(
namespace
,
name
string
,
preconditions
*
ScalePrecondition
,
newSize
uint
)
error
ScaleSimple
(
namespace
,
name
string
,
preconditions
*
ScalePrecondition
,
newSize
uint
)
error
}
}
func
ScalerFor
(
kind
string
,
c
client
.
Interface
)
(
Scaler
,
error
)
{
func
ScalerFor
(
kind
unversioned
.
GroupKind
,
c
client
.
Interface
)
(
Scaler
,
error
)
{
switch
kind
{
switch
kind
{
case
"ReplicationController"
:
case
api
.
Kind
(
"ReplicationController"
)
:
return
&
ReplicationControllerScaler
{
c
},
nil
return
&
ReplicationControllerScaler
{
c
},
nil
case
"Job"
:
case
extensions
.
Kind
(
"Job"
)
:
return
&
JobScaler
{
c
.
Extensions
()},
nil
return
&
JobScaler
{
c
.
Extensions
()},
nil
case
"Deployment"
:
case
extensions
.
Kind
(
"Deployment"
)
:
return
&
DeploymentScaler
{
c
.
Extensions
()},
nil
return
&
DeploymentScaler
{
c
.
Extensions
()},
nil
}
}
return
nil
,
fmt
.
Errorf
(
"no scaler has been implemented for %q"
,
kind
)
return
nil
,
fmt
.
Errorf
(
"no scaler has been implemented for %q"
,
kind
)
...
...
pkg/kubectl/stop.go
View file @
1ac6d8af
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
...
@@ -45,11 +46,11 @@ type Reaper interface {
...
@@ -45,11 +46,11 @@ type Reaper interface {
}
}
type
NoSuchReaperError
struct
{
type
NoSuchReaperError
struct
{
kind
string
kind
unversioned
.
GroupKind
}
}
func
(
n
*
NoSuchReaperError
)
Error
()
string
{
func
(
n
*
NoSuchReaperError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"no reaper has been implemented for %
q
"
,
n
.
kind
)
return
fmt
.
Sprintf
(
"no reaper has been implemented for %
v
"
,
n
.
kind
)
}
}
func
IsNoSuchReaperError
(
err
error
)
bool
{
func
IsNoSuchReaperError
(
err
error
)
bool
{
...
@@ -57,18 +58,23 @@ func IsNoSuchReaperError(err error) bool {
...
@@ -57,18 +58,23 @@ func IsNoSuchReaperError(err error) bool {
return
ok
return
ok
}
}
func
ReaperFor
(
kind
string
,
c
client
.
Interface
)
(
Reaper
,
error
)
{
func
ReaperFor
(
kind
unversioned
.
GroupKind
,
c
client
.
Interface
)
(
Reaper
,
error
)
{
switch
kind
{
switch
kind
{
case
"ReplicationController"
:
case
api
.
Kind
(
"ReplicationController"
)
:
return
&
ReplicationControllerReaper
{
c
,
Interval
,
Timeout
},
nil
return
&
ReplicationControllerReaper
{
c
,
Interval
,
Timeout
},
nil
case
"DaemonSet"
:
case
extensions
.
Kind
(
"DaemonSet"
)
:
return
&
DaemonSetReaper
{
c
,
Interval
,
Timeout
},
nil
return
&
DaemonSetReaper
{
c
,
Interval
,
Timeout
},
nil
case
"Pod"
:
case
api
.
Kind
(
"Pod"
)
:
return
&
PodReaper
{
c
},
nil
return
&
PodReaper
{
c
},
nil
case
"Service"
:
case
api
.
Kind
(
"Service"
)
:
return
&
ServiceReaper
{
c
},
nil
return
&
ServiceReaper
{
c
},
nil
case
"Job"
:
case
extensions
.
Kind
(
"Job"
)
:
return
&
JobReaper
{
c
,
Interval
,
Timeout
},
nil
return
&
JobReaper
{
c
,
Interval
,
Timeout
},
nil
}
}
return
nil
,
&
NoSuchReaperError
{
kind
}
return
nil
,
&
NoSuchReaperError
{
kind
}
}
}
...
@@ -120,7 +126,7 @@ func getOverlappingControllers(c client.ReplicationControllerInterface, rc *api.
...
@@ -120,7 +126,7 @@ func getOverlappingControllers(c client.ReplicationControllerInterface, rc *api.
func
(
reaper
*
ReplicationControllerReaper
)
Stop
(
namespace
,
name
string
,
timeout
time
.
Duration
,
gracePeriod
*
api
.
DeleteOptions
)
error
{
func
(
reaper
*
ReplicationControllerReaper
)
Stop
(
namespace
,
name
string
,
timeout
time
.
Duration
,
gracePeriod
*
api
.
DeleteOptions
)
error
{
rc
:=
reaper
.
ReplicationControllers
(
namespace
)
rc
:=
reaper
.
ReplicationControllers
(
namespace
)
scaler
,
err
:=
ScalerFor
(
"ReplicationController"
,
*
reaper
)
scaler
,
err
:=
ScalerFor
(
api
.
Kind
(
"ReplicationController"
)
,
*
reaper
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -224,7 +230,7 @@ func (reaper *DaemonSetReaper) Stop(namespace, name string, timeout time.Duratio
...
@@ -224,7 +230,7 @@ func (reaper *DaemonSetReaper) Stop(namespace, name string, timeout time.Duratio
func
(
reaper
*
JobReaper
)
Stop
(
namespace
,
name
string
,
timeout
time
.
Duration
,
gracePeriod
*
api
.
DeleteOptions
)
error
{
func
(
reaper
*
JobReaper
)
Stop
(
namespace
,
name
string
,
timeout
time
.
Duration
,
gracePeriod
*
api
.
DeleteOptions
)
error
{
jobs
:=
reaper
.
Extensions
()
.
Jobs
(
namespace
)
jobs
:=
reaper
.
Extensions
()
.
Jobs
(
namespace
)
pods
:=
reaper
.
Pods
(
namespace
)
pods
:=
reaper
.
Pods
(
namespace
)
scaler
,
err
:=
ScalerFor
(
"Job"
,
*
reaper
)
scaler
,
err
:=
ScalerFor
(
extensions
.
Kind
(
"Job"
)
,
*
reaper
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubectl/stop_test.go
View file @
1ac6d8af
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
client
"k8s.io/kubernetes/pkg/client/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
...
@@ -424,7 +425,7 @@ func (c *reaperFake) Services(namespace string) client.ServiceInterface {
...
@@ -424,7 +425,7 @@ func (c *reaperFake) Services(namespace string) client.ServiceInterface {
func
TestSimpleStop
(
t
*
testing
.
T
)
{
func
TestSimpleStop
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
fake
*
reaperFake
fake
*
reaperFake
kind
string
kind
unversioned
.
GroupKind
actions
[]
testclient
.
Action
actions
[]
testclient
.
Action
expectError
bool
expectError
bool
test
string
test
string
...
@@ -433,7 +434,7 @@ func TestSimpleStop(t *testing.T) {
...
@@ -433,7 +434,7 @@ func TestSimpleStop(t *testing.T) {
fake
:
&
reaperFake
{
fake
:
&
reaperFake
{
Fake
:
&
testclient
.
Fake
{},
Fake
:
&
testclient
.
Fake
{},
},
},
kind
:
"Pod"
,
kind
:
api
.
Kind
(
"Pod"
)
,
actions
:
[]
testclient
.
Action
{
actions
:
[]
testclient
.
Action
{
testclient
.
NewGetAction
(
"pods"
,
api
.
NamespaceDefault
,
"foo"
),
testclient
.
NewGetAction
(
"pods"
,
api
.
NamespaceDefault
,
"foo"
),
testclient
.
NewDeleteAction
(
"pods"
,
api
.
NamespaceDefault
,
"foo"
),
testclient
.
NewDeleteAction
(
"pods"
,
api
.
NamespaceDefault
,
"foo"
),
...
@@ -445,7 +446,7 @@ func TestSimpleStop(t *testing.T) {
...
@@ -445,7 +446,7 @@ func TestSimpleStop(t *testing.T) {
fake
:
&
reaperFake
{
fake
:
&
reaperFake
{
Fake
:
&
testclient
.
Fake
{},
Fake
:
&
testclient
.
Fake
{},
},
},
kind
:
"Service"
,
kind
:
api
.
Kind
(
"Service"
)
,
actions
:
[]
testclient
.
Action
{
actions
:
[]
testclient
.
Action
{
testclient
.
NewGetAction
(
"services"
,
api
.
NamespaceDefault
,
"foo"
),
testclient
.
NewGetAction
(
"services"
,
api
.
NamespaceDefault
,
"foo"
),
testclient
.
NewDeleteAction
(
"services"
,
api
.
NamespaceDefault
,
"foo"
),
testclient
.
NewDeleteAction
(
"services"
,
api
.
NamespaceDefault
,
"foo"
),
...
@@ -458,7 +459,7 @@ func TestSimpleStop(t *testing.T) {
...
@@ -458,7 +459,7 @@ func TestSimpleStop(t *testing.T) {
Fake
:
&
testclient
.
Fake
{},
Fake
:
&
testclient
.
Fake
{},
noSuchPod
:
true
,
noSuchPod
:
true
,
},
},
kind
:
"Pod"
,
kind
:
api
.
Kind
(
"Pod"
)
,
actions
:
[]
testclient
.
Action
{},
actions
:
[]
testclient
.
Action
{},
expectError
:
true
,
expectError
:
true
,
test
:
"stop pod fails, no pod"
,
test
:
"stop pod fails, no pod"
,
...
@@ -468,7 +469,7 @@ func TestSimpleStop(t *testing.T) {
...
@@ -468,7 +469,7 @@ func TestSimpleStop(t *testing.T) {
Fake
:
&
testclient
.
Fake
{},
Fake
:
&
testclient
.
Fake
{},
noDeleteService
:
true
,
noDeleteService
:
true
,
},
},
kind
:
"Service"
,
kind
:
api
.
Kind
(
"Service"
)
,
actions
:
[]
testclient
.
Action
{
actions
:
[]
testclient
.
Action
{
testclient
.
NewGetAction
(
"services"
,
api
.
NamespaceDefault
,
"foo"
),
testclient
.
NewGetAction
(
"services"
,
api
.
NamespaceDefault
,
"foo"
),
},
},
...
...
test/e2e/daemon_set.go
View file @
1ac6d8af
...
@@ -98,7 +98,7 @@ var _ = Describe("Daemon set", func() {
...
@@ -98,7 +98,7 @@ var _ = Describe("Daemon set", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
defer
func
()
{
defer
func
()
{
Logf
(
"Check that reaper kills all daemon pods for %s"
,
dsName
)
Logf
(
"Check that reaper kills all daemon pods for %s"
,
dsName
)
dsReaper
,
err
:=
kubectl
.
ReaperFor
(
"DaemonSet"
,
c
)
dsReaper
,
err
:=
kubectl
.
ReaperFor
(
extensions
.
Kind
(
"DaemonSet"
)
,
c
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
err
=
dsReaper
.
Stop
(
ns
,
dsName
,
0
,
nil
)
err
=
dsReaper
.
Stop
(
ns
,
dsName
,
0
,
nil
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
...
test/e2e/job.go
View file @
1ac6d8af
...
@@ -124,7 +124,7 @@ var _ = Describe("Job", func() {
...
@@ -124,7 +124,7 @@ var _ = Describe("Job", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"scale job up"
)
By
(
"scale job up"
)
scaler
,
err
:=
kubectl
.
ScalerFor
(
"Job"
,
f
.
Client
)
scaler
,
err
:=
kubectl
.
ScalerFor
(
extensions
.
Kind
(
"Job"
)
,
f
.
Client
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
waitForScale
:=
kubectl
.
NewRetryParams
(
5
*
time
.
Second
,
1
*
time
.
Minute
)
waitForScale
:=
kubectl
.
NewRetryParams
(
5
*
time
.
Second
,
1
*
time
.
Minute
)
waitForReplicas
:=
kubectl
.
NewRetryParams
(
5
*
time
.
Second
,
5
*
time
.
Minute
)
waitForReplicas
:=
kubectl
.
NewRetryParams
(
5
*
time
.
Second
,
5
*
time
.
Minute
)
...
@@ -149,7 +149,7 @@ var _ = Describe("Job", func() {
...
@@ -149,7 +149,7 @@ var _ = Describe("Job", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"scale job down"
)
By
(
"scale job down"
)
scaler
,
err
:=
kubectl
.
ScalerFor
(
"Job"
,
f
.
Client
)
scaler
,
err
:=
kubectl
.
ScalerFor
(
extensions
.
Kind
(
"Job"
)
,
f
.
Client
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
waitForScale
:=
kubectl
.
NewRetryParams
(
5
*
time
.
Second
,
1
*
time
.
Minute
)
waitForScale
:=
kubectl
.
NewRetryParams
(
5
*
time
.
Second
,
1
*
time
.
Minute
)
waitForReplicas
:=
kubectl
.
NewRetryParams
(
5
*
time
.
Second
,
5
*
time
.
Minute
)
waitForReplicas
:=
kubectl
.
NewRetryParams
(
5
*
time
.
Second
,
5
*
time
.
Minute
)
...
@@ -172,7 +172,7 @@ var _ = Describe("Job", func() {
...
@@ -172,7 +172,7 @@ var _ = Describe("Job", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"scale job down"
)
By
(
"scale job down"
)
reaper
,
err
:=
kubectl
.
ReaperFor
(
"Job"
,
f
.
Client
)
reaper
,
err
:=
kubectl
.
ReaperFor
(
extensions
.
Kind
(
"Job"
)
,
f
.
Client
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
timeout
:=
1
*
time
.
Minute
timeout
:=
1
*
time
.
Minute
err
=
reaper
.
Stop
(
f
.
Namespace
.
Name
,
job
.
Name
,
timeout
,
api
.
NewDeleteOptions
(
0
))
err
=
reaper
.
Stop
(
f
.
Namespace
.
Name
,
job
.
Name
,
timeout
,
api
.
NewDeleteOptions
(
0
))
...
...
test/e2e/util.go
View file @
1ac6d8af
...
@@ -1710,7 +1710,7 @@ func getNodeEvents(c *client.Client, nodeName string) []api.Event {
...
@@ -1710,7 +1710,7 @@ func getNodeEvents(c *client.Client, nodeName string) []api.Event {
func
ScaleRC
(
c
*
client
.
Client
,
ns
,
name
string
,
size
uint
,
wait
bool
)
error
{
func
ScaleRC
(
c
*
client
.
Client
,
ns
,
name
string
,
size
uint
,
wait
bool
)
error
{
By
(
fmt
.
Sprintf
(
"Scaling replication controller %s in namespace %s to %d"
,
name
,
ns
,
size
))
By
(
fmt
.
Sprintf
(
"Scaling replication controller %s in namespace %s to %d"
,
name
,
ns
,
size
))
scaler
,
err
:=
kubectl
.
ScalerFor
(
"ReplicationController"
,
c
)
scaler
,
err
:=
kubectl
.
ScalerFor
(
api
.
Kind
(
"ReplicationController"
)
,
c
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
test/integration/framework/master_utils.go
View file @
1ac6d8af
...
@@ -189,7 +189,7 @@ func RCFromManifest(fileName string) *api.ReplicationController {
...
@@ -189,7 +189,7 @@ func RCFromManifest(fileName string) *api.ReplicationController {
// StopRC stops the rc via kubectl's stop library
// StopRC stops the rc via kubectl's stop library
func
StopRC
(
rc
*
api
.
ReplicationController
,
restClient
*
client
.
Client
)
error
{
func
StopRC
(
rc
*
api
.
ReplicationController
,
restClient
*
client
.
Client
)
error
{
reaper
,
err
:=
kubectl
.
ReaperFor
(
"ReplicationController"
,
restClient
)
reaper
,
err
:=
kubectl
.
ReaperFor
(
api
.
Kind
(
"ReplicationController"
)
,
restClient
)
if
err
!=
nil
||
reaper
==
nil
{
if
err
!=
nil
||
reaper
==
nil
{
return
err
return
err
}
}
...
@@ -202,7 +202,7 @@ func StopRC(rc *api.ReplicationController, restClient *client.Client) error {
...
@@ -202,7 +202,7 @@ func StopRC(rc *api.ReplicationController, restClient *client.Client) error {
// ScaleRC scales the given rc to the given replicas.
// ScaleRC scales the given rc to the given replicas.
func
ScaleRC
(
name
,
ns
string
,
replicas
int
,
restClient
*
client
.
Client
)
(
*
api
.
ReplicationController
,
error
)
{
func
ScaleRC
(
name
,
ns
string
,
replicas
int
,
restClient
*
client
.
Client
)
(
*
api
.
ReplicationController
,
error
)
{
scaler
,
err
:=
kubectl
.
ScalerFor
(
"ReplicationController"
,
restClient
)
scaler
,
err
:=
kubectl
.
ScalerFor
(
api
.
Kind
(
"ReplicationController"
)
,
restClient
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
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