Skip to content

Commit 898fcc7

Browse files
committed
Run pipeline
1 parent 71ed507 commit 898fcc7

File tree

2 files changed

+61
-30
lines changed

2 files changed

+61
-30
lines changed

internal/mode/static/provisioner/handler.go

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (h *eventHandler) HandleEventBatch(ctx context.Context, logger logr.Logger,
6262
if h.labelSelector.Matches(objLabels) {
6363
gatewayName := objLabels.Get(controller.GatewayLabel)
6464
gatewayNSName := types.NamespacedName{Namespace: obj.GetNamespace(), Name: gatewayName}
65+
6566
if err := h.updateOrDeleteResources(ctx, obj, gatewayNSName); err != nil {
6667
logger.Error(err, "error handling resource update")
6768
}
@@ -71,6 +72,7 @@ func (h *eventHandler) HandleEventBatch(ctx context.Context, logger logr.Logger,
7172
if h.labelSelector.Matches(objLabels) {
7273
gatewayName := objLabels.Get(controller.GatewayLabel)
7374
gatewayNSName := types.NamespacedName{Namespace: obj.GetNamespace(), Name: gatewayName}
75+
7476
if err := h.updateOrDeleteResources(ctx, obj, gatewayNSName); err != nil {
7577
logger.Error(err, "error handling resource update")
7678
}

tests/suite/graceful_recovery_test.go

+59-30
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"net/http"
88
"os/exec"
9+
"slices"
910
"strings"
1011
"time"
1112

@@ -318,9 +319,16 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
318319
setUpPortForward(nginxPodName, ns.Name)
319320

320321
checkNGFFunctionality(teaURL, coffeeURL, "", files, ns)
321-
// if errorLogs := getUnexpectedNginxErrorLogs(ngfPodName, ns.Name); errorLogs != "" {
322-
// Skip(fmt.Sprintf("NGINX has unexpected error logs: \n%s", errorLogs))
323-
//}
322+
323+
checkNGFContainerLogsForErrors(ngfPodName)
324+
325+
nginxPodNames, err = framework.GetReadyNginxPodNames(k8sClient, ns.Name, timeoutConfig.GetTimeout)
326+
Expect(err).ToNot(HaveOccurred())
327+
Expect(nginxPodNames).To(HaveLen(1))
328+
329+
if errorLogs := getUnexpectedNginxErrorLogs(nginxPodNames[0], ns.Name); errorLogs != "" {
330+
Skip(fmt.Sprintf("NGINX has unexpected error logs: \n%s", errorLogs))
331+
}
324332
}
325333

326334
runRestartNodeWithDrainingTest := func(teaURL, coffeeURL string, files []string, ns *core.Namespace) {
@@ -433,9 +441,20 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
433441
setUpPortForward(nginxPodNames[0], ns.Name)
434442

435443
checkNGFFunctionality(teaURL, coffeeURL, nginxContainerName, files, &ns)
436-
// if errorLogs := getUnexpectedNginxErrorLogs(nginxPodName, ns.Name); errorLogs != "" {
437-
// Skip(fmt.Sprintf("NGINX has unexpected error logs: \n%s", errorLogs))
438-
//}
444+
445+
ngfPodNames, err := framework.GetReadyNGFPodNames(k8sClient, ngfNamespace, releaseName, timeoutConfig.GetTimeout)
446+
Expect(err).ToNot(HaveOccurred())
447+
Expect(ngfPodNames).To(HaveLen(1))
448+
449+
nginxPodNames, err = framework.GetReadyNginxPodNames(k8sClient, ns.Name, timeoutConfig.GetTimeout)
450+
Expect(err).ToNot(HaveOccurred())
451+
Expect(nginxPodNames).To(HaveLen(1))
452+
453+
checkNGFContainerLogsForErrors(ngfPodNames[0])
454+
455+
if errorLogs := getUnexpectedNginxErrorLogs(nginxPodNames[0], ns.Name); errorLogs != "" {
456+
Skip(fmt.Sprintf("NGINX has unexpected error logs: \n%s", errorLogs))
457+
}
439458
})
440459

441460
It("recovers when NGF Pod is restarted", func() {
@@ -489,6 +508,16 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
489508
Should(Succeed())
490509

491510
checkNGFFunctionality(teaURL, coffeeURL, "", files, &ns)
511+
512+
checkNGFContainerLogsForErrors(newNGFPodName)
513+
514+
nginxPodNames, err := framework.GetReadyNginxPodNames(k8sClient, ns.Name, timeoutConfig.GetTimeout)
515+
Expect(err).ToNot(HaveOccurred())
516+
Expect(nginxPodNames).To(HaveLen(1))
517+
518+
if errorLogs := getUnexpectedNginxErrorLogs(nginxPodNames[0], ns.Name); errorLogs != "" {
519+
Skip(fmt.Sprintf("NGINX has unexpected error logs: \n%s", errorLogs))
520+
}
492521
})
493522

494523
It("recovers when drained node is restarted", func() {
@@ -593,30 +622,30 @@ func getNginxErrorLogs(nginxPodName, namespace string) string {
593622
return errorLogs
594623
}
595624

596-
// func getUnexpectedNginxErrorLogs(nginxPodName, namespace string) string {
597-
// expectedErrStrings := []string{
598-
// "connect() failed (111: Connection refused)",
599-
// "could not be resolved (host not found) during usage report",
600-
// "server returned 429",
601-
// // FIXME(salonichf5) remove this error message check
602-
// // when https://github.com/nginx/nginx-gateway-fabric/issues/2090 is completed.
603-
// "no live upstreams while connecting to upstream",
604-
// }
605-
//
606-
// unexpectedErrors := ""
607-
//
608-
// errorLogs := getNginxErrorLogs(nginxPodName, namespace)
609-
//
610-
// for _, line := range strings.Split(errorLogs, "\n") {
611-
// if !slices.ContainsFunc(expectedErrStrings, func(s string) bool {
612-
// return strings.Contains(line, s)
613-
// }) {
614-
// unexpectedErrors += line
615-
// }
616-
// }
617-
//
618-
// return unexpectedErrors
619-
//}
625+
func getUnexpectedNginxErrorLogs(nginxPodName, namespace string) string {
626+
expectedErrStrings := []string{
627+
"connect() failed (111: Connection refused)",
628+
"could not be resolved (host not found) during usage report",
629+
"server returned 429",
630+
// FIXME(salonichf5) remove this error message check
631+
// when https://github.com/nginx/nginx-gateway-fabric/issues/2090 is completed.
632+
"no live upstreams while connecting to upstream",
633+
}
634+
635+
unexpectedErrors := ""
636+
637+
errorLogs := getNginxErrorLogs(nginxPodName, namespace)
638+
639+
for _, line := range strings.Split(errorLogs, "\n") {
640+
if !slices.ContainsFunc(expectedErrStrings, func(s string) bool {
641+
return strings.Contains(line, s)
642+
}) {
643+
unexpectedErrors += line
644+
}
645+
}
646+
647+
return unexpectedErrors
648+
}
620649

621650
// checkNGFContainerLogsForErrors checks NGF container's logs for any possible errors.
622651
func checkNGFContainerLogsForErrors(ngfPodName string) {

0 commit comments

Comments
 (0)