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
0d666e1f
Commit
0d666e1f
authored
Mar 21, 2017
by
Maciej Pytel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cluster-autoscaler multistep node drain e2e
parent
e9a91b8c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
cluster_size_autoscaling.go
test/e2e/autoscaling/cluster_size_autoscaling.go
+19
-11
No files found.
test/e2e/autoscaling/cluster_size_autoscaling.go
View file @
0d666e1f
...
@@ -330,7 +330,7 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
...
@@ -330,7 +330,7 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
})
})
It
(
"should be able to scale down when rescheduling a pod is required and pdb allows for it[Feature:ClusterSizeAutoscalingScaleDown]"
,
func
()
{
It
(
"should be able to scale down when rescheduling a pod is required and pdb allows for it[Feature:ClusterSizeAutoscalingScaleDown]"
,
func
()
{
runDrainTest
(
f
,
originalSizes
,
1
,
func
(
increasedSize
int
)
{
runDrainTest
(
f
,
originalSizes
,
1
,
1
,
func
(
increasedSize
int
)
{
By
(
"Some node should be removed"
)
By
(
"Some node should be removed"
)
framework
.
ExpectNoError
(
WaitForClusterSizeFunc
(
f
.
ClientSet
,
framework
.
ExpectNoError
(
WaitForClusterSizeFunc
(
f
.
ClientSet
,
func
(
size
int
)
bool
{
return
size
<
increasedSize
},
scaleDownTimeout
))
func
(
size
int
)
bool
{
return
size
<
increasedSize
},
scaleDownTimeout
))
...
@@ -338,7 +338,7 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
...
@@ -338,7 +338,7 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
})
})
It
(
"shouldn't be able to scale down when rescheduling a pod is required, but pdb doesn't allow drain[Feature:ClusterSizeAutoscalingScaleDown]"
,
func
()
{
It
(
"shouldn't be able to scale down when rescheduling a pod is required, but pdb doesn't allow drain[Feature:ClusterSizeAutoscalingScaleDown]"
,
func
()
{
runDrainTest
(
f
,
originalSizes
,
0
,
func
(
increasedSize
int
)
{
runDrainTest
(
f
,
originalSizes
,
1
,
0
,
func
(
increasedSize
int
)
{
By
(
"No nodes should be removed"
)
By
(
"No nodes should be removed"
)
time
.
Sleep
(
scaleDownTimeout
)
time
.
Sleep
(
scaleDownTimeout
)
nodes
:=
framework
.
GetReadySchedulableNodesOrDie
(
f
.
ClientSet
)
nodes
:=
framework
.
GetReadySchedulableNodesOrDie
(
f
.
ClientSet
)
...
@@ -346,9 +346,17 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
...
@@ -346,9 +346,17 @@ var _ = framework.KubeDescribe("Cluster size autoscaling [Slow]", func() {
})
})
})
})
It
(
"should be able to scale down by draining multiple pods one by one as dictated by pdb[Feature:ClusterSizeAutoscalingScaleDown]"
,
func
()
{
runDrainTest
(
f
,
originalSizes
,
2
,
1
,
func
(
increasedSize
int
)
{
By
(
"Some node should be removed"
)
framework
.
ExpectNoError
(
WaitForClusterSizeFunc
(
f
.
ClientSet
,
func
(
size
int
)
bool
{
return
size
<
increasedSize
},
scaleDownTimeout
))
})
})
})
})
func
runDrainTest
(
f
*
framework
.
Framework
,
migSizes
map
[
string
]
int
,
pdbSize
int
,
verifyFunction
func
(
int
))
{
func
runDrainTest
(
f
*
framework
.
Framework
,
migSizes
map
[
string
]
int
,
p
odsPerNode
,
p
dbSize
int
,
verifyFunction
func
(
int
))
{
increasedSize
:=
manuallyIncreaseClusterSize
(
f
,
migSizes
)
increasedSize
:=
manuallyIncreaseClusterSize
(
f
,
migSizes
)
nodes
,
err
:=
f
.
ClientSet
.
Core
()
.
Nodes
()
.
List
(
metav1
.
ListOptions
{
FieldSelector
:
fields
.
Set
{
nodes
,
err
:=
f
.
ClientSet
.
Core
()
.
Nodes
()
.
List
(
metav1
.
ListOptions
{
FieldSelector
:
fields
.
Set
{
...
@@ -356,10 +364,10 @@ func runDrainTest(f *framework.Framework, migSizes map[string]int, pdbSize int,
...
@@ -356,10 +364,10 @@ func runDrainTest(f *framework.Framework, migSizes map[string]int, pdbSize int,
}
.
AsSelector
()
.
String
()})
}
.
AsSelector
()
.
String
()})
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
namespace
:=
f
.
Namespace
.
Name
namespace
:=
f
.
Namespace
.
Name
numPods
:=
len
(
nodes
.
Items
)
numPods
:=
len
(
nodes
.
Items
)
*
podsPerNode
testId
:=
string
(
uuid
.
NewUUID
())
// So that we can label and find pods
testId
:=
string
(
uuid
.
NewUUID
())
// So that we can label and find pods
labelMap
:=
map
[
string
]
string
{
"test_id"
:
testId
}
labelMap
:=
map
[
string
]
string
{
"test_id"
:
testId
}
framework
.
ExpectNoError
(
runReplicatedPodOnEachNode
(
f
,
nodes
.
Items
,
"reschedulable-pods"
,
labelMap
))
framework
.
ExpectNoError
(
runReplicatedPodOnEachNode
(
f
,
nodes
.
Items
,
podsPerNode
,
"reschedulable-pods"
,
labelMap
))
defer
framework
.
DeleteRCAndPods
(
f
.
ClientSet
,
f
.
InternalClientset
,
f
.
Namespace
.
Name
,
"reschedulable-pods"
)
defer
framework
.
DeleteRCAndPods
(
f
.
ClientSet
,
f
.
InternalClientset
,
f
.
Namespace
.
Name
,
"reschedulable-pods"
)
...
@@ -705,16 +713,16 @@ func makeNodeSchedulable(c clientset.Interface, node *v1.Node) error {
...
@@ -705,16 +713,16 @@ func makeNodeSchedulable(c clientset.Interface, node *v1.Node) error {
return
nil
return
nil
}
}
// Creat an RC running a
single pod on each node without adding any constraint forcing such
// Creat an RC running a
given number of pods on each node without adding any constraint forcing
// pod distribution. This is meant to create a bunch of underutilized (but not unused) nodes
//
such
pod distribution. This is meant to create a bunch of underutilized (but not unused) nodes
// with pods that can be rescheduled on different nodes.
// with pods that can be rescheduled on different nodes.
// This is achieved using the following method:
// This is achieved using the following method:
// 1. disable scheduling on each node
// 1. disable scheduling on each node
// 2. create an empty RC
// 2. create an empty RC
// 3. for each node:
// 3. for each node:
// 3a. enable scheduling on that node
// 3a. enable scheduling on that node
// 3b. increase number of replicas in RC by
1
// 3b. increase number of replicas in RC by
podsPerNode
func
runReplicatedPodOnEachNode
(
f
*
framework
.
Framework
,
nodes
[]
v1
.
Node
,
id
string
,
labels
map
[
string
]
string
)
error
{
func
runReplicatedPodOnEachNode
(
f
*
framework
.
Framework
,
nodes
[]
v1
.
Node
,
podsPerNode
int
,
id
string
,
labels
map
[
string
]
string
)
error
{
By
(
"Run a pod on each node"
)
By
(
"Run a pod on each node"
)
for
_
,
node
:=
range
nodes
{
for
_
,
node
:=
range
nodes
{
err
:=
makeNodeUnschedulable
(
f
.
ClientSet
,
&
node
)
err
:=
makeNodeUnschedulable
(
f
.
ClientSet
,
&
node
)
...
@@ -754,7 +762,7 @@ func runReplicatedPodOnEachNode(f *framework.Framework, nodes []v1.Node, id stri
...
@@ -754,7 +762,7 @@ func runReplicatedPodOnEachNode(f *framework.Framework, nodes []v1.Node, id stri
// Update replicas count, to create new pods that will be allocated on node
// Update replicas count, to create new pods that will be allocated on node
// (we retry 409 errors in case rc reference got out of sync)
// (we retry 409 errors in case rc reference got out of sync)
for
j
:=
0
;
j
<
3
;
j
++
{
for
j
:=
0
;
j
<
3
;
j
++
{
*
rc
.
Spec
.
Replicas
=
int32
(
i
+
1
)
*
rc
.
Spec
.
Replicas
=
int32
(
(
i
+
1
)
*
podsPerNode
)
rc
,
err
=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
.
Update
(
rc
)
rc
,
err
=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
.
Update
(
rc
)
if
err
==
nil
{
if
err
==
nil
{
break
break
...
@@ -771,7 +779,7 @@ func runReplicatedPodOnEachNode(f *framework.Framework, nodes []v1.Node, id stri
...
@@ -771,7 +779,7 @@ func runReplicatedPodOnEachNode(f *framework.Framework, nodes []v1.Node, id stri
err
=
wait
.
PollImmediate
(
5
*
time
.
Second
,
podTimeout
,
func
()
(
bool
,
error
)
{
err
=
wait
.
PollImmediate
(
5
*
time
.
Second
,
podTimeout
,
func
()
(
bool
,
error
)
{
rc
,
err
=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
.
Get
(
id
,
metav1
.
GetOptions
{})
rc
,
err
=
f
.
ClientSet
.
Core
()
.
ReplicationControllers
(
f
.
Namespace
.
Name
)
.
Get
(
id
,
metav1
.
GetOptions
{})
if
err
!=
nil
||
rc
.
Status
.
ReadyReplicas
<
int32
(
i
+
1
)
{
if
err
!=
nil
||
rc
.
Status
.
ReadyReplicas
<
int32
(
(
i
+
1
)
*
podsPerNode
)
{
return
false
,
nil
return
false
,
nil
}
}
return
true
,
nil
return
true
,
nil
...
...
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