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
e3537425
Commit
e3537425
authored
Jul 26, 2017
by
sakeven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getHashEquivalencePod also returns if equivalence pod is found
Signed-off-by:
sakeven
<
jc5930@sina.cn
>
parent
fc89743d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
15 deletions
+14
-15
equivalence_cache.go
plugin/pkg/scheduler/core/equivalence_cache.go
+6
-5
equivalence_cache_test.go
plugin/pkg/scheduler/core/equivalence_cache_test.go
+7
-8
generic_scheduler.go
plugin/pkg/scheduler/core/generic_scheduler.go
+1
-2
No files found.
plugin/pkg/scheduler/core/equivalence_cache.go
View file @
e3537425
...
@@ -51,7 +51,7 @@ func newAlgorithmCache() AlgorithmCache {
...
@@ -51,7 +51,7 @@ func newAlgorithmCache() AlgorithmCache {
}
}
}
}
//
Store
a map of predicate cache with maxsize
//
EquivalenceCache stores
a map of predicate cache with maxsize
type
EquivalenceCache
struct
{
type
EquivalenceCache
struct
{
sync
.
RWMutex
sync
.
RWMutex
getEquivalencePod
algorithm
.
GetEquivalencePodFunc
getEquivalencePod
algorithm
.
GetEquivalencePodFunc
...
@@ -179,13 +179,14 @@ func (ec *EquivalenceCache) InvalidateCachedPredicateItemForPodAdd(pod *v1.Pod,
...
@@ -179,13 +179,14 @@ func (ec *EquivalenceCache) InvalidateCachedPredicateItemForPodAdd(pod *v1.Pod,
}
}
// getHashEquivalencePod returns the hash of equivalence pod.
// getHashEquivalencePod returns the hash of equivalence pod.
// if no equivalence pod found, return 0
// 1. equivalenceHash
func
(
ec
*
EquivalenceCache
)
getHashEquivalencePod
(
pod
*
v1
.
Pod
)
uint64
{
// 2. if equivalence pod is found
func
(
ec
*
EquivalenceCache
)
getHashEquivalencePod
(
pod
*
v1
.
Pod
)
(
uint64
,
bool
)
{
equivalencePod
:=
ec
.
getEquivalencePod
(
pod
)
equivalencePod
:=
ec
.
getEquivalencePod
(
pod
)
if
equivalencePod
!=
nil
{
if
equivalencePod
!=
nil
{
hash
:=
fnv
.
New32a
()
hash
:=
fnv
.
New32a
()
hashutil
.
DeepHashObject
(
hash
,
equivalencePod
)
hashutil
.
DeepHashObject
(
hash
,
equivalencePod
)
return
uint64
(
hash
.
Sum32
())
return
uint64
(
hash
.
Sum32
())
,
true
}
}
return
0
return
0
,
false
}
}
plugin/pkg/scheduler/core/equivalence_cache_test.go
View file @
e3537425
...
@@ -287,9 +287,9 @@ func TestGetHashEquivalencePod(t *testing.T) {
...
@@ -287,9 +287,9 @@ func TestGetHashEquivalencePod(t *testing.T) {
},
},
}
}
hash1
:=
ecache
.
getHashEquivalencePod
(
pod1
)
hash1
,
_
:=
ecache
.
getHashEquivalencePod
(
pod1
)
hash2
:=
ecache
.
getHashEquivalencePod
(
pod2
)
hash2
,
_
:=
ecache
.
getHashEquivalencePod
(
pod2
)
hash3
:=
ecache
.
getHashEquivalencePod
(
pod3
)
hash3
,
_
:=
ecache
.
getHashEquivalencePod
(
pod3
)
if
hash1
!=
hash2
{
if
hash1
!=
hash2
{
t
.
Errorf
(
"Failed: pod %v and %v is expected to be equivalent"
,
pod1
.
Name
,
pod2
.
Name
)
t
.
Errorf
(
"Failed: pod %v and %v is expected to be equivalent"
,
pod1
.
Name
,
pod2
.
Name
)
...
@@ -305,11 +305,10 @@ func TestGetHashEquivalencePod(t *testing.T) {
...
@@ -305,11 +305,10 @@ func TestGetHashEquivalencePod(t *testing.T) {
Name
:
"pod4"
,
Name
:
"pod4"
,
},
},
}
}
hash4
:=
ecache
.
getHashEquivalencePod
(
pod4
)
_
,
found
:=
ecache
.
getHashEquivalencePod
(
pod4
)
if
found
{
if
hash4
!=
0
{
t
.
Errorf
(
"Failed: equivalence hash of pod %v is not expected to be found, but got: %v"
,
t
.
Errorf
(
"Failed: equivalence hash of pod %v is expected to be: 0, but got: %v"
,
pod4
.
Name
,
found
)
pod4
.
Name
,
hash4
)
}
}
}
}
...
...
plugin/pkg/scheduler/core/generic_scheduler.go
View file @
e3537425
...
@@ -244,8 +244,7 @@ func podFitsOnNode(pod *v1.Pod, meta interface{}, info *schedulercache.NodeInfo,
...
@@ -244,8 +244,7 @@ func podFitsOnNode(pod *v1.Pod, meta interface{}, info *schedulercache.NodeInfo,
)
)
if
ecache
!=
nil
{
if
ecache
!=
nil
{
// getHashEquivalencePod will return immediately if no equivalence pod found
// getHashEquivalencePod will return immediately if no equivalence pod found
equivalenceHash
=
ecache
.
getHashEquivalencePod
(
pod
)
equivalenceHash
,
eCacheAvailable
=
ecache
.
getHashEquivalencePod
(
pod
)
eCacheAvailable
=
(
equivalenceHash
!=
0
)
}
}
for
predicateKey
,
predicate
:=
range
predicateFuncs
{
for
predicateKey
,
predicate
:=
range
predicateFuncs
{
// If equivalenceCache is available
// If equivalenceCache is available
...
...
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