Skip to content

Commit

Permalink
fix bug: match pod by labels
Browse files Browse the repository at this point in the history
  • Loading branch information
MandssS committed Sep 6, 2022
1 parent 00f5b9e commit f3def73
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion exec/model/filter_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ var resourceFunc = func(ctx context.Context, client2 *channel.Client, flags map[
logrusField := logrus.WithField("experiment", GetExperimentIdFromContext(ctx))
pods := make([]v1.Pod, 0)
names := flags[ResourceNamesFlag.Name]
logrusField.Debugf("namespace: %s, labels: %s, names: %s", namespace, labels, names)
if names != "" {
nameArr := strings.Split(names, ",")
for _, name := range nameArr {
Expand All @@ -124,7 +125,11 @@ var resourceFunc = func(ctx context.Context, client2 *channel.Client, flags map[
logrusField.Warningf("can not find the pod by %s name in %s namespace, %v", name, namespace, err)
continue
}
if MapContains(pod.Labels, requirements) {
if len(requirements) > 0 {
if MapContains(pod.Labels, requirements) {
pods = append(pods, pod)
}
} else {
pods = append(pods, pod)
}
}
Expand Down

0 comments on commit f3def73

Please sign in to comment.