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
fd600ab6
Commit
fd600ab6
authored
Jul 12, 2016
by
gmarek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hooks for cluster health detection
parent
ea70eca3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
131 additions
and
98 deletions
+131
-98
controller_utils.go
pkg/controller/node/controller_utils.go
+14
-11
nodecontroller.go
pkg/controller/node/nodecontroller.go
+92
-64
node.go
pkg/util/node/node.go
+22
-0
selector_spreading.go
.../pkg/scheduler/algorithm/priorities/selector_spreading.go
+3
-23
No files found.
pkg/controller/node/
deletion
_utils.go
→
pkg/controller/node/
controller
_utils.go
View file @
fd600ab6
...
@@ -22,7 +22,6 @@ import (
...
@@ -22,7 +22,6 @@ import (
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/cache"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/record"
"k8s.io/kubernetes/pkg/client/record"
...
@@ -36,6 +35,20 @@ import (
...
@@ -36,6 +35,20 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
)
)
// This function is expected to get a slice of NodeReadyConditions for all Nodes in a given zone.
func
ComputeZoneState
(
nodeReadyConditions
[]
*
api
.
NodeCondition
)
zoneState
{
seenReady
:=
false
for
i
:=
range
nodeReadyConditions
{
if
nodeReadyConditions
[
i
]
!=
nil
&&
nodeReadyConditions
[
i
]
.
Status
==
api
.
ConditionTrue
{
seenReady
=
true
}
}
if
seenReady
{
return
stateNormal
}
return
stateFullSegmentation
}
// cleanupOrphanedPods deletes pods that are bound to nodes that don't
// cleanupOrphanedPods deletes pods that are bound to nodes that don't
// exist.
// exist.
func
cleanupOrphanedPods
(
pods
[]
*
api
.
Pod
,
nodeStore
cache
.
Store
,
forcefulDeletePodFunc
func
(
*
api
.
Pod
)
error
)
{
func
cleanupOrphanedPods
(
pods
[]
*
api
.
Pod
,
nodeStore
cache
.
Store
,
forcefulDeletePodFunc
func
(
*
api
.
Pod
)
error
)
{
...
@@ -124,16 +137,6 @@ func forcefullyDeleteNode(kubeClient clientset.Interface, nodeName string, force
...
@@ -124,16 +137,6 @@ func forcefullyDeleteNode(kubeClient clientset.Interface, nodeName string, force
return
nil
return
nil
}
}
// forceUpdateAllProbeTimes bumps all observed timestamps in saved nodeStatuses to now. This makes
// all eviction timer to reset.
func
forceUpdateAllProbeTimes
(
now
unversioned
.
Time
,
statusData
map
[
string
]
nodeStatusData
)
{
for
k
,
v
:=
range
statusData
{
v
.
probeTimestamp
=
now
v
.
readyTransitionTimestamp
=
now
statusData
[
k
]
=
v
}
}
// maybeDeleteTerminatingPod non-gracefully deletes pods that are terminating
// maybeDeleteTerminatingPod non-gracefully deletes pods that are terminating
// that should not be gracefully terminated.
// that should not be gracefully terminated.
func
(
nc
*
NodeController
)
maybeDeleteTerminatingPod
(
obj
interface
{},
nodeStore
cache
.
Store
,
forcefulDeletePodFunc
func
(
*
api
.
Pod
)
error
)
{
func
(
nc
*
NodeController
)
maybeDeleteTerminatingPod
(
obj
interface
{},
nodeStore
cache
.
Store
,
forcefulDeletePodFunc
func
(
*
api
.
Pod
)
error
)
{
...
...
pkg/controller/node/nodecontroller.go
View file @
fd600ab6
This diff is collapsed.
Click to expand it.
pkg/util/node/node.go
View file @
fd600ab6
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
)
)
func
GetHostname
(
hostnameOverride
string
)
string
{
func
GetHostname
(
hostnameOverride
string
)
string
{
...
@@ -59,3 +60,24 @@ func GetNodeHostIP(node *api.Node) (net.IP, error) {
...
@@ -59,3 +60,24 @@ func GetNodeHostIP(node *api.Node) (net.IP, error) {
}
}
return
nil
,
fmt
.
Errorf
(
"host IP unknown; known addresses: %v"
,
addresses
)
return
nil
,
fmt
.
Errorf
(
"host IP unknown; known addresses: %v"
,
addresses
)
}
}
// Helper function that builds a string identifier that is unique per failure-zone
// Returns empty-string for no zone
func
GetZoneKey
(
node
*
api
.
Node
)
string
{
labels
:=
node
.
Labels
if
labels
==
nil
{
return
""
}
region
,
_
:=
labels
[
unversioned
.
LabelZoneRegion
]
failureDomain
,
_
:=
labels
[
unversioned
.
LabelZoneFailureDomain
]
if
region
==
""
&&
failureDomain
==
""
{
return
""
}
// We include the null character just in case region or failureDomain has a colon
// (We do assume there's no null characters in a region or failureDomain)
// As a nice side-benefit, the null character is not printed by fmt.Print or glog
return
region
+
":
\x00
:"
+
failureDomain
}
plugin/pkg/scheduler/algorithm/priorities/selector_spreading.go
View file @
fd600ab6
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/labels"
utilnode
"k8s.io/kubernetes/pkg/util/node"
utilruntime
"k8s.io/kubernetes/pkg/util/runtime"
utilruntime
"k8s.io/kubernetes/pkg/util/runtime"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
schedulerapi
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
schedulerapi
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
...
@@ -54,27 +55,6 @@ func NewSelectorSpreadPriority(podLister algorithm.PodLister, serviceLister algo
...
@@ -54,27 +55,6 @@ func NewSelectorSpreadPriority(podLister algorithm.PodLister, serviceLister algo
return
selectorSpread
.
CalculateSpreadPriority
return
selectorSpread
.
CalculateSpreadPriority
}
}
// Helper function that builds a string identifier that is unique per failure-zone
// Returns empty-string for no zone
func
getZoneKey
(
node
*
api
.
Node
)
string
{
labels
:=
node
.
Labels
if
labels
==
nil
{
return
""
}
region
,
_
:=
labels
[
unversioned
.
LabelZoneRegion
]
failureDomain
,
_
:=
labels
[
unversioned
.
LabelZoneFailureDomain
]
if
region
==
""
&&
failureDomain
==
""
{
return
""
}
// We include the null character just in case region or failureDomain has a colon
// (We do assume there's no null characters in a region or failureDomain)
// As a nice side-benefit, the null character is not printed by fmt.Print or glog
return
region
+
":
\x00
:"
+
failureDomain
}
// CalculateSpreadPriority spreads pods across hosts and zones, considering pods belonging to the same service or replication controller.
// CalculateSpreadPriority spreads pods across hosts and zones, considering pods belonging to the same service or replication controller.
// When a pod is scheduled, it looks for services or RCs that match the pod, then finds existing pods that match those selectors.
// When a pod is scheduled, it looks for services or RCs that match the pod, then finds existing pods that match those selectors.
// It favors nodes that have fewer existing matching pods.
// It favors nodes that have fewer existing matching pods.
...
@@ -189,7 +169,7 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
...
@@ -189,7 +169,7 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
continue
continue
}
}
zoneId
:=
g
etZoneKey
(
node
)
zoneId
:=
utilnode
.
G
etZoneKey
(
node
)
if
zoneId
==
""
{
if
zoneId
==
""
{
continue
continue
}
}
...
@@ -220,7 +200,7 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
...
@@ -220,7 +200,7 @@ func (s *SelectorSpread) CalculateSpreadPriority(pod *api.Pod, nodeNameToInfo ma
// If there is zone information present, incorporate it
// If there is zone information present, incorporate it
if
haveZones
{
if
haveZones
{
zoneId
:=
g
etZoneKey
(
node
)
zoneId
:=
utilnode
.
G
etZoneKey
(
node
)
if
zoneId
!=
""
{
if
zoneId
!=
""
{
zoneScore
:=
maxPriority
*
(
float32
(
maxCountByZone
-
countsByZone
[
zoneId
])
/
float32
(
maxCountByZone
))
zoneScore
:=
maxPriority
*
(
float32
(
maxCountByZone
-
countsByZone
[
zoneId
])
/
float32
(
maxCountByZone
))
fScore
=
(
fScore
*
(
1.0
-
zoneWeighting
))
+
(
zoneWeighting
*
zoneScore
)
fScore
=
(
fScore
*
(
1.0
-
zoneWeighting
))
+
(
zoneWeighting
*
zoneScore
)
...
...
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