From fa7bfa805634c432d43d8e6a3ca6ee439a2250f9 Mon Sep 17 00:00:00 2001 From: Luthan95 <66585454+Luthan95@users.noreply.github.com> Date: Fri, 15 Sep 2023 04:31:41 +0530 Subject: [PATCH] refactor(front50,clouddriver): replace RetrofitError with SpinnakerRetrofitErrorHandler in DockerRegistry and PluginMonitor for custom error handling in front50 and clouddriver (#1125) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- igor-web/igor-web.gradle | 2 ++ .../spinnaker/igor/config/DockerRegistryConfig.groovy | 2 ++ .../netflix/spinnaker/igor/config/PluginMonitorConfig.java | 2 ++ .../igor/docker/model/DockerRegistryAccounts.groovy | 6 +++--- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/igor-web/igor-web.gradle b/igor-web/igor-web.gradle index e97d2ab8e..dd1b74538 100644 --- a/igor-web/igor-web.gradle +++ b/igor-web/igor-web.gradle @@ -83,6 +83,8 @@ dependencies { implementation "javax.inject:javax.inject:1" implementation "javax.validation:validation-api" + implementation "io.spinnaker.kork:kork-retrofit" + runtimeOnly "io.spinnaker.kork:kork-runtime" testImplementation "com.squareup.okhttp:mockwebserver" diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/DockerRegistryConfig.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/DockerRegistryConfig.groovy index 0cf4e3a95..ae64ec98b 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/DockerRegistryConfig.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/DockerRegistryConfig.groovy @@ -22,6 +22,7 @@ import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider import com.netflix.spinnaker.igor.IgorConfigurationProperties import com.netflix.spinnaker.igor.docker.model.DockerRegistryAccounts import com.netflix.spinnaker.igor.docker.service.ClouddriverService +import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger import groovy.transform.CompileStatic import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty @@ -55,6 +56,7 @@ class DockerRegistryConfig { .setClient(new Ok3Client(clientProvider.getClient(new DefaultServiceEndpoint("clouddriver", address)))) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(ClouddriverService)) + .setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance()) .build() .create(ClouddriverService) } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/PluginMonitorConfig.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/PluginMonitorConfig.java index a73ece757..4ed9da24e 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/PluginMonitorConfig.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/PluginMonitorConfig.java @@ -31,6 +31,7 @@ import com.netflix.spinnaker.kork.discovery.DiscoveryStatusListener; import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService; import com.netflix.spinnaker.kork.jedis.RedisClientDelegate; +import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler; import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger; import java.util.Optional; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -65,6 +66,7 @@ public PluginReleaseService pluginReleaseService( clientProvider.getClient(new DefaultServiceEndpoint("front50", address)))) .setLogLevel(retrofitLogLevel) .setLog(new Slf4jRetrofitLogger(Front50Service.class)) + .setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance()) .build() .create(Front50Service.class); diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/model/DockerRegistryAccounts.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/model/DockerRegistryAccounts.groovy index b4116f5b0..d432581f6 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/model/DockerRegistryAccounts.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/docker/model/DockerRegistryAccounts.groovy @@ -17,10 +17,10 @@ package com.netflix.spinnaker.igor.docker.model import com.netflix.spinnaker.igor.docker.service.ClouddriverService +import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerServerException import com.netflix.spinnaker.security.AuthenticatedRequest import groovy.util.logging.Slf4j import org.springframework.beans.factory.annotation.Autowired -import retrofit.RetrofitError @Slf4j class DockerRegistryAccounts { @@ -40,8 +40,8 @@ class DockerRegistryAccounts { service.getAccountDetails(it) } } - } catch (RetrofitError e) { - log.error "Failed to get list of docker accounts", e + } catch (SpinnakerServerException e) { + log.error "Failed to get list of docker accounts", e } } }