Skip to content

Commit

Permalink
[NodeKiller] Change rounding of a number of selected nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzychodzen committed Mar 5, 2020
1 parent e658b72 commit 3c22abd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions clusterloader2/pkg/chaos/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package chaos

import (
"fmt"
"math"
"math/rand"
"sync"
"time"
Expand Down Expand Up @@ -86,6 +87,7 @@ func (k *NodeKiller) pickNodes() ([]v1.Node, error) {
for i := range prometheusPods {
if prometheusPods[i].Spec.NodeName != "" {
nodesHasPrometheusPod.Insert(prometheusPods[i].Spec.NodeName)
klog.Infof("%s: Node %s removed from killing. Runs pod %s", k, prometheusPods[i].Spec.NodeName, prometheusPods[i].Name)
}
}

Expand All @@ -98,9 +100,13 @@ func (k *NodeKiller) pickNodes() ([]v1.Node, error) {
rand.Shuffle(len(nodes), func(i, j int) {
nodes[i], nodes[j] = nodes[j], nodes[i]
})
numNodes := int(k.config.FailureRate * float64(len(nodes)))
numNodes := int(math.Ceil(k.config.FailureRate * float64(len(nodes))))
klog.Infof("%s: %d nodes available, wants to fail %d nodes", k, len(nodes), numNodes)
if len(nodes) > numNodes {
return nodes[:numNodes], nil
nodes = nodes[:numNodes]
}
for _, node := range nodes {
klog.Infof("%s: Node %q schedule for failure", k, node.Name)
}
return nodes, nil
}
Expand Down
2 changes: 1 addition & 1 deletion clusterloader2/testing/load/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ tuningSets:
chaosMonkey:
nodeFailure:
failureRate: 0.01
interval: 1m
interval: 5m
jitterFactor: 10.0
simulatedDowntime: 10m
{{end}}
Expand Down

0 comments on commit 3c22abd

Please sign in to comment.