Skip to content

Commit

Permalink
perf: deploy dual-architecture chaos by default (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangSetSail authored Jun 20, 2023
1 parent a1b4849 commit b5f8973
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions controllers/handler/chaos.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handler
import (
"context"
"fmt"
"github.com/sirupsen/logrus"
"path"
"strings"

Expand Down Expand Up @@ -210,6 +211,24 @@ func (c *chaos) deployment() client.Object {
var affinity *corev1.Affinity
if len(nodeNames) > 0 {
affinity = affinityForRequiredNodes(nodeNames)
} else {
nodeList := &corev1.NodeList{}
err := c.client.List(context.Background(), nodeList)
if err != nil {
logrus.Errorf("get nodes failure: %v", err)
}
nodes := nodeList.Items
node_arch := make(map[string]string)
for _, node := range nodes {
arch := node.Status.NodeInfo.Architecture
node_arch[arch] = node.Name
}
if len(node_arch) >= 2 {
for _, nodeName := range node_arch {
nodeNames = append(nodeNames, nodeName)
}
}
affinity = affinityForRequiredNodes(nodeNames)
}

env := []corev1.EnvVar{
Expand Down

0 comments on commit b5f8973

Please sign in to comment.