Skip to content

Commit

Permalink
rewrite 502 as 503
Browse files Browse the repository at this point in the history
  • Loading branch information
Grekkq committed Oct 18, 2023
1 parent a27d287 commit 55315b8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/scala/com/ing/wbaa/rokku/proxy/api/ProxyService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import com.ing.wbaa.rokku.proxy.provider.aws.AwsErrorCodes

import java.util.UUID
import java.util.concurrent.TimeUnit
import scala.concurrent.{ ExecutionContext, Future }
import scala.concurrent.{ Await, ExecutionContext, Future }
import scala.concurrent.duration.Duration
import scala.util.{ Failure, Success }

trait ProxyService {
Expand Down Expand Up @@ -132,14 +133,16 @@ trait ProxyService {
updateHeadersForRequest(httpRequest) { newHttpRequest =>
val httpResponse = executeRequest(newHttpRequest, userSTS, s3Request).andThen {
case Success(response: HttpResponse) =>
if (response.status == StatusCodes.BadGateway) {
logger.info("Got 502, rewriting as 503 to debug")
throw new RokkuThrottlingException("Got 502, rewriting as 503")
}
logger.info("Completing request correctly with headers: {}", response.headers)
handlePostRequestActions(response, httpRequest, s3Request, userSTS)
}
complete(httpResponse)
val evaluatedResponse = Await.result(httpResponse, Duration("60 seconds"))
if (evaluatedResponse.status == StatusCodes.BadGateway) {
logger.info("Got 502, rewriting as 503 to debug")
throw new RokkuThrottlingException("Got 502, rewriting as 503")
}
logger.info("Completing request correctly, so no exceptions")
complete(evaluatedResponse)
}
}

Expand Down

0 comments on commit 55315b8

Please sign in to comment.