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
d6f5dd7c
Commit
d6f5dd7c
authored
Jan 13, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3389 from ddysher/update-scheduler
Filter out unhealthy node in scheduler
parents
82d8ae74
153dbd30
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
10 deletions
+129
-10
factory.go
plugin/pkg/scheduler/factory/factory.go
+32
-5
factory_test.go
plugin/pkg/scheduler/factory/factory_test.go
+97
-5
No files found.
plugin/pkg/scheduler/factory/factory.go
View file @
d6f5dd7c
...
@@ -99,7 +99,8 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys util.StringSe
...
@@ -99,7 +99,8 @@ func (f *ConfigFactory) CreateFromKeys(predicateKeys, priorityKeys util.StringSe
// Watch minions.
// Watch minions.
// Minions may be listed frequently, so provide a local up-to-date cache.
// Minions may be listed frequently, so provide a local up-to-date cache.
if
false
{
if
false
{
// Disable this code until minions support watches.
// Disable this code until minions support watches. Note when this code is enabled,
// we need to make sure minion ListWatcher has proper FieldSelector.
cache
.
NewReflector
(
f
.
createMinionLW
(),
&
api
.
Node
{},
f
.
MinionLister
.
Store
)
.
Run
()
cache
.
NewReflector
(
f
.
createMinionLW
(),
&
api
.
Node
{},
f
.
MinionLister
.
Store
)
.
Run
()
}
else
{
}
else
{
cache
.
NewPoller
(
f
.
pollMinions
,
10
*
time
.
Second
,
f
.
MinionLister
.
Store
)
.
Run
()
cache
.
NewPoller
(
f
.
pollMinions
,
10
*
time
.
Second
,
f
.
MinionLister
.
Store
)
.
Run
()
...
@@ -168,14 +169,40 @@ func (factory *ConfigFactory) createMinionLW() *cache.ListWatch {
...
@@ -168,14 +169,40 @@ func (factory *ConfigFactory) createMinionLW() *cache.ListWatch {
}
}
}
}
// pollMinions lists all minions and returns an enumerator for cache.Poller.
// pollMinions lists all minions and filter out unhealthy ones, then returns
// an enumerator for cache.Poller.
func
(
factory
*
ConfigFactory
)
pollMinions
()
(
cache
.
Enumerator
,
error
)
{
func
(
factory
*
ConfigFactory
)
pollMinions
()
(
cache
.
Enumerator
,
error
)
{
list
:=
&
api
.
NodeList
{}
allNodes
:=
&
api
.
NodeList
{}
err
:=
factory
.
Client
.
Get
()
.
Resource
(
"minions"
)
.
Do
()
.
Into
(
list
)
err
:=
factory
.
Client
.
Get
()
.
Resource
(
"minions"
)
.
Do
()
.
Into
(
allNodes
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
&
nodeEnumerator
{
list
},
nil
nodes
:=
&
api
.
NodeList
{
TypeMeta
:
allNodes
.
TypeMeta
,
ListMeta
:
allNodes
.
ListMeta
,
}
for
_
,
node
:=
range
allNodes
.
Items
{
conditionMap
:=
make
(
map
[
api
.
NodeConditionKind
]
*
api
.
NodeCondition
)
for
i
:=
range
node
.
Status
.
Conditions
{
cond
:=
node
.
Status
.
Conditions
[
i
]
conditionMap
[
cond
.
Kind
]
=
&
cond
}
if
condition
,
ok
:=
conditionMap
[
api
.
NodeReady
];
ok
{
if
condition
.
Status
==
api
.
ConditionFull
{
nodes
.
Items
=
append
(
nodes
.
Items
,
node
)
}
}
else
if
condition
,
ok
:=
conditionMap
[
api
.
NodeReachable
];
ok
{
if
condition
.
Status
==
api
.
ConditionFull
{
nodes
.
Items
=
append
(
nodes
.
Items
,
node
)
}
}
else
{
// If no condition is set, either node health check is disabled (master
// flag "healthCheckMinions" is set to false), or we get unknown condition.
// In such cases, we add nodes unconditionally.
nodes
.
Items
=
append
(
nodes
.
Items
,
node
)
}
}
return
&
nodeEnumerator
{
nodes
},
nil
}
}
func
(
factory
*
ConfigFactory
)
makeDefaultErrorFunc
(
backoff
*
podBackoff
,
podQueue
*
cache
.
FIFO
)
func
(
pod
*
api
.
Pod
,
err
error
)
{
func
(
factory
*
ConfigFactory
)
makeDefaultErrorFunc
(
backoff
*
podBackoff
,
podQueue
*
cache
.
FIFO
)
func
(
pod
*
api
.
Pod
,
err
error
)
{
...
...
plugin/pkg/scheduler/factory/factory_test.go
View file @
d6f5dd7c
...
@@ -48,13 +48,105 @@ func TestCreate(t *testing.T) {
...
@@ -48,13 +48,105 @@ func TestCreate(t *testing.T) {
func
TestPollMinions
(
t
*
testing
.
T
)
{
func
TestPollMinions
(
t
*
testing
.
T
)
{
table
:=
[]
struct
{
table
:=
[]
struct
{
minions
[]
api
.
Node
minions
[]
api
.
Node
expectedCount
int
}{
}{
{
{
minions
:
[]
api
.
Node
{
minions
:
[]
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
}},
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
}},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{
{
Kind
:
api
.
NodeReady
,
Status
:
api
.
ConditionFull
},
},
},
},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{
{
Kind
:
api
.
NodeReachable
,
Status
:
api
.
ConditionFull
},
},
},
},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"baz"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{
{
Kind
:
api
.
NodeReady
,
Status
:
api
.
ConditionFull
},
{
Kind
:
api
.
NodeReachable
,
Status
:
api
.
ConditionFull
},
},
},
},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"baz"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{
{
Kind
:
api
.
NodeReady
,
Status
:
api
.
ConditionFull
},
{
Kind
:
api
.
NodeReady
,
Status
:
api
.
ConditionFull
},
},
},
},
},
},
expectedCount
:
4
,
},
{
minions
:
[]
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{
{
Kind
:
api
.
NodeReady
,
Status
:
api
.
ConditionFull
},
},
},
},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"bar"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{
{
Kind
:
api
.
NodeReady
,
Status
:
api
.
ConditionNone
},
},
},
},
},
expectedCount
:
1
,
},
{
minions
:
[]
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{
{
Kind
:
api
.
NodeReady
,
Status
:
api
.
ConditionFull
},
{
Kind
:
api
.
NodeReachable
,
Status
:
api
.
ConditionNone
}},
},
},
},
expectedCount
:
1
,
},
{
minions
:
[]
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{
{
Kind
:
api
.
NodeReachable
,
Status
:
api
.
ConditionFull
},
{
Kind
:
"invalidValue"
,
Status
:
api
.
ConditionNone
}},
},
},
},
expectedCount
:
1
,
},
{
minions
:
[]
api
.
Node
{
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
},
Status
:
api
.
NodeStatus
{
Conditions
:
[]
api
.
NodeCondition
{},
},
},
},
expectedCount
:
1
,
},
},
}
}
...
@@ -80,8 +172,8 @@ func TestPollMinions(t *testing.T) {
...
@@ -80,8 +172,8 @@ func TestPollMinions(t *testing.T) {
}
}
handler
.
ValidateRequest
(
t
,
"/api/"
+
testapi
.
Version
()
+
"/minions"
,
"GET"
,
nil
)
handler
.
ValidateRequest
(
t
,
"/api/"
+
testapi
.
Version
()
+
"/minions"
,
"GET"
,
nil
)
if
e
,
a
:=
len
(
item
.
minions
),
ce
.
Len
();
e
!=
a
{
if
a
:=
ce
.
Len
();
item
.
expectedCount
!=
a
{
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"Expected %v, got %v"
,
item
.
expectedCount
,
a
)
}
}
}
}
}
}
...
...
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