From 04fcca9431fb1062b9fa4f5317cea8ada16cee63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Przychodze=C5=84?= Date: Wed, 4 Mar 2020 15:28:07 +0100 Subject: [PATCH] [NodeKiller] Change rounding of a number of selected nodes --- clusterloader2/pkg/chaos/nodes.go | 10 ++++++++-- clusterloader2/testing/load/config.yaml | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/clusterloader2/pkg/chaos/nodes.go b/clusterloader2/pkg/chaos/nodes.go index a805147b42..2a81c2ab7b 100644 --- a/clusterloader2/pkg/chaos/nodes.go +++ b/clusterloader2/pkg/chaos/nodes.go @@ -18,6 +18,7 @@ package chaos import ( "fmt" + "math" "math/rand" "sync" "time" @@ -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) } } @@ -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 } diff --git a/clusterloader2/testing/load/config.yaml b/clusterloader2/testing/load/config.yaml index 8c771cb16a..b6c916ef05 100644 --- a/clusterloader2/testing/load/config.yaml +++ b/clusterloader2/testing/load/config.yaml @@ -67,8 +67,8 @@ tuningSets: chaosMonkey: nodeFailure: failureRate: 0.01 - interval: 1m - jitterFactor: 10.0 + interval: 5m + jitterFactor: 2.0 simulatedDowntime: 10m {{end}} steps: