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
c5bffaaf
Commit
c5bffaaf
authored
Jul 27, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11903 from mikedanese/renamers
rename StoreToControllerLister -> StoreToReplicationControllerLister
parents
f37be94d
d167fa27
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
36 deletions
+36
-36
listers.go
pkg/client/cache/listers.go
+7
-7
listers_test.go
pkg/client/cache/listers_test.go
+2
-2
replication_controller.go
pkg/controller/replication_controller.go
+5
-5
replication_controller_test.go
pkg/controller/replication_controller_test.go
+22
-22
No files found.
pkg/client/cache/listers.go
View file @
c5bffaaf
...
@@ -172,13 +172,13 @@ func (s *StoreToNodeLister) GetNodeInfo(id string) (*api.Node, error) {
...
@@ -172,13 +172,13 @@ func (s *StoreToNodeLister) GetNodeInfo(id string) (*api.Node, error) {
return
minion
.
(
*
api
.
Node
),
nil
return
minion
.
(
*
api
.
Node
),
nil
}
}
// StoreToControllerLister gives a store List and Exists methods. The store must contain only ReplicationControllers.
// StoreTo
Replication
ControllerLister gives a store List and Exists methods. The store must contain only ReplicationControllers.
type
StoreToControllerLister
struct
{
type
StoreTo
Replication
ControllerLister
struct
{
Store
Store
}
}
// Exists checks if the given rc exists in the store.
// Exists checks if the given rc exists in the store.
func
(
s
*
StoreToControllerLister
)
Exists
(
controller
*
api
.
ReplicationController
)
(
bool
,
error
)
{
func
(
s
*
StoreTo
Replication
ControllerLister
)
Exists
(
controller
*
api
.
ReplicationController
)
(
bool
,
error
)
{
_
,
exists
,
err
:=
s
.
Store
.
Get
(
controller
)
_
,
exists
,
err
:=
s
.
Store
.
Get
(
controller
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
...
@@ -186,17 +186,17 @@ func (s *StoreToControllerLister) Exists(controller *api.ReplicationController)
...
@@ -186,17 +186,17 @@ func (s *StoreToControllerLister) Exists(controller *api.ReplicationController)
return
exists
,
nil
return
exists
,
nil
}
}
// StoreToControllerLister lists all controllers in the store.
// StoreTo
Replication
ControllerLister lists all controllers in the store.
// TODO: converge on the interface in pkg/client
// TODO: converge on the interface in pkg/client
func
(
s
*
StoreToControllerLister
)
List
()
(
controllers
[]
api
.
ReplicationController
,
err
error
)
{
func
(
s
*
StoreTo
Replication
ControllerLister
)
List
()
(
controllers
[]
api
.
ReplicationController
,
err
error
)
{
for
_
,
c
:=
range
s
.
Store
.
List
()
{
for
_
,
c
:=
range
s
.
Store
.
List
()
{
controllers
=
append
(
controllers
,
*
(
c
.
(
*
api
.
ReplicationController
)))
controllers
=
append
(
controllers
,
*
(
c
.
(
*
api
.
ReplicationController
)))
}
}
return
controllers
,
nil
return
controllers
,
nil
}
}
// GetPodControllers returns a list of controllers managing a pod. Returns an error only if no matching controllers are found.
// GetPodControllers returns a list of
replication
controllers managing a pod. Returns an error only if no matching controllers are found.
func
(
s
*
StoreToControllerLister
)
GetPodControllers
(
pod
*
api
.
Pod
)
(
controllers
[]
api
.
ReplicationController
,
err
error
)
{
func
(
s
*
StoreTo
Replication
ControllerLister
)
GetPodControllers
(
pod
*
api
.
Pod
)
(
controllers
[]
api
.
ReplicationController
,
err
error
)
{
var
selector
labels
.
Selector
var
selector
labels
.
Selector
var
rc
api
.
ReplicationController
var
rc
api
.
ReplicationController
...
...
pkg/client/cache/listers_test.go
View file @
c5bffaaf
...
@@ -45,9 +45,9 @@ func TestStoreToMinionLister(t *testing.T) {
...
@@ -45,9 +45,9 @@ func TestStoreToMinionLister(t *testing.T) {
}
}
}
}
func
TestStoreToControllerLister
(
t
*
testing
.
T
)
{
func
TestStoreTo
Replication
ControllerLister
(
t
*
testing
.
T
)
{
store
:=
NewStore
(
MetaNamespaceKeyFunc
)
store
:=
NewStore
(
MetaNamespaceKeyFunc
)
lister
:=
StoreToControllerLister
{
store
}
lister
:=
StoreTo
Replication
ControllerLister
{
store
}
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
inRCs
[]
*
api
.
ReplicationController
inRCs
[]
*
api
.
ReplicationController
list
func
()
([]
api
.
ReplicationController
,
error
)
list
func
()
([]
api
.
ReplicationController
,
error
)
...
...
pkg/controller/replication_controller.go
View file @
c5bffaaf
...
@@ -91,8 +91,8 @@ type ReplicationManager struct {
...
@@ -91,8 +91,8 @@ type ReplicationManager struct {
// A TTLCache of pod creates/deletes each rc expects to see
// A TTLCache of pod creates/deletes each rc expects to see
expectations
RCExpectationsManager
expectations
RCExpectationsManager
// A store of controllers, populated by the rcController
// A store of
replication
controllers, populated by the rcController
controllerStore
cache
.
StoreTo
ControllerLister
rcStore
cache
.
StoreToReplication
ControllerLister
// A store of pods, populated by the podController
// A store of pods, populated by the podController
podStore
cache
.
StoreToPodLister
podStore
cache
.
StoreToPodLister
// Watches changes to all replication controllers
// Watches changes to all replication controllers
...
@@ -120,7 +120,7 @@ func NewReplicationManager(kubeClient client.Interface, burstReplicas int) *Repl
...
@@ -120,7 +120,7 @@ func NewReplicationManager(kubeClient client.Interface, burstReplicas int) *Repl
queue
:
workqueue
.
New
(),
queue
:
workqueue
.
New
(),
}
}
rm
.
controller
Store
.
Store
,
rm
.
rcController
=
framework
.
NewInformer
(
rm
.
rc
Store
.
Store
,
rm
.
rcController
=
framework
.
NewInformer
(
&
cache
.
ListWatch
{
&
cache
.
ListWatch
{
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
return
rm
.
kubeClient
.
ReplicationControllers
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
())
return
rm
.
kubeClient
.
ReplicationControllers
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
())
...
@@ -204,7 +204,7 @@ func (rm *ReplicationManager) Run(workers int, stopCh <-chan struct{}) {
...
@@ -204,7 +204,7 @@ func (rm *ReplicationManager) Run(workers int, stopCh <-chan struct{}) {
// getPodControllers returns the controller managing the given pod.
// getPodControllers returns the controller managing the given pod.
// TODO: Surface that we are ignoring multiple controllers for a single pod.
// TODO: Surface that we are ignoring multiple controllers for a single pod.
func
(
rm
*
ReplicationManager
)
getPodControllers
(
pod
*
api
.
Pod
)
*
api
.
ReplicationController
{
func
(
rm
*
ReplicationManager
)
getPodControllers
(
pod
*
api
.
Pod
)
*
api
.
ReplicationController
{
controllers
,
err
:=
rm
.
controller
Store
.
GetPodControllers
(
pod
)
controllers
,
err
:=
rm
.
rc
Store
.
GetPodControllers
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
4
)
.
Infof
(
"No controllers found for pod %v, replication manager will avoid syncing"
,
pod
.
Name
)
glog
.
V
(
4
)
.
Infof
(
"No controllers found for pod %v, replication manager will avoid syncing"
,
pod
.
Name
)
return
nil
return
nil
...
@@ -376,7 +376,7 @@ func (rm *ReplicationManager) syncReplicationController(key string) error {
...
@@ -376,7 +376,7 @@ func (rm *ReplicationManager) syncReplicationController(key string) error {
glog
.
V
(
4
)
.
Infof
(
"Finished syncing controller %q (%v)"
,
key
,
time
.
Now
()
.
Sub
(
startTime
))
glog
.
V
(
4
)
.
Infof
(
"Finished syncing controller %q (%v)"
,
key
,
time
.
Now
()
.
Sub
(
startTime
))
}()
}()
obj
,
exists
,
err
:=
rm
.
controller
Store
.
Store
.
GetByKey
(
key
)
obj
,
exists
,
err
:=
rm
.
rc
Store
.
Store
.
GetByKey
(
key
)
if
!
exists
{
if
!
exists
{
glog
.
Infof
(
"Replication Controller has been deleted %v"
,
key
)
glog
.
Infof
(
"Replication Controller has been deleted %v"
,
key
)
rm
.
expectations
.
DeleteExpectations
(
key
)
rm
.
expectations
.
DeleteExpectations
(
key
)
...
...
pkg/controller/replication_controller_test.go
View file @
c5bffaaf
...
@@ -229,7 +229,7 @@ func TestSyncReplicationControllerDoesNothing(t *testing.T) {
...
@@ -229,7 +229,7 @@ func TestSyncReplicationControllerDoesNothing(t *testing.T) {
// 2 running pods, a controller with 2 replicas, sync is a no-op
// 2 running pods, a controller with 2 replicas, sync is a no-op
controllerSpec
:=
newReplicationController
(
2
)
controllerSpec
:=
newReplicationController
(
2
)
manager
.
controller
Store
.
Store
.
Add
(
controllerSpec
)
manager
.
rc
Store
.
Store
.
Add
(
controllerSpec
)
newPodList
(
manager
.
podStore
.
Store
,
2
,
api
.
PodRunning
,
controllerSpec
)
newPodList
(
manager
.
podStore
.
Store
,
2
,
api
.
PodRunning
,
controllerSpec
)
manager
.
podControl
=
&
fakePodControl
manager
.
podControl
=
&
fakePodControl
...
@@ -246,7 +246,7 @@ func TestSyncReplicationControllerDeletes(t *testing.T) {
...
@@ -246,7 +246,7 @@ func TestSyncReplicationControllerDeletes(t *testing.T) {
// 2 running pods and a controller with 1 replica, one pod delete expected
// 2 running pods and a controller with 1 replica, one pod delete expected
controllerSpec
:=
newReplicationController
(
1
)
controllerSpec
:=
newReplicationController
(
1
)
manager
.
controller
Store
.
Store
.
Add
(
controllerSpec
)
manager
.
rc
Store
.
Store
.
Add
(
controllerSpec
)
newPodList
(
manager
.
podStore
.
Store
,
2
,
api
.
PodRunning
,
controllerSpec
)
newPodList
(
manager
.
podStore
.
Store
,
2
,
api
.
PodRunning
,
controllerSpec
)
manager
.
syncReplicationController
(
getKey
(
controllerSpec
,
t
))
manager
.
syncReplicationController
(
getKey
(
controllerSpec
,
t
))
...
@@ -269,7 +269,7 @@ func TestDeleteFinalStateUnknown(t *testing.T) {
...
@@ -269,7 +269,7 @@ func TestDeleteFinalStateUnknown(t *testing.T) {
// The DeletedFinalStateUnknown object should cause the rc manager to insert
// The DeletedFinalStateUnknown object should cause the rc manager to insert
// the controller matching the selectors of the deleted pod into the work queue.
// the controller matching the selectors of the deleted pod into the work queue.
controllerSpec
:=
newReplicationController
(
1
)
controllerSpec
:=
newReplicationController
(
1
)
manager
.
controller
Store
.
Store
.
Add
(
controllerSpec
)
manager
.
rc
Store
.
Store
.
Add
(
controllerSpec
)
pods
:=
newPodList
(
nil
,
1
,
api
.
PodRunning
,
controllerSpec
)
pods
:=
newPodList
(
nil
,
1
,
api
.
PodRunning
,
controllerSpec
)
manager
.
deletePod
(
cache
.
DeletedFinalStateUnknown
{
Key
:
"foo"
,
Obj
:
&
pods
.
Items
[
0
]})
manager
.
deletePod
(
cache
.
DeletedFinalStateUnknown
{
Key
:
"foo"
,
Obj
:
&
pods
.
Items
[
0
]})
...
@@ -293,7 +293,7 @@ func TestSyncReplicationControllerCreates(t *testing.T) {
...
@@ -293,7 +293,7 @@ func TestSyncReplicationControllerCreates(t *testing.T) {
// A controller with 2 replicas and no pods in the store, 2 creates expected
// A controller with 2 replicas and no pods in the store, 2 creates expected
controller
:=
newReplicationController
(
2
)
controller
:=
newReplicationController
(
2
)
manager
.
controller
Store
.
Store
.
Add
(
controller
)
manager
.
rc
Store
.
Store
.
Add
(
controller
)
fakePodControl
:=
FakePodControl
{}
fakePodControl
:=
FakePodControl
{}
manager
.
podControl
=
&
fakePodControl
manager
.
podControl
=
&
fakePodControl
...
@@ -355,7 +355,7 @@ func TestStatusUpdatesWithoutReplicasChange(t *testing.T) {
...
@@ -355,7 +355,7 @@ func TestStatusUpdatesWithoutReplicasChange(t *testing.T) {
// Steady state for the replication controller, no Status.Replicas updates expected
// Steady state for the replication controller, no Status.Replicas updates expected
activePods
:=
5
activePods
:=
5
rc
:=
newReplicationController
(
activePods
)
rc
:=
newReplicationController
(
activePods
)
manager
.
controller
Store
.
Store
.
Add
(
rc
)
manager
.
rc
Store
.
Store
.
Add
(
rc
)
rc
.
Status
=
api
.
ReplicationControllerStatus
{
Replicas
:
activePods
}
rc
.
Status
=
api
.
ReplicationControllerStatus
{
Replicas
:
activePods
}
newPodList
(
manager
.
podStore
.
Store
,
activePods
,
api
.
PodRunning
,
rc
)
newPodList
(
manager
.
podStore
.
Store
,
activePods
,
api
.
PodRunning
,
rc
)
...
@@ -397,7 +397,7 @@ func TestControllerUpdateReplicas(t *testing.T) {
...
@@ -397,7 +397,7 @@ func TestControllerUpdateReplicas(t *testing.T) {
// Insufficient number of pods in the system, and Status.Replicas is wrong;
// Insufficient number of pods in the system, and Status.Replicas is wrong;
// Status.Replica should update to match number of pods in system, 1 new pod should be created.
// Status.Replica should update to match number of pods in system, 1 new pod should be created.
rc
:=
newReplicationController
(
5
)
rc
:=
newReplicationController
(
5
)
manager
.
controller
Store
.
Store
.
Add
(
rc
)
manager
.
rc
Store
.
Store
.
Add
(
rc
)
rc
.
Status
=
api
.
ReplicationControllerStatus
{
Replicas
:
2
,
ObservedGeneration
:
0
}
rc
.
Status
=
api
.
ReplicationControllerStatus
{
Replicas
:
2
,
ObservedGeneration
:
0
}
rc
.
Generation
=
1
rc
.
Generation
=
1
newPodList
(
manager
.
podStore
.
Store
,
4
,
api
.
PodRunning
,
rc
)
newPodList
(
manager
.
podStore
.
Store
,
4
,
api
.
PodRunning
,
rc
)
...
@@ -586,7 +586,7 @@ func TestSyncReplicationControllerDormancy(t *testing.T) {
...
@@ -586,7 +586,7 @@ func TestSyncReplicationControllerDormancy(t *testing.T) {
manager
.
podControl
=
&
fakePodControl
manager
.
podControl
=
&
fakePodControl
controllerSpec
:=
newReplicationController
(
2
)
controllerSpec
:=
newReplicationController
(
2
)
manager
.
controller
Store
.
Store
.
Add
(
controllerSpec
)
manager
.
rc
Store
.
Store
.
Add
(
controllerSpec
)
newPodList
(
manager
.
podStore
.
Store
,
1
,
api
.
PodRunning
,
controllerSpec
)
newPodList
(
manager
.
podStore
.
Store
,
1
,
api
.
PodRunning
,
controllerSpec
)
// Creates a replica and sets expectations
// Creates a replica and sets expectations
...
@@ -668,7 +668,7 @@ func TestPodControllerLookup(t *testing.T) {
...
@@ -668,7 +668,7 @@ func TestPodControllerLookup(t *testing.T) {
}
}
for
_
,
c
:=
range
testCases
{
for
_
,
c
:=
range
testCases
{
for
_
,
r
:=
range
c
.
inRCs
{
for
_
,
r
:=
range
c
.
inRCs
{
manager
.
controller
Store
.
Add
(
r
)
manager
.
rc
Store
.
Add
(
r
)
}
}
if
rc
:=
manager
.
getPodControllers
(
c
.
pod
);
rc
!=
nil
{
if
rc
:=
manager
.
getPodControllers
(
c
.
pod
);
rc
!=
nil
{
if
c
.
outRCName
!=
rc
.
Name
{
if
c
.
outRCName
!=
rc
.
Name
{
...
@@ -699,7 +699,7 @@ func TestWatchControllers(t *testing.T) {
...
@@ -699,7 +699,7 @@ func TestWatchControllers(t *testing.T) {
// and closes the received channel to indicate that the test can finish.
// and closes the received channel to indicate that the test can finish.
manager
.
syncHandler
=
func
(
key
string
)
error
{
manager
.
syncHandler
=
func
(
key
string
)
error
{
obj
,
exists
,
err
:=
manager
.
controller
Store
.
Store
.
GetByKey
(
key
)
obj
,
exists
,
err
:=
manager
.
rc
Store
.
Store
.
GetByKey
(
key
)
if
!
exists
||
err
!=
nil
{
if
!
exists
||
err
!=
nil
{
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
}
}
...
@@ -735,13 +735,13 @@ func TestWatchPods(t *testing.T) {
...
@@ -735,13 +735,13 @@ func TestWatchPods(t *testing.T) {
// Put one rc and one pod into the controller's stores
// Put one rc and one pod into the controller's stores
testControllerSpec
:=
newReplicationController
(
1
)
testControllerSpec
:=
newReplicationController
(
1
)
manager
.
controller
Store
.
Store
.
Add
(
testControllerSpec
)
manager
.
rc
Store
.
Store
.
Add
(
testControllerSpec
)
received
:=
make
(
chan
string
)
received
:=
make
(
chan
string
)
// The pod update sent through the fakeWatcher should figure out the managing rc and
// The pod update sent through the fakeWatcher should figure out the managing rc and
// send it into the syncHandler.
// send it into the syncHandler.
manager
.
syncHandler
=
func
(
key
string
)
error
{
manager
.
syncHandler
=
func
(
key
string
)
error
{
obj
,
exists
,
err
:=
manager
.
controller
Store
.
Store
.
GetByKey
(
key
)
obj
,
exists
,
err
:=
manager
.
rc
Store
.
Store
.
GetByKey
(
key
)
if
!
exists
||
err
!=
nil
{
if
!
exists
||
err
!=
nil
{
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
}
}
...
@@ -780,7 +780,7 @@ func TestUpdatePods(t *testing.T) {
...
@@ -780,7 +780,7 @@ func TestUpdatePods(t *testing.T) {
received
:=
make
(
chan
string
)
received
:=
make
(
chan
string
)
manager
.
syncHandler
=
func
(
key
string
)
error
{
manager
.
syncHandler
=
func
(
key
string
)
error
{
obj
,
exists
,
err
:=
manager
.
controller
Store
.
Store
.
GetByKey
(
key
)
obj
,
exists
,
err
:=
manager
.
rc
Store
.
Store
.
GetByKey
(
key
)
if
!
exists
||
err
!=
nil
{
if
!
exists
||
err
!=
nil
{
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
}
}
...
@@ -794,11 +794,11 @@ func TestUpdatePods(t *testing.T) {
...
@@ -794,11 +794,11 @@ func TestUpdatePods(t *testing.T) {
// Put 2 rcs and one pod into the controller's stores
// Put 2 rcs and one pod into the controller's stores
testControllerSpec1
:=
newReplicationController
(
1
)
testControllerSpec1
:=
newReplicationController
(
1
)
manager
.
controller
Store
.
Store
.
Add
(
testControllerSpec1
)
manager
.
rc
Store
.
Store
.
Add
(
testControllerSpec1
)
testControllerSpec2
:=
*
testControllerSpec1
testControllerSpec2
:=
*
testControllerSpec1
testControllerSpec2
.
Spec
.
Selector
=
map
[
string
]
string
{
"bar"
:
"foo"
}
testControllerSpec2
.
Spec
.
Selector
=
map
[
string
]
string
{
"bar"
:
"foo"
}
testControllerSpec2
.
Name
=
"barfoo"
testControllerSpec2
.
Name
=
"barfoo"
manager
.
controller
Store
.
Store
.
Add
(
&
testControllerSpec2
)
manager
.
rc
Store
.
Store
.
Add
(
&
testControllerSpec2
)
// Put one pod in the podStore
// Put one pod in the podStore
pod1
:=
newPodList
(
manager
.
podStore
.
Store
,
1
,
api
.
PodRunning
,
testControllerSpec1
)
.
Items
[
0
]
pod1
:=
newPodList
(
manager
.
podStore
.
Store
,
1
,
api
.
PodRunning
,
testControllerSpec1
)
.
Items
[
0
]
...
@@ -837,7 +837,7 @@ func TestControllerUpdateRequeue(t *testing.T) {
...
@@ -837,7 +837,7 @@ func TestControllerUpdateRequeue(t *testing.T) {
manager
.
podStoreSynced
=
alwaysReady
manager
.
podStoreSynced
=
alwaysReady
rc
:=
newReplicationController
(
1
)
rc
:=
newReplicationController
(
1
)
manager
.
controller
Store
.
Store
.
Add
(
rc
)
manager
.
rc
Store
.
Store
.
Add
(
rc
)
rc
.
Status
=
api
.
ReplicationControllerStatus
{
Replicas
:
2
}
rc
.
Status
=
api
.
ReplicationControllerStatus
{
Replicas
:
2
}
newPodList
(
manager
.
podStore
.
Store
,
1
,
api
.
PodRunning
,
rc
)
newPodList
(
manager
.
podStore
.
Store
,
1
,
api
.
PodRunning
,
rc
)
...
@@ -915,7 +915,7 @@ func doTestControllerBurstReplicas(t *testing.T, burstReplicas, numReplicas int)
...
@@ -915,7 +915,7 @@ func doTestControllerBurstReplicas(t *testing.T, burstReplicas, numReplicas int)
manager
.
podControl
=
&
fakePodControl
manager
.
podControl
=
&
fakePodControl
controllerSpec
:=
newReplicationController
(
numReplicas
)
controllerSpec
:=
newReplicationController
(
numReplicas
)
manager
.
controller
Store
.
Store
.
Add
(
controllerSpec
)
manager
.
rc
Store
.
Store
.
Add
(
controllerSpec
)
expectedPods
:=
0
expectedPods
:=
0
pods
:=
newPodList
(
nil
,
numReplicas
,
api
.
PodPending
,
controllerSpec
)
pods
:=
newPodList
(
nil
,
numReplicas
,
api
.
PodPending
,
controllerSpec
)
...
@@ -924,7 +924,7 @@ func doTestControllerBurstReplicas(t *testing.T, burstReplicas, numReplicas int)
...
@@ -924,7 +924,7 @@ func doTestControllerBurstReplicas(t *testing.T, burstReplicas, numReplicas int)
for
_
,
replicas
:=
range
[]
int
{
numReplicas
,
0
}
{
for
_
,
replicas
:=
range
[]
int
{
numReplicas
,
0
}
{
controllerSpec
.
Spec
.
Replicas
=
replicas
controllerSpec
.
Spec
.
Replicas
=
replicas
manager
.
controller
Store
.
Store
.
Add
(
controllerSpec
)
manager
.
rc
Store
.
Store
.
Add
(
controllerSpec
)
for
i
:=
0
;
i
<
numReplicas
;
i
+=
burstReplicas
{
for
i
:=
0
;
i
<
numReplicas
;
i
+=
burstReplicas
{
manager
.
syncReplicationController
(
getKey
(
controllerSpec
,
t
))
manager
.
syncReplicationController
(
getKey
(
controllerSpec
,
t
))
...
@@ -1030,7 +1030,7 @@ func TestRCSyncExpectations(t *testing.T) {
...
@@ -1030,7 +1030,7 @@ func TestRCSyncExpectations(t *testing.T) {
manager
.
podControl
=
&
fakePodControl
manager
.
podControl
=
&
fakePodControl
controllerSpec
:=
newReplicationController
(
2
)
controllerSpec
:=
newReplicationController
(
2
)
manager
.
controller
Store
.
Store
.
Add
(
controllerSpec
)
manager
.
rc
Store
.
Store
.
Add
(
controllerSpec
)
pods
:=
newPodList
(
nil
,
2
,
api
.
PodPending
,
controllerSpec
)
pods
:=
newPodList
(
nil
,
2
,
api
.
PodPending
,
controllerSpec
)
manager
.
podStore
.
Store
.
Add
(
&
pods
.
Items
[
0
])
manager
.
podStore
.
Store
.
Add
(
&
pods
.
Items
[
0
])
postExpectationsPod
:=
pods
.
Items
[
1
]
postExpectationsPod
:=
pods
.
Items
[
1
]
...
@@ -1053,7 +1053,7 @@ func TestDeleteControllerAndExpectations(t *testing.T) {
...
@@ -1053,7 +1053,7 @@ func TestDeleteControllerAndExpectations(t *testing.T) {
manager
.
podStoreSynced
=
alwaysReady
manager
.
podStoreSynced
=
alwaysReady
rc
:=
newReplicationController
(
1
)
rc
:=
newReplicationController
(
1
)
manager
.
controller
Store
.
Store
.
Add
(
rc
)
manager
.
rc
Store
.
Store
.
Add
(
rc
)
fakePodControl
:=
FakePodControl
{}
fakePodControl
:=
FakePodControl
{}
manager
.
podControl
=
&
fakePodControl
manager
.
podControl
=
&
fakePodControl
...
@@ -1069,7 +1069,7 @@ func TestDeleteControllerAndExpectations(t *testing.T) {
...
@@ -1069,7 +1069,7 @@ func TestDeleteControllerAndExpectations(t *testing.T) {
if
!
exists
||
err
!=
nil
{
if
!
exists
||
err
!=
nil
{
t
.
Errorf
(
"No expectations found for rc"
)
t
.
Errorf
(
"No expectations found for rc"
)
}
}
manager
.
controller
Store
.
Delete
(
rc
)
manager
.
rc
Store
.
Delete
(
rc
)
manager
.
syncReplicationController
(
getKey
(
rc
,
t
))
manager
.
syncReplicationController
(
getKey
(
rc
,
t
))
if
_
,
exists
,
err
=
manager
.
expectations
.
GetExpectations
(
rc
);
exists
{
if
_
,
exists
,
err
=
manager
.
expectations
.
GetExpectations
(
rc
);
exists
{
...
@@ -1094,7 +1094,7 @@ func TestRCManagerNotReady(t *testing.T) {
...
@@ -1094,7 +1094,7 @@ func TestRCManagerNotReady(t *testing.T) {
// want to end up creating replicas in this case until the pod reflector
// want to end up creating replicas in this case until the pod reflector
// has synced, so the rc manager should just requeue the rc.
// has synced, so the rc manager should just requeue the rc.
controllerSpec
:=
newReplicationController
(
1
)
controllerSpec
:=
newReplicationController
(
1
)
manager
.
controller
Store
.
Store
.
Add
(
controllerSpec
)
manager
.
rc
Store
.
Store
.
Add
(
controllerSpec
)
rcKey
:=
getKey
(
controllerSpec
,
t
)
rcKey
:=
getKey
(
controllerSpec
,
t
)
manager
.
syncReplicationController
(
rcKey
)
manager
.
syncReplicationController
(
rcKey
)
...
@@ -1137,7 +1137,7 @@ func TestOverlappingRCs(t *testing.T) {
...
@@ -1137,7 +1137,7 @@ func TestOverlappingRCs(t *testing.T) {
}
}
shuffledControllers
:=
shuffle
(
controllers
)
shuffledControllers
:=
shuffle
(
controllers
)
for
j
:=
range
shuffledControllers
{
for
j
:=
range
shuffledControllers
{
manager
.
controller
Store
.
Store
.
Add
(
shuffledControllers
[
j
])
manager
.
rc
Store
.
Store
.
Add
(
shuffledControllers
[
j
])
}
}
// Add a pod and make sure only the oldest rc is synced
// Add a pod and make sure only the oldest rc is synced
pods
:=
newPodList
(
nil
,
1
,
api
.
PodPending
,
controllers
[
0
])
pods
:=
newPodList
(
nil
,
1
,
api
.
PodPending
,
controllers
[
0
])
...
...
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