Skip to content

Commit 1bdcd36

Browse files
authored
Merge pull request #29 from nginxinc/mrajagopal-issue-23
Fix: Issue 23: Collect nginx-ingress version in the NIC pods
2 parents e42462a + 8b1a5d5 commit 1bdcd36

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

pkg/jobs/nic_job_list.go

+26
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,32 @@ func NICJobList() []Job {
434434
ch <- jobResult
435435
},
436436
},
437+
{
438+
Name: "exec-nginx-ingress-version",
439+
Timeout: time.Second * 10,
440+
Execute: func(dc *data_collector.DataCollector, ctx context.Context, ch chan JobResult) {
441+
jobResult := JobResult{Files: make(map[string][]byte), Error: nil}
442+
command := []string{"./nginx-ingress", "--version"}
443+
for _, namespace := range dc.Namespaces {
444+
pods, err := dc.K8sCoreClientSet.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{})
445+
if err != nil {
446+
dc.Logger.Printf("\tCould not retrieve pod list for namespace %s: %v\n", namespace, err)
447+
} else {
448+
for _, pod := range pods.Items {
449+
if strings.Contains(pod.Name, "ingress") {
450+
res, err := dc.PodExecutor(namespace, pod.Name, command, ctx)
451+
if err != nil {
452+
dc.Logger.Printf("\tCommand execution %s failed for pod %s in namespace %s: %v\n", command, pod.Name, namespace, err)
453+
} else {
454+
jobResult.Files[path.Join(dc.BaseDir, "exec", namespace, pod.Name+"__nginx-ingress-version.txt")] = res
455+
}
456+
}
457+
}
458+
}
459+
}
460+
ch <- jobResult
461+
},
462+
},
437463
{
438464
Name: "crd-objects",
439465
Timeout: time.Second * 10,

0 commit comments

Comments
 (0)