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
e5b586b5
Commit
e5b586b5
authored
Jan 02, 2017
by
Michail Kargakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share rc cache from the rc manager
parent
75c5f4d6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
95 additions
and
50 deletions
+95
-50
core.go
cmd/kube-controller-manager/app/core.go
+1
-1
core.go
pkg/controller/informers/core.go
+57
-2
factory.go
pkg/controller/informers/factory.go
+5
-0
replica_set.go
pkg/controller/replicaset/replica_set.go
+3
-12
BUILD
pkg/controller/replication/BUILD
+1
-2
replication_controller.go
pkg/controller/replication/replication_controller.go
+0
-0
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+0
-0
policy.go
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go
+1
-1
cluster-roles.yaml
...thorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
+1
-0
quota_test.go
test/integration/quota/quota_test.go
+9
-2
replicationcontroller_test.go
...ation/replicationcontroller/replicationcontroller_test.go
+17
-30
No files found.
cmd/kube-controller-manager/app/core.go
View file @
e5b586b5
...
@@ -55,8 +55,8 @@ func startEndpointController(ctx ControllerContext) (bool, error) {
...
@@ -55,8 +55,8 @@ func startEndpointController(ctx ControllerContext) (bool, error) {
func
startReplicationController
(
ctx
ControllerContext
)
(
bool
,
error
)
{
func
startReplicationController
(
ctx
ControllerContext
)
(
bool
,
error
)
{
go
replicationcontroller
.
NewReplicationManager
(
go
replicationcontroller
.
NewReplicationManager
(
ctx
.
InformerFactory
.
Pods
()
.
Informer
(),
ctx
.
InformerFactory
.
Pods
()
.
Informer
(),
ctx
.
InformerFactory
.
ReplicationControllers
()
.
Informer
(),
ctx
.
ClientBuilder
.
ClientOrDie
(
"replication-controller"
),
ctx
.
ClientBuilder
.
ClientOrDie
(
"replication-controller"
),
ResyncPeriod
(
&
ctx
.
Options
),
replicationcontroller
.
BurstReplicas
,
replicationcontroller
.
BurstReplicas
,
int
(
ctx
.
Options
.
LookupCacheSizeForRC
),
int
(
ctx
.
Options
.
LookupCacheSizeForRC
),
ctx
.
Options
.
EnableGarbageCollector
,
ctx
.
Options
.
EnableGarbageCollector
,
...
...
pkg/controller/informers/core.go
View file @
e5b586b5
...
@@ -318,6 +318,42 @@ func (f *internalLimitRangeInformer) Lister() coreinternallisters.LimitRangeList
...
@@ -318,6 +318,42 @@ func (f *internalLimitRangeInformer) Lister() coreinternallisters.LimitRangeList
//*****************************************************************************
//*****************************************************************************
// ReplicationControllerInformer is type of SharedIndexInformer which watches and lists all replication controllers.
// Interface provides constructor for informer and lister for replication controllers.
type
ReplicationControllerInformer
interface
{
Informer
()
cache
.
SharedIndexInformer
Lister
()
*
cache
.
StoreToReplicationControllerLister
}
type
replicationControllerInformer
struct
{
*
sharedInformerFactory
}
// Informer checks whether replicationControllerInformer exists in sharedInformerFactory and if not, it creates new informer of type
// replicationControllerInformer and connects it to sharedInformerFactory
func
(
f
*
replicationControllerInformer
)
Informer
()
cache
.
SharedIndexInformer
{
f
.
lock
.
Lock
()
defer
f
.
lock
.
Unlock
()
informerType
:=
reflect
.
TypeOf
(
&
v1
.
ReplicationController
{})
informer
,
exists
:=
f
.
informers
[
informerType
]
if
exists
{
return
informer
}
informer
=
NewReplicationControllerInformer
(
f
.
client
,
f
.
defaultResync
)
f
.
informers
[
informerType
]
=
informer
return
informer
}
// Lister returns lister for replicationControllerInformer
func
(
f
*
replicationControllerInformer
)
Lister
()
*
cache
.
StoreToReplicationControllerLister
{
informer
:=
f
.
Informer
()
return
&
cache
.
StoreToReplicationControllerLister
{
Indexer
:
informer
.
GetIndexer
()}
}
//*****************************************************************************
// NewPodInformer returns a SharedIndexInformer that lists and watches all pods
// NewPodInformer returns a SharedIndexInformer that lists and watches all pods
func
NewPodInformer
(
client
clientset
.
Interface
,
resyncPeriod
time
.
Duration
)
cache
.
SharedIndexInformer
{
func
NewPodInformer
(
client
clientset
.
Interface
,
resyncPeriod
time
.
Duration
)
cache
.
SharedIndexInformer
{
sharedIndexInformer
:=
cache
.
NewSharedIndexInformer
(
sharedIndexInformer
:=
cache
.
NewSharedIndexInformer
(
...
@@ -350,7 +386,7 @@ func NewNodeInformer(client clientset.Interface, resyncPeriod time.Duration) cac
...
@@ -350,7 +386,7 @@ func NewNodeInformer(client clientset.Interface, resyncPeriod time.Duration) cac
},
},
&
v1
.
Node
{},
&
v1
.
Node
{},
resyncPeriod
,
resyncPeriod
,
cache
.
Indexers
{
cache
.
NamespaceIndex
:
cache
.
MetaNamespaceIndexFunc
})
cache
.
Indexers
{})
return
sharedIndexInformer
return
sharedIndexInformer
}
}
...
@@ -445,7 +481,7 @@ func NewLimitRangeInformer(client clientset.Interface, resyncPeriod time.Duratio
...
@@ -445,7 +481,7 @@ func NewLimitRangeInformer(client clientset.Interface, resyncPeriod time.Duratio
},
},
&
v1
.
LimitRange
{},
&
v1
.
LimitRange
{},
resyncPeriod
,
resyncPeriod
,
cache
.
Indexers
{})
cache
.
Indexers
{
cache
.
NamespaceIndex
:
cache
.
MetaNamespaceIndexFunc
})
return
sharedIndexInformer
return
sharedIndexInformer
}
}
...
@@ -472,6 +508,25 @@ func NewInternalLimitRangeInformer(internalclient internalclientset.Interface, r
...
@@ -472,6 +508,25 @@ func NewInternalLimitRangeInformer(internalclient internalclientset.Interface, r
return
sharedIndexInformer
return
sharedIndexInformer
}
}
// NewReplicationControllerInformer returns a SharedIndexInformer that lists and watches all replication controllers.
func
NewReplicationControllerInformer
(
client
clientset
.
Interface
,
resyncPeriod
time
.
Duration
)
cache
.
SharedIndexInformer
{
sharedIndexInformer
:=
cache
.
NewSharedIndexInformer
(
&
cache
.
ListWatch
{
ListFunc
:
func
(
options
v1
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
return
client
.
Core
()
.
ReplicationControllers
(
v1
.
NamespaceAll
)
.
List
(
options
)
},
WatchFunc
:
func
(
options
v1
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
client
.
Core
()
.
ReplicationControllers
(
v1
.
NamespaceAll
)
.
Watch
(
options
)
},
},
&
v1
.
ReplicationController
{},
resyncPeriod
,
cache
.
Indexers
{
cache
.
NamespaceIndex
:
cache
.
MetaNamespaceIndexFunc
},
)
return
sharedIndexInformer
}
/*****************************************************************************/
/*****************************************************************************/
// ServiceAccountInformer is type of SharedIndexInformer which watches and lists all ServiceAccounts.
// ServiceAccountInformer is type of SharedIndexInformer which watches and lists all ServiceAccounts.
...
...
pkg/controller/informers/factory.go
View file @
e5b586b5
...
@@ -52,6 +52,7 @@ type SharedInformerFactory interface {
...
@@ -52,6 +52,7 @@ type SharedInformerFactory interface {
DaemonSets
()
DaemonSetInformer
DaemonSets
()
DaemonSetInformer
Deployments
()
DeploymentInformer
Deployments
()
DeploymentInformer
ReplicaSets
()
ReplicaSetInformer
ReplicaSets
()
ReplicaSetInformer
ReplicationControllers
()
ReplicationControllerInformer
ClusterRoleBindings
()
ClusterRoleBindingInformer
ClusterRoleBindings
()
ClusterRoleBindingInformer
ClusterRoles
()
ClusterRoleInformer
ClusterRoles
()
ClusterRoleInformer
...
@@ -151,6 +152,10 @@ func (f *sharedInformerFactory) ReplicaSets() ReplicaSetInformer {
...
@@ -151,6 +152,10 @@ func (f *sharedInformerFactory) ReplicaSets() ReplicaSetInformer {
return
&
replicaSetInformer
{
sharedInformerFactory
:
f
}
return
&
replicaSetInformer
{
sharedInformerFactory
:
f
}
}
}
func
(
f
*
sharedInformerFactory
)
ReplicationControllers
()
ReplicationControllerInformer
{
return
&
replicationControllerInformer
{
sharedInformerFactory
:
f
}
}
func
(
f
*
sharedInformerFactory
)
ClusterRoles
()
ClusterRoleInformer
{
func
(
f
*
sharedInformerFactory
)
ClusterRoles
()
ClusterRoleInformer
{
return
&
clusterRoleInformer
{
sharedInformerFactory
:
f
}
return
&
clusterRoleInformer
{
sharedInformerFactory
:
f
}
}
}
...
...
pkg/controller/replicaset/replica_set.go
View file @
e5b586b5
...
@@ -47,19 +47,10 @@ import (
...
@@ -47,19 +47,10 @@ import (
)
)
const
(
const
(
// We'll attempt to recompute the required replicas of all ReplicaSets
// that have fulfilled their expectations at least this often. This recomputation
// happens based on contents in local pod storage.
FullControllerResyncPeriod
=
30
*
time
.
Second
// Realistic value of the burstReplica field for the replica set manager based off
// Realistic value of the burstReplica field for the replica set manager based off
// performance requirements for kubernetes 1.0.
// performance requirements for kubernetes 1.0.
BurstReplicas
=
500
BurstReplicas
=
500
// We must avoid counting pods until the pod store has synced. If it hasn't synced, to
// avoid a hot loop, we'll wait this long between checks.
PodStoreSyncedPollPeriod
=
100
*
time
.
Millisecond
// The number of times we retry updating a ReplicaSet's status.
// The number of times we retry updating a ReplicaSet's status.
statusUpdateRetries
=
1
statusUpdateRetries
=
1
)
)
...
@@ -568,14 +559,14 @@ func (rsc *ReplicaSetController) syncReplicaSet(key string) error {
...
@@ -568,14 +559,14 @@ func (rsc *ReplicaSetController) syncReplicaSet(key string) error {
}()
}()
obj
,
exists
,
err
:=
rsc
.
rsLister
.
Indexer
.
GetByKey
(
key
)
obj
,
exists
,
err
:=
rsc
.
rsLister
.
Indexer
.
GetByKey
(
key
)
if
err
!=
nil
{
return
err
}
if
!
exists
{
if
!
exists
{
glog
.
V
(
4
)
.
Infof
(
"ReplicaSet has been deleted %v"
,
key
)
glog
.
V
(
4
)
.
Infof
(
"ReplicaSet has been deleted %v"
,
key
)
rsc
.
expectations
.
DeleteExpectations
(
key
)
rsc
.
expectations
.
DeleteExpectations
(
key
)
return
nil
return
nil
}
}
if
err
!=
nil
{
return
err
}
rs
:=
*
obj
.
(
*
extensions
.
ReplicaSet
)
rs
:=
*
obj
.
(
*
extensions
.
ReplicaSet
)
rsNeedsSync
:=
rsc
.
expectations
.
SatisfiedExpectations
(
key
)
rsNeedsSync
:=
rsc
.
expectations
.
SatisfiedExpectations
(
key
)
...
...
pkg/controller/replication/BUILD
View file @
e5b586b5
...
@@ -27,7 +27,6 @@ go_library(
...
@@ -27,7 +27,6 @@ go_library(
"//pkg/controller:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/controller/informers:go_default_library",
"//pkg/controller/informers:go_default_library",
"//pkg/labels:go_default_library",
"//pkg/labels:go_default_library",
"//pkg/runtime:go_default_library",
"//pkg/runtime/schema:go_default_library",
"//pkg/runtime/schema:go_default_library",
"//pkg/util:go_default_library",
"//pkg/util:go_default_library",
"//pkg/util/errors:go_default_library",
"//pkg/util/errors:go_default_library",
...
@@ -35,7 +34,6 @@ go_library(
...
@@ -35,7 +34,6 @@ go_library(
"//pkg/util/runtime:go_default_library",
"//pkg/util/runtime:go_default_library",
"//pkg/util/wait:go_default_library",
"//pkg/util/wait:go_default_library",
"//pkg/util/workqueue:go_default_library",
"//pkg/util/workqueue:go_default_library",
"//pkg/watch:go_default_library",
"//vendor:github.com/golang/glog",
"//vendor:github.com/golang/glog",
],
],
)
)
...
@@ -57,6 +55,7 @@ go_test(
...
@@ -57,6 +55,7 @@ go_test(
"//pkg/client/restclient:go_default_library",
"//pkg/client/restclient:go_default_library",
"//pkg/client/testing/core:go_default_library",
"//pkg/client/testing/core:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/controller/informers:go_default_library",
"//pkg/runtime:go_default_library",
"//pkg/runtime:go_default_library",
"//pkg/securitycontext:go_default_library",
"//pkg/securitycontext:go_default_library",
"//pkg/util/sets:go_default_library",
"//pkg/util/sets:go_default_library",
...
...
pkg/controller/replication/replication_controller.go
View file @
e5b586b5
This diff is collapsed.
Click to expand it.
pkg/controller/replication/replication_controller_test.go
View file @
e5b586b5
This diff is collapsed.
Click to expand it.
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go
View file @
e5b586b5
...
@@ -250,7 +250,7 @@ func ClusterRoles() []rbac.ClusterRole {
...
@@ -250,7 +250,7 @@ func ClusterRoles() []rbac.ClusterRole {
rbac
.
NewRule
(
"update"
)
.
Groups
(
legacyGroup
)
.
Resources
(
"endpoints"
,
"serviceaccounts"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"update"
)
.
Groups
(
legacyGroup
)
.
Resources
(
"endpoints"
,
"serviceaccounts"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
"*"
)
.
Resources
(
"namespaces"
,
"nodes"
,
"persistentvolumeclaims"
,
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
"*"
)
.
Resources
(
"namespaces"
,
"nodes"
,
"persistentvolumeclaims"
,
"persistentvolumes"
,
"pods"
,
"secrets"
,
"serviceaccounts"
)
.
RuleOrDie
(),
"persistentvolumes"
,
"pods"
,
"secrets"
,
"serviceaccounts"
,
"replicationcontrollers"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
extensionsGroup
)
.
Resources
(
"daemonsets"
,
"deployments"
,
"replicasets"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
extensionsGroup
)
.
Resources
(
"daemonsets"
,
"deployments"
,
"replicasets"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
batchGroup
)
.
Resources
(
"jobs"
,
"cronjobs"
)
.
RuleOrDie
(),
rbac
.
NewRule
(
"list"
,
"watch"
)
.
Groups
(
batchGroup
)
.
Resources
(
"jobs"
,
"cronjobs"
)
.
RuleOrDie
(),
},
},
...
...
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
View file @
e5b586b5
...
@@ -445,6 +445,7 @@ items:
...
@@ -445,6 +445,7 @@ items:
-
persistentvolumeclaims
-
persistentvolumeclaims
-
persistentvolumes
-
persistentvolumes
-
pods
-
pods
-
replicationcontrollers
-
secrets
-
secrets
-
serviceaccounts
-
serviceaccounts
verbs
:
verbs
:
...
...
test/integration/quota/quota_test.go
View file @
e5b586b5
...
@@ -31,8 +31,10 @@ import (
...
@@ -31,8 +31,10 @@ import (
"k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apimachinery/registered"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/informers"
replicationcontroller
"k8s.io/kubernetes/pkg/controller/replication"
replicationcontroller
"k8s.io/kubernetes/pkg/controller/replication"
resourcequotacontroller
"k8s.io/kubernetes/pkg/controller/resourcequota"
resourcequotacontroller
"k8s.io/kubernetes/pkg/controller/resourcequota"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/fields"
...
@@ -80,8 +82,13 @@ func TestQuota(t *testing.T) {
...
@@ -80,8 +82,13 @@ func TestQuota(t *testing.T) {
controllerCh
:=
make
(
chan
struct
{})
controllerCh
:=
make
(
chan
struct
{})
defer
close
(
controllerCh
)
defer
close
(
controllerCh
)
go
replicationcontroller
.
NewReplicationManagerFromClientForIntegration
(
clientset
,
controller
.
NoResyncPeriodFunc
,
replicationcontroller
.
BurstReplicas
,
4096
)
.
informers
:=
informers
.
NewSharedInformerFactory
(
clientset
,
nil
,
controller
.
NoResyncPeriodFunc
())
Run
(
3
,
controllerCh
)
podInformer
:=
informers
.
Pods
()
.
Informer
()
rcInformer
:=
informers
.
ReplicationControllers
()
.
Informer
()
rm
:=
replicationcontroller
.
NewReplicationManager
(
podInformer
,
rcInformer
,
clientset
,
replicationcontroller
.
BurstReplicas
,
4096
,
false
)
rm
.
SetEventRecorder
(
&
record
.
FakeRecorder
{})
informers
.
Start
(
controllerCh
)
go
rm
.
Run
(
3
,
controllerCh
)
resourceQuotaRegistry
:=
quotainstall
.
NewRegistry
(
clientset
,
nil
)
resourceQuotaRegistry
:=
quotainstall
.
NewRegistry
(
clientset
,
nil
)
groupKindsToReplenish
:=
[]
schema
.
GroupKind
{
groupKindsToReplenish
:=
[]
schema
.
GroupKind
{
...
...
test/integration/replicationcontroller/replicationcontroller_test.go
View file @
e5b586b5
...
@@ -123,7 +123,7 @@ func verifyRemainingObjects(t *testing.T, clientSet clientset.Interface, namespa
...
@@ -123,7 +123,7 @@ func verifyRemainingObjects(t *testing.T, clientSet clientset.Interface, namespa
return
ret
,
nil
return
ret
,
nil
}
}
func
rmSetup
(
t
*
testing
.
T
,
enableGarbageCollector
bool
)
(
*
httptest
.
Server
,
*
replication
.
ReplicationManager
,
cache
.
SharedIndexInformer
,
clientset
.
Interface
)
{
func
rmSetup
(
t
*
testing
.
T
,
stopCh
chan
struct
{},
enableGarbageCollector
bool
)
(
*
httptest
.
Server
,
*
replication
.
ReplicationManager
,
cache
.
SharedIndexInformer
,
clientset
.
Interface
)
{
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
masterConfig
:=
framework
.
NewIntegrationTestMasterConfig
()
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
_
,
s
:=
framework
.
RunAMaster
(
masterConfig
)
...
@@ -133,22 +133,13 @@ func rmSetup(t *testing.T, enableGarbageCollector bool) (*httptest.Server, *repl
...
@@ -133,22 +133,13 @@ func rmSetup(t *testing.T, enableGarbageCollector bool) (*httptest.Server, *repl
t
.
Fatalf
(
"Error in create clientset: %v"
,
err
)
t
.
Fatalf
(
"Error in create clientset: %v"
,
err
)
}
}
resyncPeriod
:=
12
*
time
.
Hour
resyncPeriod
:=
12
*
time
.
Hour
resyncPeriodFunc
:=
func
()
time
.
Duration
{
return
resyncPeriod
}
podInformer
:=
informers
.
NewPodInformer
(
clientset
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
&
config
,
"pod-informer"
)),
resyncPeriod
)
rm
:=
replication
.
NewReplicationManager
(
podInformer
,
clientset
.
NewForConfigOrDie
(
restclient
.
AddUserAgent
(
&
config
,
"replication-controller"
)),
resyncPeriodFunc
,
replication
.
BurstReplicas
,
4096
,
enableGarbageCollector
,
)
if
err
!=
nil
{
informers
:=
informers
.
NewSharedInformerFactory
(
clientSet
,
nil
,
resyncPeriod
)
t
.
Fatalf
(
"Failed to create replication manager"
)
podInformer
:=
informers
.
Pods
()
.
Informer
()
}
rcInformer
:=
informers
.
ReplicationControllers
()
.
Informer
()
rm
:=
replication
.
NewReplicationManager
(
podInformer
,
rcInformer
,
clientSet
,
replication
.
BurstReplicas
,
4096
,
enableGarbageCollector
)
informers
.
Start
(
stopCh
)
return
s
,
rm
,
podInformer
,
clientSet
return
s
,
rm
,
podInformer
,
clientSet
}
}
...
@@ -219,7 +210,8 @@ func TestAdoption(t *testing.T) {
...
@@ -219,7 +210,8 @@ func TestAdoption(t *testing.T) {
},
},
}
}
for
i
,
tc
:=
range
testCases
{
for
i
,
tc
:=
range
testCases
{
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
stopCh
:=
make
(
chan
struct
{})
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
stopCh
,
true
)
ns
:=
framework
.
CreateTestingNamespace
(
fmt
.
Sprintf
(
"adoption-%d"
,
i
),
s
,
t
)
ns
:=
framework
.
CreateTestingNamespace
(
fmt
.
Sprintf
(
"adoption-%d"
,
i
),
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
...
@@ -238,7 +230,6 @@ func TestAdoption(t *testing.T) {
...
@@ -238,7 +230,6 @@ func TestAdoption(t *testing.T) {
t
.
Fatalf
(
"Failed to create Pod: %v"
,
err
)
t
.
Fatalf
(
"Failed to create Pod: %v"
,
err
)
}
}
stopCh
:=
make
(
chan
struct
{})
go
podInformer
.
Run
(
stopCh
)
go
podInformer
.
Run
(
stopCh
)
waitToObservePods
(
t
,
podInformer
,
1
)
waitToObservePods
(
t
,
podInformer
,
1
)
go
rm
.
Run
(
5
,
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
...
@@ -296,7 +287,8 @@ func TestUpdateSelectorToAdopt(t *testing.T) {
...
@@ -296,7 +287,8 @@ func TestUpdateSelectorToAdopt(t *testing.T) {
// We have pod1, pod2 and rc. rc.spec.replicas=1. At first rc.Selector
// We have pod1, pod2 and rc. rc.spec.replicas=1. At first rc.Selector
// matches pod1 only; change the selector to match pod2 as well. Verify
// matches pod1 only; change the selector to match pod2 as well. Verify
// there is only one pod left.
// there is only one pod left.
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
stopCh
:=
make
(
chan
struct
{})
s
,
rm
,
_
,
clientSet
:=
rmSetup
(
t
,
stopCh
,
true
)
ns
:=
framework
.
CreateTestingNamespace
(
"update-selector-to-adopt"
,
s
,
t
)
ns
:=
framework
.
CreateTestingNamespace
(
"update-selector-to-adopt"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
rc
:=
newRC
(
"rc"
,
ns
.
Name
,
1
)
rc
:=
newRC
(
"rc"
,
ns
.
Name
,
1
)
...
@@ -309,8 +301,6 @@ func TestUpdateSelectorToAdopt(t *testing.T) {
...
@@ -309,8 +301,6 @@ func TestUpdateSelectorToAdopt(t *testing.T) {
pod2
.
Labels
[
"uniqueKey"
]
=
"2"
pod2
.
Labels
[
"uniqueKey"
]
=
"2"
createRCsPods
(
t
,
clientSet
,
[]
*
v1
.
ReplicationController
{
rc
},
[]
*
v1
.
Pod
{
pod1
,
pod2
},
ns
.
Name
)
createRCsPods
(
t
,
clientSet
,
[]
*
v1
.
ReplicationController
{
rc
},
[]
*
v1
.
Pod
{
pod1
,
pod2
},
ns
.
Name
)
stopCh
:=
make
(
chan
struct
{})
go
podInformer
.
Run
(
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
waitRCStable
(
t
,
clientSet
,
rc
,
ns
.
Name
)
waitRCStable
(
t
,
clientSet
,
rc
,
ns
.
Name
)
...
@@ -336,7 +326,8 @@ func TestUpdateSelectorToRemoveControllerRef(t *testing.T) {
...
@@ -336,7 +326,8 @@ func TestUpdateSelectorToRemoveControllerRef(t *testing.T) {
// matches pod1 and pod2; change the selector to match only pod1. Verify
// matches pod1 and pod2; change the selector to match only pod1. Verify
// that rc creates one more pod, so there are 3 pods. Also verify that
// that rc creates one more pod, so there are 3 pods. Also verify that
// pod2's controllerRef is cleared.
// pod2's controllerRef is cleared.
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
stopCh
:=
make
(
chan
struct
{})
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
stopCh
,
true
)
ns
:=
framework
.
CreateTestingNamespace
(
"update-selector-to-remove-controllerref"
,
s
,
t
)
ns
:=
framework
.
CreateTestingNamespace
(
"update-selector-to-remove-controllerref"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
rc
:=
newRC
(
"rc"
,
ns
.
Name
,
2
)
rc
:=
newRC
(
"rc"
,
ns
.
Name
,
2
)
...
@@ -346,8 +337,6 @@ func TestUpdateSelectorToRemoveControllerRef(t *testing.T) {
...
@@ -346,8 +337,6 @@ func TestUpdateSelectorToRemoveControllerRef(t *testing.T) {
pod2
.
Labels
[
"uniqueKey"
]
=
"2"
pod2
.
Labels
[
"uniqueKey"
]
=
"2"
createRCsPods
(
t
,
clientSet
,
[]
*
v1
.
ReplicationController
{
rc
},
[]
*
v1
.
Pod
{
pod1
,
pod2
},
ns
.
Name
)
createRCsPods
(
t
,
clientSet
,
[]
*
v1
.
ReplicationController
{
rc
},
[]
*
v1
.
Pod
{
pod1
,
pod2
},
ns
.
Name
)
stopCh
:=
make
(
chan
struct
{})
go
podInformer
.
Run
(
stopCh
)
waitToObservePods
(
t
,
podInformer
,
2
)
waitToObservePods
(
t
,
podInformer
,
2
)
go
rm
.
Run
(
5
,
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
waitRCStable
(
t
,
clientSet
,
rc
,
ns
.
Name
)
waitRCStable
(
t
,
clientSet
,
rc
,
ns
.
Name
)
...
@@ -382,7 +371,8 @@ func TestUpdateLabelToRemoveControllerRef(t *testing.T) {
...
@@ -382,7 +371,8 @@ func TestUpdateLabelToRemoveControllerRef(t *testing.T) {
// matches pod1 and pod2; change pod2's labels to non-matching. Verify
// matches pod1 and pod2; change pod2's labels to non-matching. Verify
// that rc creates one more pod, so there are 3 pods. Also verify that
// that rc creates one more pod, so there are 3 pods. Also verify that
// pod2's controllerRef is cleared.
// pod2's controllerRef is cleared.
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
stopCh
:=
make
(
chan
struct
{})
s
,
rm
,
_
,
clientSet
:=
rmSetup
(
t
,
stopCh
,
true
)
ns
:=
framework
.
CreateTestingNamespace
(
"update-label-to-remove-controllerref"
,
s
,
t
)
ns
:=
framework
.
CreateTestingNamespace
(
"update-label-to-remove-controllerref"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
rc
:=
newRC
(
"rc"
,
ns
.
Name
,
2
)
rc
:=
newRC
(
"rc"
,
ns
.
Name
,
2
)
...
@@ -390,8 +380,6 @@ func TestUpdateLabelToRemoveControllerRef(t *testing.T) {
...
@@ -390,8 +380,6 @@ func TestUpdateLabelToRemoveControllerRef(t *testing.T) {
pod2
:=
newMatchingPod
(
"pod2"
,
ns
.
Name
)
pod2
:=
newMatchingPod
(
"pod2"
,
ns
.
Name
)
createRCsPods
(
t
,
clientSet
,
[]
*
v1
.
ReplicationController
{
rc
},
[]
*
v1
.
Pod
{
pod1
,
pod2
},
ns
.
Name
)
createRCsPods
(
t
,
clientSet
,
[]
*
v1
.
ReplicationController
{
rc
},
[]
*
v1
.
Pod
{
pod1
,
pod2
},
ns
.
Name
)
stopCh
:=
make
(
chan
struct
{})
go
podInformer
.
Run
(
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
waitRCStable
(
t
,
clientSet
,
rc
,
ns
.
Name
)
waitRCStable
(
t
,
clientSet
,
rc
,
ns
.
Name
)
...
@@ -424,7 +412,8 @@ func TestUpdateLabelToBeAdopted(t *testing.T) {
...
@@ -424,7 +412,8 @@ func TestUpdateLabelToBeAdopted(t *testing.T) {
// matches pod1 only; change pod2's labels to be matching. Verify the RC
// matches pod1 only; change pod2's labels to be matching. Verify the RC
// controller adopts pod2 and delete one of them, so there is only 1 pod
// controller adopts pod2 and delete one of them, so there is only 1 pod
// left.
// left.
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
stopCh
:=
make
(
chan
struct
{})
s
,
rm
,
_
,
clientSet
:=
rmSetup
(
t
,
stopCh
,
true
)
ns
:=
framework
.
CreateTestingNamespace
(
"update-label-to-be-adopted"
,
s
,
t
)
ns
:=
framework
.
CreateTestingNamespace
(
"update-label-to-be-adopted"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
rc
:=
newRC
(
"rc"
,
ns
.
Name
,
1
)
rc
:=
newRC
(
"rc"
,
ns
.
Name
,
1
)
...
@@ -437,8 +426,6 @@ func TestUpdateLabelToBeAdopted(t *testing.T) {
...
@@ -437,8 +426,6 @@ func TestUpdateLabelToBeAdopted(t *testing.T) {
pod2
.
Labels
[
"uniqueKey"
]
=
"2"
pod2
.
Labels
[
"uniqueKey"
]
=
"2"
createRCsPods
(
t
,
clientSet
,
[]
*
v1
.
ReplicationController
{
rc
},
[]
*
v1
.
Pod
{
pod1
,
pod2
},
ns
.
Name
)
createRCsPods
(
t
,
clientSet
,
[]
*
v1
.
ReplicationController
{
rc
},
[]
*
v1
.
Pod
{
pod1
,
pod2
},
ns
.
Name
)
stopCh
:=
make
(
chan
struct
{})
go
podInformer
.
Run
(
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
waitRCStable
(
t
,
clientSet
,
rc
,
ns
.
Name
)
waitRCStable
(
t
,
clientSet
,
rc
,
ns
.
Name
)
...
...
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