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

Do not retry when retrieving groups fail #3929

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions delta/app/src/main/resources/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ app {
event-log = ${app.defaults.event-log}
# the realms pagination config
pagination = ${app.defaults.pagination}
# the client to interact with the Open-ID Connect endpoints
client = ${app.defaults.http-client}
}

# Organizations configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ object RealmsModule extends ModuleDef {
new RealmsRoutes(identities, realms, aclCheck)(cfg.http.baseUri, cfg.realms.pagination, s, cr, ordering)
}

make[HttpClient].named("realm").from { (cfg: AppConfig, as: ActorSystem[Nothing], sc: Scheduler) =>
HttpClient()(cfg.realms.client, as.classicSystem, sc)
make[HttpClient].named("realm").from { (as: ActorSystem[Nothing], sc: Scheduler) =>
HttpClient.noRetry()(as.classicSystem, sc)
}

many[SseEncoder[_]].add { base: BaseUri => RealmEvent.sseEncoder(base) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RealmsRoutesSpec extends BaseRouteSpec {

val githubLogo: Uri = "https://localhost/ghlogo"

val config: RealmsConfig = RealmsConfig(eventLogConfig, pagination, httpClientConfig)
val config: RealmsConfig = RealmsConfig(eventLogConfig, pagination)

val (githubOpenId, githubWk) = WellKnownGen.create(github.value)
val (gitlabOpenId, gitlabWk) = WellKnownGen.create(gitlab.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.plugins.storage
import akka.actor
import akka.actor.typed.ActorSystem
import cats.effect.Clock
import ch.epfl.bluebrain.nexus.delta.kernel.RetryStrategyConfig
import ch.epfl.bluebrain.nexus.delta.kernel.database.Transactors
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF
import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.client.ElasticSearchClient
Expand Down Expand Up @@ -35,7 +34,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.crypto.Crypto
import ch.epfl.bluebrain.nexus.delta.sdk.deletion.ProjectDeletionTask
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaSchemeDirectives
import ch.epfl.bluebrain.nexus.delta.sdk.fusion.FusionConfig
import ch.epfl.bluebrain.nexus.delta.sdk.http.{HttpClient, HttpClientConfig, HttpClientWorthRetry}
import ch.epfl.bluebrain.nexus.delta.sdk.http.HttpClient
import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.ServiceAccount
import ch.epfl.bluebrain.nexus.delta.sdk.migration.{MigrationLog, MigrationState}
Expand Down Expand Up @@ -68,12 +67,7 @@ class StoragePluginModule(priority: Int) extends ModuleDef {
make[StorageTypeConfig].from { cfg: StoragePluginConfig => cfg.storages.storageTypeConfig }

make[HttpClient].named("storage").from { (as: ActorSystem[Nothing], sc: Scheduler) =>
val clientConfig = HttpClientConfig(RetryStrategyConfig.AlwaysGiveUp, HttpClientWorthRetry.never, true)
HttpClient()(
clientConfig,
as.classicSystem,
sc
)
HttpClient.noRetry()(as.classicSystem, sc)
}

make[Storages]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ object HttpClient {
apply(HttpSingleRequest.default)
}

/**
* Construct an Http client using an underlying akka http client which will not retry on failures
*/
final def noRetry()(implicit as: ActorSystem, scheduler: Scheduler): HttpClient = {
implicit val config: HttpClientConfig = HttpClientConfig.noRetry
apply()
}

private[http] def apply(
client: HttpSingleRequest
)(implicit httpConfig: HttpClientConfig, as: ActorSystem, scheduler: Scheduler): HttpClient =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ object HttpClientConfig {

private[http] val logger: Logger = Logger[HttpClientConfig]

val noRetry: HttpClientConfig =
HttpClientConfig(RetryStrategyConfig.AlwaysGiveUp, HttpClientWorthRetry.never, compression = true)

@nowarn("cat=unused")
implicit private val httpClientWorthRetryConverter: ConfigReader[HttpClientWorthRetry] =
ConfigReader.fromString[HttpClientWorthRetry](string =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ch.epfl.bluebrain.nexus.delta.sdk.realms

import ch.epfl.bluebrain.nexus.delta.sdk.http.HttpClientConfig
import ch.epfl.bluebrain.nexus.delta.sdk.model.search.PaginationConfig
import ch.epfl.bluebrain.nexus.delta.sourcing.config.EventLogConfig
import pureconfig.ConfigReader
Expand All @@ -13,13 +12,10 @@ import pureconfig.generic.semiauto.deriveReader
* The event log configuration
* @param pagination
* configuration for how pagination should behave in listing operations
* @param client
* the client to interact with the Open-ID Connect endpoints
*/
final case class RealmsConfig(
eventLog: EventLogConfig,
pagination: PaginationConfig,
client: HttpClientConfig
pagination: PaginationConfig
)

object RealmsConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RealmImplSpec
val (githubOpenId, githubWk) = WellKnownGen.create(github.value)
val (gitlabOpenId, gitlabWk) = WellKnownGen.create(gitlab.value)

val realmConfig = RealmsConfig(eventLogConfig, pagination, httpClientConfig)
val realmConfig = RealmsConfig(eventLogConfig, pagination)

val resolveWellKnown = ioFromMap(
Map(githubOpenId -> githubWk, gitlabOpenId -> gitlabWk),
Expand Down