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
77dcd470
Commit
77dcd470
authored
Jan 30, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20264 from Random-Liu/cleanup-config
Auto commit by PR queue bot
parents
9fef5f29
488e14a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
44 deletions
+19
-44
config.go
pkg/kubelet/config/config.go
+19
-44
No files found.
pkg/kubelet/config/config.go
View file @
77dcd470
...
@@ -208,16 +208,11 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
...
@@ -208,16 +208,11 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
pods
=
make
(
map
[
string
]
*
api
.
Pod
)
pods
=
make
(
map
[
string
]
*
api
.
Pod
)
}
}
update
:=
change
.
(
kubetypes
.
PodUpdate
)
// updatePodFunc is the local function which updates the pod cache *oldPods* with new pods *newPods*.
switch
update
.
Op
{
// After updated, new pod will be stored in the pod cache *pods*.
case
kubetypes
.
ADD
,
kubetypes
.
UPDATE
:
// Notice that *pods* and *oldPods* could be the same cache.
if
update
.
Op
==
kubetypes
.
ADD
{
updatePodsFunc
:=
func
(
newPods
[]
*
api
.
Pod
,
oldPods
,
pods
map
[
string
]
*
api
.
Pod
)
{
glog
.
V
(
4
)
.
Infof
(
"Adding new pods from source %s : %v"
,
source
,
update
.
Pods
)
filtered
:=
filterInvalidPods
(
newPods
,
source
,
s
.
recorder
)
}
else
{
glog
.
V
(
4
)
.
Infof
(
"Updating pods from source %s : %v"
,
source
,
update
.
Pods
)
}
filtered
:=
filterInvalidPods
(
update
.
Pods
,
source
,
s
.
recorder
)
for
_
,
ref
:=
range
filtered
{
for
_
,
ref
:=
range
filtered
{
name
:=
kubecontainer
.
GetPodFullName
(
ref
)
name
:=
kubecontainer
.
GetPodFullName
(
ref
)
// Annotate the pod with the source before any comparison.
// Annotate the pod with the source before any comparison.
...
@@ -225,7 +220,8 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
...
@@ -225,7 +220,8 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
ref
.
Annotations
=
make
(
map
[
string
]
string
)
ref
.
Annotations
=
make
(
map
[
string
]
string
)
}
}
ref
.
Annotations
[
kubetypes
.
ConfigSourceAnnotationKey
]
=
source
ref
.
Annotations
[
kubetypes
.
ConfigSourceAnnotationKey
]
=
source
if
existing
,
found
:=
pods
[
name
];
found
{
if
existing
,
found
:=
oldPods
[
name
];
found
{
pods
[
name
]
=
existing
needUpdate
,
needReconcile
:=
checkAndUpdatePod
(
existing
,
ref
)
needUpdate
,
needReconcile
:=
checkAndUpdatePod
(
existing
,
ref
)
if
needUpdate
{
if
needUpdate
{
updatePods
=
append
(
updatePods
,
existing
)
updatePods
=
append
(
updatePods
,
existing
)
...
@@ -247,6 +243,17 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
...
@@ -247,6 +243,17 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
addPods
=
append
(
addPods
,
ref
)
addPods
=
append
(
addPods
,
ref
)
}
}
}
}
}
update
:=
change
.
(
kubetypes
.
PodUpdate
)
switch
update
.
Op
{
case
kubetypes
.
ADD
,
kubetypes
.
UPDATE
:
if
update
.
Op
==
kubetypes
.
ADD
{
glog
.
V
(
4
)
.
Infof
(
"Adding new pods from source %s : %v"
,
source
,
update
.
Pods
)
}
else
{
glog
.
V
(
4
)
.
Infof
(
"Updating pods from source %s : %v"
,
source
,
update
.
Pods
)
}
updatePodsFunc
(
update
.
Pods
,
pods
,
pods
)
case
kubetypes
.
REMOVE
:
case
kubetypes
.
REMOVE
:
glog
.
V
(
4
)
.
Infof
(
"Removing a pod %v"
,
update
)
glog
.
V
(
4
)
.
Infof
(
"Removing a pod %v"
,
update
)
...
@@ -267,39 +274,7 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
...
@@ -267,39 +274,7 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
// Clear the old map entries by just creating a new map
// Clear the old map entries by just creating a new map
oldPods
:=
pods
oldPods
:=
pods
pods
=
make
(
map
[
string
]
*
api
.
Pod
)
pods
=
make
(
map
[
string
]
*
api
.
Pod
)
updatePodsFunc
(
update
.
Pods
,
oldPods
,
pods
)
filtered
:=
filterInvalidPods
(
update
.
Pods
,
source
,
s
.
recorder
)
for
_
,
ref
:=
range
filtered
{
name
:=
kubecontainer
.
GetPodFullName
(
ref
)
// Annotate the pod with the source before any comparison.
if
ref
.
Annotations
==
nil
{
ref
.
Annotations
=
make
(
map
[
string
]
string
)
}
ref
.
Annotations
[
kubetypes
.
ConfigSourceAnnotationKey
]
=
source
if
existing
,
found
:=
oldPods
[
name
];
found
{
pods
[
name
]
=
existing
needUpdate
,
needReconcile
:=
checkAndUpdatePod
(
existing
,
ref
)
if
needUpdate
{
updatePods
=
append
(
updatePods
,
existing
)
}
else
if
needReconcile
{
reconcilePods
=
append
(
reconcilePods
,
existing
)
}
continue
}
recordFirstSeenTime
(
ref
)
pods
[
name
]
=
ref
// If a pod is not found in the cache, and it's also not in the
// pending phase, it implies that kubelet may have restarted.
// Treat this pod as update so that kubelet wouldn't reject the
// pod in the admission process.
if
ref
.
Status
.
Phase
!=
api
.
PodPending
{
updatePods
=
append
(
updatePods
,
ref
)
}
else
{
// this is an add
addPods
=
append
(
addPods
,
ref
)
}
}
for
name
,
existing
:=
range
oldPods
{
for
name
,
existing
:=
range
oldPods
{
if
_
,
found
:=
pods
[
name
];
!
found
{
if
_
,
found
:=
pods
[
name
];
!
found
{
// this is a delete
// this is a delete
...
...
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