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
16ff0c2d
Commit
16ff0c2d
authored
Jan 10, 2018
by
ravisantoshgudimetla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved readability for messages being logged
parent
2d2fa023
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
cache.go
pkg/scheduler/schedulercache/cache.go
+9
-9
No files found.
pkg/scheduler/schedulercache/cache.go
View file @
16ff0c2d
...
@@ -131,7 +131,7 @@ func (cache *schedulerCache) AssumePod(pod *v1.Pod) error {
...
@@ -131,7 +131,7 @@ func (cache *schedulerCache) AssumePod(pod *v1.Pod) error {
cache
.
mu
.
Lock
()
cache
.
mu
.
Lock
()
defer
cache
.
mu
.
Unlock
()
defer
cache
.
mu
.
Unlock
()
if
_
,
ok
:=
cache
.
podStates
[
key
];
ok
{
if
_
,
ok
:=
cache
.
podStates
[
key
];
ok
{
return
fmt
.
Errorf
(
"pod %v
state wasn't initial but get
assumed"
,
key
)
return
fmt
.
Errorf
(
"pod %v
is not in the cache, so can't be
assumed"
,
key
)
}
}
cache
.
addPod
(
pod
)
cache
.
addPod
(
pod
)
...
@@ -178,7 +178,7 @@ func (cache *schedulerCache) ForgetPod(pod *v1.Pod) error {
...
@@ -178,7 +178,7 @@ func (cache *schedulerCache) ForgetPod(pod *v1.Pod) error {
currState
,
ok
:=
cache
.
podStates
[
key
]
currState
,
ok
:=
cache
.
podStates
[
key
]
if
ok
&&
currState
.
pod
.
Spec
.
NodeName
!=
pod
.
Spec
.
NodeName
{
if
ok
&&
currState
.
pod
.
Spec
.
NodeName
!=
pod
.
Spec
.
NodeName
{
return
fmt
.
Errorf
(
"pod %v
state was assumed on a different node"
,
key
)
return
fmt
.
Errorf
(
"pod %v
was assumed on %v but assigned to %v"
,
key
,
pod
.
Spec
.
NodeName
,
currState
.
pod
.
Spec
.
NodeName
)
}
}
switch
{
switch
{
...
@@ -191,7 +191,7 @@ func (cache *schedulerCache) ForgetPod(pod *v1.Pod) error {
...
@@ -191,7 +191,7 @@ func (cache *schedulerCache) ForgetPod(pod *v1.Pod) error {
delete
(
cache
.
assumedPods
,
key
)
delete
(
cache
.
assumedPods
,
key
)
delete
(
cache
.
podStates
,
key
)
delete
(
cache
.
podStates
,
key
)
default
:
default
:
return
fmt
.
Errorf
(
"pod %v
state wasn't assumed but get
forgotten"
,
key
)
return
fmt
.
Errorf
(
"pod %v
wasn't assumed so cannot be
forgotten"
,
key
)
}
}
return
nil
return
nil
}
}
...
@@ -241,7 +241,7 @@ func (cache *schedulerCache) AddPod(pod *v1.Pod) error {
...
@@ -241,7 +241,7 @@ func (cache *schedulerCache) AddPod(pod *v1.Pod) error {
case
ok
&&
cache
.
assumedPods
[
key
]
:
case
ok
&&
cache
.
assumedPods
[
key
]
:
if
currState
.
pod
.
Spec
.
NodeName
!=
pod
.
Spec
.
NodeName
{
if
currState
.
pod
.
Spec
.
NodeName
!=
pod
.
Spec
.
NodeName
{
// The pod was added to a different node than it was assumed to.
// The pod was added to a different node than it was assumed to.
glog
.
Warningf
(
"Pod %v
assumed to a different node than added to."
,
key
)
glog
.
Warningf
(
"Pod %v
was assumed to be on %v but got added to %v"
,
key
,
pod
.
Spec
.
NodeName
,
currState
.
pod
.
Spec
.
NodeName
)
// Clean this up.
// Clean this up.
cache
.
removePod
(
currState
.
pod
)
cache
.
removePod
(
currState
.
pod
)
cache
.
addPod
(
pod
)
cache
.
addPod
(
pod
)
...
@@ -257,7 +257,7 @@ func (cache *schedulerCache) AddPod(pod *v1.Pod) error {
...
@@ -257,7 +257,7 @@ func (cache *schedulerCache) AddPod(pod *v1.Pod) error {
}
}
cache
.
podStates
[
key
]
=
ps
cache
.
podStates
[
key
]
=
ps
default
:
default
:
return
fmt
.
Errorf
(
"pod
was already in added state. Pod key: %v
"
,
key
)
return
fmt
.
Errorf
(
"pod
%v was already in added state.
"
,
key
)
}
}
return
nil
return
nil
}
}
...
@@ -284,7 +284,7 @@ func (cache *schedulerCache) UpdatePod(oldPod, newPod *v1.Pod) error {
...
@@ -284,7 +284,7 @@ func (cache *schedulerCache) UpdatePod(oldPod, newPod *v1.Pod) error {
return
err
return
err
}
}
default
:
default
:
return
fmt
.
Errorf
(
"pod %v
state wasn't added but get
updated"
,
key
)
return
fmt
.
Errorf
(
"pod %v
is not added to scheduler cache, so cannot be
updated"
,
key
)
}
}
return
nil
return
nil
}
}
...
@@ -304,7 +304,7 @@ func (cache *schedulerCache) RemovePod(pod *v1.Pod) error {
...
@@ -304,7 +304,7 @@ func (cache *schedulerCache) RemovePod(pod *v1.Pod) error {
// before Remove event, in which case the state would change from Assumed to Added.
// before Remove event, in which case the state would change from Assumed to Added.
case
ok
&&
!
cache
.
assumedPods
[
key
]
:
case
ok
&&
!
cache
.
assumedPods
[
key
]
:
if
currState
.
pod
.
Spec
.
NodeName
!=
pod
.
Spec
.
NodeName
{
if
currState
.
pod
.
Spec
.
NodeName
!=
pod
.
Spec
.
NodeName
{
glog
.
Errorf
(
"Pod %v
removed from a different node than previously added to."
,
key
)
glog
.
Errorf
(
"Pod %v
was assumed to be on %v but got added to %v"
,
key
,
pod
.
Spec
.
NodeName
,
currState
.
pod
.
Spec
.
NodeName
)
glog
.
Fatalf
(
"Schedulercache is corrupted and can badly affect scheduling decisions"
)
glog
.
Fatalf
(
"Schedulercache is corrupted and can badly affect scheduling decisions"
)
}
}
err
:=
cache
.
removePod
(
currState
.
pod
)
err
:=
cache
.
removePod
(
currState
.
pod
)
...
@@ -313,7 +313,7 @@ func (cache *schedulerCache) RemovePod(pod *v1.Pod) error {
...
@@ -313,7 +313,7 @@ func (cache *schedulerCache) RemovePod(pod *v1.Pod) error {
}
}
delete
(
cache
.
podStates
,
key
)
delete
(
cache
.
podStates
,
key
)
default
:
default
:
return
fmt
.
Errorf
(
"pod
state wasn't added but get removed. Pod key: %v
"
,
key
)
return
fmt
.
Errorf
(
"pod
%v is not found in scheduler cache, so cannot be removed from it
"
,
key
)
}
}
return
nil
return
nil
}
}
...
@@ -345,7 +345,7 @@ func (cache *schedulerCache) GetPod(pod *v1.Pod) (*v1.Pod, error) {
...
@@ -345,7 +345,7 @@ func (cache *schedulerCache) GetPod(pod *v1.Pod) (*v1.Pod, error) {
podState
,
ok
:=
cache
.
podStates
[
key
]
podState
,
ok
:=
cache
.
podStates
[
key
]
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"pod %v does not exist"
,
key
)
return
nil
,
fmt
.
Errorf
(
"pod %v does not exist
in scheduler cache
"
,
key
)
}
}
return
podState
.
pod
,
nil
return
podState
.
pod
,
nil
...
...
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