From 3148a3f948caa64a19f49ee08b7d138ed4d24a9b Mon Sep 17 00:00:00 2001 From: Pranav-b-7 Date: Wed, 17 Apr 2024 21:27:23 +0530 Subject: [PATCH] fix(clouddriver): Handle the Retrofit conversionError in ClusterSizePreconditionTask The oortService already uses SpinnakerRetrofitErrorHandler as part of the commit: 84a7106c512ceada65d7799f527a956262d964d5, so constructing the conversionError with RetrofitError would result in unexpected behaviour. Wrapping up the conversion error into SpinnakerConversionError will fix this bug. --- .../tasks/cluster/ClusterSizePreconditionTask.groovy | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/cluster/ClusterSizePreconditionTask.groovy b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/cluster/ClusterSizePreconditionTask.groovy index 9f883d35af..f17600541c 100644 --- a/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/cluster/ClusterSizePreconditionTask.groovy +++ b/orca-clouddriver/src/main/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/cluster/ClusterSizePreconditionTask.groovy @@ -19,6 +19,7 @@ package com.netflix.spinnaker.orca.clouddriver.tasks.cluster import com.fasterxml.jackson.databind.ObjectMapper import com.netflix.frigga.Names import com.netflix.spinnaker.kork.exceptions.ConfigurationException +import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerConversionException import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerHttpException import com.netflix.spinnaker.moniker.Moniker import com.netflix.spinnaker.orca.api.pipeline.RetryableTask @@ -103,12 +104,17 @@ class ClusterSizePreconditionTask implements CloudProviderAware, RetryableTask, } throw spinnakerHttpException } - + /** + * @see {@link com.netflix.spinnaker.orca.clouddriver.config.CloudDriverConfiguration#oortDeployService(com.netflix.spinnaker.orca.clouddriver.config.CloudDriverConfiguration.ClouddriverRetrofitBuilder)} + * it uses {@link com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler} and the internal logic of constructing the conversion exception is by wrapping the {@link RetrofitError}. + * In the same way the below {@link ConversionException} is wrapped into {@link com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerConversionException} for time being. + * This logic will remain until the {@link OortService} configurations are migrated/modified to retrofit 2.x, the same is applicable to below {@link JacksonConverter} as well. + * **/ JacksonConverter converter = new JacksonConverter(objectMapper) try { return (Cluster) converter.fromBody(response.body, Cluster) } catch (ConversionException ce) { - throw RetrofitError.conversionError(response.url, response, converter, Cluster, ce) + throw new SpinnakerConversionException(RetrofitError.conversionError(response.url, response, converter, Cluster, ce)) } }