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
2d9c6dfa
Commit
2d9c6dfa
authored
Aug 03, 2017
by
Julia Evans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle errors more consistently in scheduler
parent
f189d7f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
scheduler.go
plugin/pkg/scheduler/scheduler.go
+18
-12
No files found.
plugin/pkg/scheduler/scheduler.go
View file @
2d9c6dfa
...
@@ -17,7 +17,6 @@ limitations under the License.
...
@@ -17,7 +17,6 @@ limitations under the License.
package
scheduler
package
scheduler
import
(
import
(
"fmt"
"time"
"time"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
...
@@ -194,12 +193,20 @@ func (sched *Scheduler) assume(assumed *v1.Pod, host string) error {
...
@@ -194,12 +193,20 @@ func (sched *Scheduler) assume(assumed *v1.Pod, host string) error {
assumed
.
Spec
.
NodeName
=
host
assumed
.
Spec
.
NodeName
=
host
if
err
:=
sched
.
config
.
SchedulerCache
.
AssumePod
(
assumed
);
err
!=
nil
{
if
err
:=
sched
.
config
.
SchedulerCache
.
AssumePod
(
assumed
);
err
!=
nil
{
glog
.
Errorf
(
"scheduler cache AssumePod failed: %v"
,
err
)
glog
.
Errorf
(
"scheduler cache AssumePod failed: %v"
,
err
)
// TODO: This means that a given pod is already in cache (which means it
// is either assumed or already added). This is most probably result of a
// This is most probably result of a BUG in retrying logic.
// BUG in retrying logic. As a temporary workaround (which doesn't fully
// We report an error here so that pod scheduling can be retried.
// fix the problem, but should reduce its impact), we simply return here,
// This relies on the fact that Error will check if the pod has been bound
// as binding doesn't make sense anyway.
// to a node and if so will not add it back to the unscheduled pods queue
// This should be fixed properly though.
// (otherwise this would cause an infinite loop).
sched
.
config
.
Error
(
assumed
,
err
)
sched
.
config
.
Recorder
.
Eventf
(
assumed
,
v1
.
EventTypeWarning
,
"FailedScheduling"
,
"AssumePod failed: %v"
,
err
)
sched
.
config
.
PodConditionUpdater
.
Update
(
assumed
,
&
v1
.
PodCondition
{
Type
:
v1
.
PodScheduled
,
Status
:
v1
.
ConditionFalse
,
Reason
:
"SchedulerError"
,
Message
:
err
.
Error
(),
})
return
err
return
err
}
}
...
@@ -219,10 +226,13 @@ func (sched *Scheduler) bind(assumed *v1.Pod, b *v1.Binding) error {
...
@@ -219,10 +226,13 @@ func (sched *Scheduler) bind(assumed *v1.Pod, b *v1.Binding) error {
// If binding succeeded then PodScheduled condition will be updated in apiserver so that
// If binding succeeded then PodScheduled condition will be updated in apiserver so that
// it's atomic with setting host.
// it's atomic with setting host.
err
:=
sched
.
config
.
Binder
.
Bind
(
b
)
err
:=
sched
.
config
.
Binder
.
Bind
(
b
)
if
err
:=
sched
.
config
.
SchedulerCache
.
FinishBinding
(
assumed
);
err
!=
nil
{
glog
.
Errorf
(
"scheduler cache FinishBinding failed: %v"
,
err
)
}
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
1
)
.
Infof
(
"Failed to bind pod: %v/%v"
,
assumed
.
Namespace
,
assumed
.
Name
)
glog
.
V
(
1
)
.
Infof
(
"Failed to bind pod: %v/%v"
,
assumed
.
Namespace
,
assumed
.
Name
)
if
err
:=
sched
.
config
.
SchedulerCache
.
ForgetPod
(
assumed
);
err
!=
nil
{
if
err
:=
sched
.
config
.
SchedulerCache
.
ForgetPod
(
assumed
);
err
!=
nil
{
return
fmt
.
Errorf
(
"scheduler cache ForgetPod failed: %v"
,
err
)
glog
.
Errorf
(
"scheduler cache ForgetPod failed: %v"
,
err
)
}
}
sched
.
config
.
Error
(
assumed
,
err
)
sched
.
config
.
Error
(
assumed
,
err
)
sched
.
config
.
Recorder
.
Eventf
(
assumed
,
v1
.
EventTypeWarning
,
"FailedScheduling"
,
"Binding rejected: %v"
,
err
)
sched
.
config
.
Recorder
.
Eventf
(
assumed
,
v1
.
EventTypeWarning
,
"FailedScheduling"
,
"Binding rejected: %v"
,
err
)
...
@@ -234,10 +244,6 @@ func (sched *Scheduler) bind(assumed *v1.Pod, b *v1.Binding) error {
...
@@ -234,10 +244,6 @@ func (sched *Scheduler) bind(assumed *v1.Pod, b *v1.Binding) error {
return
err
return
err
}
}
if
err
:=
sched
.
config
.
SchedulerCache
.
FinishBinding
(
assumed
);
err
!=
nil
{
return
fmt
.
Errorf
(
"scheduler cache FinishBinding failed: %v"
,
err
)
}
metrics
.
BindingLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
bindingStart
))
metrics
.
BindingLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
bindingStart
))
sched
.
config
.
Recorder
.
Eventf
(
assumed
,
v1
.
EventTypeNormal
,
"Scheduled"
,
"Successfully assigned %v to %v"
,
assumed
.
Name
,
b
.
Target
.
Name
)
sched
.
config
.
Recorder
.
Eventf
(
assumed
,
v1
.
EventTypeNormal
,
"Scheduled"
,
"Successfully assigned %v to %v"
,
assumed
.
Name
,
b
.
Target
.
Name
)
return
nil
return
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