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
8b720ffa
Commit
8b720ffa
authored
Sep 21, 2016
by
jianhuiz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix planner loop ends before finishing replica assignments
parent
295b4eee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
4 deletions
+37
-4
planner.go
...n/pkg/federation-controller/replicaset/planner/planner.go
+1
-4
planner_test.go
.../federation-controller/replicaset/planner/planner_test.go
+36
-0
No files found.
federation/pkg/federation-controller/replicaset/planner/planner.go
View file @
8b720ffa
...
@@ -18,7 +18,6 @@ package planer
...
@@ -18,7 +18,6 @@ package planer
import
(
import
(
"hash/fnv"
"hash/fnv"
"math"
"sort"
"sort"
fed_api
"k8s.io/kubernetes/federation/apis/federation"
fed_api
"k8s.io/kubernetes/federation/apis/federation"
...
@@ -152,9 +151,7 @@ func (p *Planner) Plan(replicasToDistribute int64, availableClusters []string, c
...
@@ -152,9 +151,7 @@ func (p *Planner) Plan(replicasToDistribute int64, availableClusters []string, c
// TODO: Prove that clusterCount * log(replicas) iterations solves the problem or adjust the number.
// TODO: Prove that clusterCount * log(replicas) iterations solves the problem or adjust the number.
// TODO: This algorithm is O(clusterCount^2 * log(replicas)) which is good for up to 100 clusters.
// TODO: This algorithm is O(clusterCount^2 * log(replicas)) which is good for up to 100 clusters.
// Find something faster.
// Find something faster.
replicasAtStart
:=
remainingReplicas
for
trial
:=
0
;
modified
&&
remainingReplicas
>
0
;
trial
++
{
for
trial
:=
0
;
trial
<
int
(
2
*
(
1
+
math
.
Log
(
float64
(
replicasAtStart
)))
*
float64
(
len
(
availableClusters
)))
&&
modified
&&
remainingReplicas
>
0
;
trial
++
{
modified
=
false
modified
=
false
weightSum
:=
int64
(
0
)
weightSum
:=
int64
(
0
)
...
...
federation/pkg/federation-controller/replicaset/planner/planner_test.go
View file @
8b720ffa
...
@@ -111,6 +111,42 @@ func TestEqualWithExisting(t *testing.T) {
...
@@ -111,6 +111,42 @@ func TestEqualWithExisting(t *testing.T) {
doCheckWithExisting
(
t
,
map
[
string
]
fed_api
.
ClusterReplicaSetPreferences
{
doCheckWithExisting
(
t
,
map
[
string
]
fed_api
.
ClusterReplicaSetPreferences
{
"*"
:
{
Weight
:
1
}},
"*"
:
{
Weight
:
1
}},
15
,
[]
string
{
"A"
,
"B"
},
map
[
string
]
int64
{
"A"
:
0
,
"B"
:
8
},
map
[
string
]
int64
{
"A"
:
7
,
"B"
:
8
})
doCheckWithExisting
(
t
,
map
[
string
]
fed_api
.
ClusterReplicaSetPreferences
{
"*"
:
{
Weight
:
1
}},
15
,
[]
string
{
"A"
,
"B"
},
map
[
string
]
int64
{
"A"
:
1
,
"B"
:
8
},
map
[
string
]
int64
{
"A"
:
7
,
"B"
:
8
})
doCheckWithExisting
(
t
,
map
[
string
]
fed_api
.
ClusterReplicaSetPreferences
{
"*"
:
{
Weight
:
1
}},
15
,
[]
string
{
"A"
,
"B"
},
map
[
string
]
int64
{
"A"
:
4
,
"B"
:
8
},
map
[
string
]
int64
{
"A"
:
7
,
"B"
:
8
})
doCheckWithExisting
(
t
,
map
[
string
]
fed_api
.
ClusterReplicaSetPreferences
{
"*"
:
{
Weight
:
1
}},
15
,
[]
string
{
"A"
,
"B"
},
map
[
string
]
int64
{
"A"
:
5
,
"B"
:
8
},
map
[
string
]
int64
{
"A"
:
7
,
"B"
:
8
})
doCheckWithExisting
(
t
,
map
[
string
]
fed_api
.
ClusterReplicaSetPreferences
{
"*"
:
{
Weight
:
1
}},
15
,
[]
string
{
"A"
,
"B"
},
map
[
string
]
int64
{
"A"
:
6
,
"B"
:
8
},
map
[
string
]
int64
{
"A"
:
7
,
"B"
:
8
})
doCheckWithExisting
(
t
,
map
[
string
]
fed_api
.
ClusterReplicaSetPreferences
{
"*"
:
{
Weight
:
1
}},
15
,
[]
string
{
"A"
,
"B"
},
map
[
string
]
int64
{
"A"
:
7
,
"B"
:
8
},
map
[
string
]
int64
{
"A"
:
7
,
"B"
:
8
})
doCheckWithExisting
(
t
,
map
[
string
]
fed_api
.
ClusterReplicaSetPreferences
{
"*"
:
{
Weight
:
1
}},
500000
,
[]
string
{
"A"
,
"B"
},
500000
,
[]
string
{
"A"
,
"B"
},
map
[
string
]
int64
{
"A"
:
300000
},
map
[
string
]
int64
{
"A"
:
300000
},
map
[
string
]
int64
{
"A"
:
300000
,
"B"
:
200000
})
map
[
string
]
int64
{
"A"
:
300000
,
"B"
:
200000
})
...
...
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