Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions pkg/jobs/nic_job_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/nginxinc/nginx-k8s-supportpkg/pkg/crds"
"github.com/nginxinc/nginx-k8s-supportpkg/pkg/data_collector"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -45,12 +46,16 @@ func NICJobList() []Job {
} else {
for _, pod := range pods.Items {
if strings.Contains(pod.Name, "ingress") {
res, err := dc.PodExecutor(namespace, pod.Name, "nginx-ingress", command, ctx)
if err != nil {
jobResult.Error = err
dc.Logger.Printf("\tCommand execution %s failed for pod %s in namespace %s: %v\n", command, pod.Name, namespace, err)
} else {
jobResult.Files[filepath.Join(dc.BaseDir, "exec", namespace, pod.Name+"__nginx-ingress-version.txt")] = res
for _, container := range pod.Spec.Containers {

res, err := dc.PodExecutor(namespace, pod.Name, container.Name, command, ctx)
if err != nil {
jobResult.Error = err
dc.Logger.Printf("\tCommand execution %s failed for pod %s in namespace %s: %v\n", command, pod.Name, namespace, err)
} else {
fileName := fmt.Sprintf("%s__%s__nginx-ingress-version.txt", pod.Name, container.Name)
jobResult.Files[filepath.Join(dc.BaseDir, "exec", namespace, fileName)] = res
}
}
}
}
Expand All @@ -72,12 +77,15 @@ func NICJobList() []Job {
} else {
for _, pod := range pods.Items {
if strings.Contains(pod.Name, "ingress") {
res, err := dc.PodExecutor(namespace, pod.Name, "nginx-ingress", command, ctx)
if err != nil {
jobResult.Error = err
dc.Logger.Printf("\tCommand execution %s failed for pod %s in namespace %s: %v\n", command, pod.Name, namespace, err)
} else {
jobResult.Files[filepath.Join(dc.BaseDir, "exec", namespace, pod.Name+"__nginx-t.txt")] = res
for _, container := range pod.Spec.Containers {
res, err := dc.PodExecutor(namespace, pod.Name, container.Name, command, ctx)
if err != nil {
jobResult.Error = err
dc.Logger.Printf("\tCommand execution %s failed for pod %s in namespace %s: %v\n", command, pod.Name, namespace, err)
} else {
fileName := fmt.Sprintf("%s__%s__nginx-t.txt", pod.Name, container.Name)
jobResult.Files[filepath.Join(dc.BaseDir, "exec", namespace, fileName)] = res
}
}
}
}
Expand Down