Skip to content

Commit

Permalink
fix: return a 480 response when an AOR is not found in the location t…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
psanders committed Feb 27, 2024
1 parent a19d21e commit fd8ed74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions mods/connect/src/handlers/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as grpc from "@grpc/grpc-js"
import { Helper as H } from "@routr/location"
import { tailor } from "../tailor"
import {
Expand Down Expand Up @@ -87,6 +88,9 @@ export const handleRequest =

res.send(tailor(route as CT.Route, req))
} catch (err) {
if (err.code === grpc.status.NOT_FOUND) {
return res.sendTemporarilyUnavailable()
}
logger.error(err)
res.sendInternalServerError()
}
Expand Down
8 changes: 6 additions & 2 deletions mods/location/src/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@ export default class Location implements ILocationService {
? [await this.nextWithAffinity(routes, request.sessionAffinityRef)]
: [this.next(routes, request)]

this.store.put(storeKeyWithLabels, r[0])
if (r.length > 0 && r[0]) {
this.store.put(storeKeyWithLabels, r[0])
return r
}

return r
return []
}

/** @inheritdoc */
Expand All @@ -139,6 +142,7 @@ export default class Location implements ILocationService {
private next(routes: Array<Route>, request: FindRoutesRequest): Route {
const { backend } = request
const ref = backend?.ref || request.aor

if (
backend?.balancingAlgorithm === CT.LoadBalancingAlgorithm.LEAST_SESSIONS
) {
Expand Down

0 comments on commit fd8ed74

Please sign in to comment.