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
53ee3795
Commit
53ee3795
authored
Jul 29, 2015
by
jayunit100
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename getPodControllers to getPodController so that the truncate/ignore of…
Rename getPodControllers to getPodController so that the truncate/ignore of overlapping RCs is clear
parent
72db883b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
replication_controller.go
pkg/controller/replication/replication_controller.go
+6
-6
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+1
-1
No files found.
pkg/controller/replication/replication_controller.go
View file @
53ee3795
...
@@ -191,9 +191,9 @@ func (rm *ReplicationManager) Run(workers int, stopCh <-chan struct{}) {
...
@@ -191,9 +191,9 @@ func (rm *ReplicationManager) Run(workers int, stopCh <-chan struct{}) {
rm
.
queue
.
ShutDown
()
rm
.
queue
.
ShutDown
()
}
}
// getPodController
s
returns the controller managing the given pod.
// getPodController 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
)
getPodController
s
(
pod
*
api
.
Pod
)
*
api
.
ReplicationController
{
func
(
rm
*
ReplicationManager
)
getPodController
(
pod
*
api
.
Pod
)
*
api
.
ReplicationController
{
controllers
,
err
:=
rm
.
rcStore
.
GetPodControllers
(
pod
)
controllers
,
err
:=
rm
.
rcStore
.
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
)
...
@@ -211,7 +211,7 @@ func (rm *ReplicationManager) getPodControllers(pod *api.Pod) *api.ReplicationCo
...
@@ -211,7 +211,7 @@ func (rm *ReplicationManager) getPodControllers(pod *api.Pod) *api.ReplicationCo
// When a pod is created, enqueue the controller that manages it and update it's expectations.
// When a pod is created, enqueue the controller that manages it and update it's expectations.
func
(
rm
*
ReplicationManager
)
addPod
(
obj
interface
{})
{
func
(
rm
*
ReplicationManager
)
addPod
(
obj
interface
{})
{
pod
:=
obj
.
(
*
api
.
Pod
)
pod
:=
obj
.
(
*
api
.
Pod
)
if
rc
:=
rm
.
getPodController
s
(
pod
);
rc
!=
nil
{
if
rc
:=
rm
.
getPodController
(
pod
);
rc
!=
nil
{
rcKey
,
err
:=
controller
.
KeyFunc
(
rc
)
rcKey
,
err
:=
controller
.
KeyFunc
(
rc
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Couldn't get key for replication controller %#v: %v"
,
rc
,
err
)
glog
.
Errorf
(
"Couldn't get key for replication controller %#v: %v"
,
rc
,
err
)
...
@@ -232,7 +232,7 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
...
@@ -232,7 +232,7 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
}
}
// TODO: Write a unittest for this case
// TODO: Write a unittest for this case
curPod
:=
cur
.
(
*
api
.
Pod
)
curPod
:=
cur
.
(
*
api
.
Pod
)
if
rc
:=
rm
.
getPodController
s
(
curPod
);
rc
!=
nil
{
if
rc
:=
rm
.
getPodController
(
curPod
);
rc
!=
nil
{
rm
.
enqueueController
(
rc
)
rm
.
enqueueController
(
rc
)
}
}
oldPod
:=
old
.
(
*
api
.
Pod
)
oldPod
:=
old
.
(
*
api
.
Pod
)
...
@@ -240,7 +240,7 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
...
@@ -240,7 +240,7 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
if
!
reflect
.
DeepEqual
(
curPod
.
Labels
,
oldPod
.
Labels
)
{
if
!
reflect
.
DeepEqual
(
curPod
.
Labels
,
oldPod
.
Labels
)
{
// If the old and new rc are the same, the first one that syncs
// If the old and new rc are the same, the first one that syncs
// will set expectations preventing any damage from the second.
// will set expectations preventing any damage from the second.
if
oldRC
:=
rm
.
getPodController
s
(
oldPod
);
oldRC
!=
nil
{
if
oldRC
:=
rm
.
getPodController
(
oldPod
);
oldRC
!=
nil
{
rm
.
enqueueController
(
oldRC
)
rm
.
enqueueController
(
oldRC
)
}
}
}
}
...
@@ -267,7 +267,7 @@ func (rm *ReplicationManager) deletePod(obj interface{}) {
...
@@ -267,7 +267,7 @@ func (rm *ReplicationManager) deletePod(obj interface{}) {
return
return
}
}
}
}
if
rc
:=
rm
.
getPodController
s
(
pod
);
rc
!=
nil
{
if
rc
:=
rm
.
getPodController
(
pod
);
rc
!=
nil
{
rcKey
,
err
:=
controller
.
KeyFunc
(
rc
)
rcKey
,
err
:=
controller
.
KeyFunc
(
rc
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Couldn't get key for replication controller %#v: %v"
,
rc
,
err
)
glog
.
Errorf
(
"Couldn't get key for replication controller %#v: %v"
,
rc
,
err
)
...
...
pkg/controller/replication/replication_controller_test.go
View file @
53ee3795
...
@@ -484,7 +484,7 @@ func TestPodControllerLookup(t *testing.T) {
...
@@ -484,7 +484,7 @@ func TestPodControllerLookup(t *testing.T) {
for
_
,
r
:=
range
c
.
inRCs
{
for
_
,
r
:=
range
c
.
inRCs
{
manager
.
rcStore
.
Add
(
r
)
manager
.
rcStore
.
Add
(
r
)
}
}
if
rc
:=
manager
.
getPodController
s
(
c
.
pod
);
rc
!=
nil
{
if
rc
:=
manager
.
getPodController
(
c
.
pod
);
rc
!=
nil
{
if
c
.
outRCName
!=
rc
.
Name
{
if
c
.
outRCName
!=
rc
.
Name
{
t
.
Errorf
(
"Got controller %+v expected %+v"
,
rc
.
Name
,
c
.
outRCName
)
t
.
Errorf
(
"Got controller %+v expected %+v"
,
rc
.
Name
,
c
.
outRCName
)
}
}
...
...
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