Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix status reporting for invalid HTTPRoutes #582

Merged
merged 2 commits into from
Apr 19, 2023

Conversation

pleshakov
Copy link
Contributor

918d650 introduced a bug which made NKG fail to report status conditions for an invalid HTTPRoute. It would try to report an empty condition in the status and fail because of the status CRD validation (example error):

{"level":"error","ts":"2023-04-18T15:37:49Z","logger":"statusUpdater","msg":"Failed to update status","namespace":"default","name":"coffee","kind":"HTTPRoute","error":"HTTPRoute.gateway.networking.k8s.io \"coffee\" is invalid: [status.parents[0].conditions[1].reason: Invalid value: \"\": status.parents[0].conditions[1].reason in body should be at least 1 chars long, status.parents[0].conditions[1].status: Unsupported value: \"\": supported values: \"True\", \"False\", \"Unknown\", status.parents[0].conditions[1].type: Invalid value: \"\": status.parents[0].conditions[1].type in body should match '^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$']","stacktrace":"github.com/nginxinc/nginx-kubernetes-gateway/internal/status.(*updaterImpl).update\n\t/home/runner/work/nginx-kubernetes-gateway/nginx-kubernetes-gateway/internal/status/updater.go:168\ngithub.com/nginxinc/nginx-kubernetes-gateway/internal/status.(*updaterImpl).Update\n\t/home/runner/work/nginx-kubernetes-gateway/nginx-kubernetes-gateway/internal/status/updater.go:128\ngithub.com/nginxinc/nginx-kubernetes-gateway/internal/events.(*EventHandlerImpl).HandleEventBatch\n\t/home/runner/work/nginx-kubernetes-gateway/nginx-kubernetes-gateway/internal/events/handler.go:90\ngithub.com/nginxinc/nginx-kubernetes-gateway/internal/events.(*EventLoop).Start.func1.1\n\t/home/runner/work/nginx-kubernetes-gateway/nginx-kubernetes-gateway/internal/events/loop.go:67"}

This PR fixes that bug.

918d650 introduced a bug which
made NKG fail to report status conditions for an invalid HTTPRoute.
It would try to report an empty condition in the status and fail
because of the status CRD validation (example error):

{"level":"error","ts":"2023-04-18T15:37:49Z","logger":"statusUpdater","msg":"Failed to update status","namespace":"default","name":"coffee","kind":"HTTPRoute","error":"HTTPRoute.gateway.networking.k8s.io \"coffee\" is invalid: [status.parents[0].conditions[1].reason: Invalid value: \"\": status.parents[0].conditions[1].reason in body should be at least 1 chars long, status.parents[0].conditions[1].status: Unsupported value: \"\": supported values: \"True\", \"False\", \"Unknown\", status.parents[0].conditions[1].type: Invalid value: \"\": status.parents[0].conditions[1].type in body should match '^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$']","stacktrace":"github.com/nginxinc/nginx-kubernetes-gateway/internal/status.(*updaterImpl).update\n\t/home/runner/work/nginx-kubernetes-gateway/nginx-kubernetes-gateway/internal/status/updater.go:168\ngithub.com/nginxinc/nginx-kubernetes-gateway/internal/status.(*updaterImpl).Update\n\t/home/runner/work/nginx-kubernetes-gateway/nginx-kubernetes-gateway/internal/status/updater.go:128\ngithub.com/nginxinc/nginx-kubernetes-gateway/internal/events.(*EventHandlerImpl).HandleEventBatch\n\t/home/runner/work/nginx-kubernetes-gateway/nginx-kubernetes-gateway/internal/events/handler.go:90\ngithub.com/nginxinc/nginx-kubernetes-gateway/internal/events.(*EventLoop).Start.func1.1\n\t/home/runner/work/nginx-kubernetes-gateway/nginx-kubernetes-gateway/internal/events/loop.go:67"}

This commit fixes that bug.
@pleshakov pleshakov requested a review from a team as a code owner April 18, 2023 20:11
@pleshakov pleshakov requested a review from kate-osborn April 18, 2023 20:25
@github-actions github-actions bot added the bug Something isn't working label Apr 19, 2023
@pleshakov pleshakov merged commit 9673c9e into main Apr 19, 2023
@pleshakov pleshakov deleted the fix/invalid-route-conditions branch April 19, 2023 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants