-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add a configurable default backend. #426
base: main
Are you sure you want to change the base?
Conversation
1442a30
to
7b67e02
Compare
For all requests that don't match any path or path prefix in the database, forward the request to ROUTER_DEFAULT_BACKEND_URL. This defaults to `government-frontend`, which is where 93% of routes go. This should allow shrinking the route database by an order of magnitude as well as making it a little easier to eliminate Router in the long run. We no longer respond 503 to all requests when the route database is empty. This feature was presumably conceived as a kind of lameduck mode (albeit somewhat buggy). We're almost certainly better off without it now that an empty database doesn't mean we're completely broken.
- Use common terminology e.g. "HTTP method". - Make the `Describe` / `It` test names fit together better. - Trivial style cleanup to reduce boilerplate somewhat.
- Remove unnecessary conditionals around time.Sleep(). - Use const.
This also gets rid of change-detectors on error response bodies (which we don't care about, because the edge caches replace them with prettier ones anyway). https://onsi.github.io/gomega/#working-with-http-responses Generated with: ```sh g grep -l resp.StatusCode integration_tests | xargs gsed -i \ 's/Expect(resp.StatusCode)\.To(Equal(\([0-9]\{3\}\)))/Expect(resp).To(HaveHTTPStatus(\1))/' ```
7b67e02
to
f06f154
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Chris! Agree, this seems like a sensible change. I'm pretty sure that Rails will return 404 for a route it doesn't have - but I think government-frontend has wildcard route that catches everything and then gets handled by the content-item controller. I think there is assumption that there must be a content item in the Content Store if request is routed from router - so unsure what happens it raise an exception. However, it might be safe due to the rescue clauses.
Worth testing to see how government frontend behaves.
Ohh good shout, thanks! I'll go explore that before I think about rolling this out 🙇 |
Did some exploratory testing in the staging environment and all seems happy apart from organisations pages like these: (links unfortunately need VPN or they'll error)
All the other gov-frontend document types seem ok though 🧐 I'll set this back to draft while I figure out what's going on there. |
Ughhh it's because those pages have paths that shadow shorter path prefixes that go elsewhere 😫 (why, GOV.UK, whyyyyy) production:PRIMARY> db.routes.find({
incoming_path: '/government/organisations/hm-revenue-customs'
})
{
"_id" : ObjectId("5ae1e0b545a5a01908a01215"),
"backend_id" : "collections",
"disabled" : false,
"handler" : "backend",
"incoming_path" : "/government/organisations/hm-revenue-customs",
"route_type" : "prefix",
"updated_at" : ISODate("2023-05-15T16:08:31.165Z")
}
production:PRIMARY> db.routes.find({
incoming_path: '/government/organisations/hm-revenue-customs/contact/excise-enquiries'
})
{
"_id" : ObjectId("546dcf7e45a5a0a5a2000121"),
"backend_id" : "government-frontend",
"disabled" : false,
"handler" : "backend",
"incoming_path" : "/government/organisations/hm-revenue-customs/contact/excise-enquiries",
"route_type" : "exact"
} |
Easy enough to just put a fancier filter on the |
For all requests that don't match any path or path prefix in the database, forward the request to ROUTER_DEFAULT_BACKEND_URL. This defaults to
government-frontend
, which is where 93% of routes go.This should allow shrinking the route database by an order of magnitude as well as making it a little easier to eliminate Router in the long run.
We no longer respond 503 to all requests when the route database is empty. That feature was presumably conceived as a kind of lameduck mode (albeit somewhat buggy). We're almost certainly better off without it now that an empty database doesn't mean we're completely broken.