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
82e02cc9
Commit
82e02cc9
authored
Oct 10, 2017
by
wenlxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix inter-pod anti-affinity issue
parent
6c081c3d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
13 deletions
+25
-13
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+5
-1
BUILD
plugin/pkg/scheduler/algorithm/priorities/BUILD
+1
-0
interpod_affinity.go
...n/pkg/scheduler/algorithm/priorities/interpod_affinity.go
+19
-12
No files found.
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
82e02cc9
...
...
@@ -96,7 +96,7 @@ func (c *CachedNodeInfo) GetNodeInfo(id string) (*v1.Node, error) {
node
,
err
:=
c
.
Get
(
id
)
if
apierrors
.
IsNotFound
(
err
)
{
return
nil
,
fmt
.
Errorf
(
"node '%v' not found"
,
id
)
return
nil
,
err
}
if
err
!=
nil
{
...
...
@@ -1125,6 +1125,10 @@ func (c *PodAffinityChecker) getMatchingAntiAffinityTerms(pod *v1.Pod, allPods [
if
affinity
!=
nil
&&
affinity
.
PodAntiAffinity
!=
nil
{
existingPodNode
,
err
:=
c
.
info
.
GetNodeInfo
(
existingPod
.
Spec
.
NodeName
)
if
err
!=
nil
{
if
apierrors
.
IsNotFound
(
err
)
{
glog
.
Errorf
(
"Node not found, %v"
,
existingPod
.
Spec
.
NodeName
)
continue
}
return
nil
,
err
}
existingPodMatchingTerms
,
err
:=
getMatchingAntiAffinityTermsOfExistingPod
(
pod
,
existingPod
,
existingPodNode
)
...
...
plugin/pkg/scheduler/algorithm/priorities/BUILD
View file @
82e02cc9
...
...
@@ -33,6 +33,7 @@ go_library(
"//plugin/pkg/scheduler/schedulercache:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
...
...
plugin/pkg/scheduler/algorithm/priorities/interpod_affinity.go
View file @
82e02cc9
...
...
@@ -21,6 +21,7 @@ import (
"sync"
"k8s.io/api/core/v1"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/util/workqueue"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
...
...
@@ -137,6 +138,10 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *v1.Pod, node
processPod
:=
func
(
existingPod
*
v1
.
Pod
)
error
{
existingPodNode
,
err
:=
ipa
.
info
.
GetNodeInfo
(
existingPod
.
Spec
.
NodeName
)
if
err
!=
nil
{
if
apierrors
.
IsNotFound
(
err
)
{
glog
.
Errorf
(
"Node not found, %v"
,
existingPod
.
Spec
.
NodeName
)
return
nil
}
return
err
}
existingPodAffinity
:=
existingPod
.
Spec
.
Affinity
...
...
@@ -189,19 +194,21 @@ func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *v1.Pod, node
}
processNode
:=
func
(
i
int
)
{
nodeInfo
:=
nodeNameToInfo
[
allNodeNames
[
i
]]
if
hasAffinityConstraints
||
hasAntiAffinityConstraints
{
// We need to process all the nodes.
for
_
,
existingPod
:=
range
nodeInfo
.
Pods
()
{
if
err
:=
processPod
(
existingPod
);
err
!=
nil
{
pm
.
setError
(
err
)
if
nodeInfo
.
Node
()
!=
nil
{
if
hasAffinityConstraints
||
hasAntiAffinityConstraints
{
// We need to process all the nodes.
for
_
,
existingPod
:=
range
nodeInfo
.
Pods
()
{
if
err
:=
processPod
(
existingPod
);
err
!=
nil
{
pm
.
setError
(
err
)
}
}
}
}
else
{
// The pod doesn't have any constraints - we need to check only existing
// ones that have some.
for
_
,
existingPod
:=
range
nodeInfo
.
PodsWithAffinity
()
{
if
err
:=
processPod
(
existingPod
);
err
!=
nil
{
pm
.
setError
(
err
)
}
else
{
// The pod doesn't have any constraints - we need to check only existing
// ones that have some.
for
_
,
existingPod
:=
range
nodeInfo
.
PodsWithAffinity
()
{
if
err
:=
processPod
(
existingPod
);
err
!=
nil
{
pm
.
setError
(
err
)
}
}
}
}
...
...
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