Skip to content

Commit

Permalink
Merge pull request #141 from zwk1091/main
Browse files Browse the repository at this point in the history
fix: execute multiple containers
  • Loading branch information
KingsonKai committed Jan 8, 2024
2 parents 90af63b + c78ed82 commit 2300ed4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions chaosmeta-inject-operator/pkg/scopehandler/pod/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ func getPodObjectList(ctx context.Context, selectorUnit v1alpha1.SelectorUnit) (

var result = make([]model.AtomicObject, 0)
for _, pod := range podList {
for _, subObject := range pod.GetSubObjects() {
result = append(result, &subObject)
subObjects := pod.GetSubObjects()
for i, _ := range subObjects {
result = append(result, &subObjects[i])
}
}

Expand Down
7 changes: 4 additions & 3 deletions chaosmeta-inject-operator/pkg/selector/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import (
)

const (
HostIPKey = ".status.hostIP"
PhaseKey = ".status.phase"
HostIPKey = ".status.hostIP"
PhaseKey = ".status.phase"
containerRegFmt = "^(%s)$"
)

var (
Expand Down Expand Up @@ -227,7 +228,6 @@ func GetTargetContainers(containerReg string, status []corev1.ContainerStatus) (
return
}
containerReg = strings.ReplaceAll(containerReg, ",", "|")
reg := regexp.MustCompile(containerReg)
containers = []model.ContainerInfo{}
var targetContainerInfo corev1.ContainerStatus
// no container setting equals to firstcontainer setting
Expand All @@ -239,6 +239,7 @@ func GetTargetContainers(containerReg string, status []corev1.ContainerStatus) (
}
containers = append(containers, *info)
} else {
reg := regexp.MustCompile(fmt.Sprintf(containerRegFmt, containerReg))
for _, containerStatus := range status {
if reg.MatchString(containerStatus.Name) {
info, err := getContainerInfo(containerStatus)
Expand Down

0 comments on commit 2300ed4

Please sign in to comment.