Skip to content

Commit

Permalink
fix(clouddriver): Handle the Retrofit conversionError in ClusterSizeP…
Browse files Browse the repository at this point in the history
…reconditionTask

The oortService already uses SpinnakerRetrofitErrorHandler as part of the commit: 84a7106, so constructing the conversionError with RetrofitError would result in unexpected behaviour.

Wrapping up the conversion error into SpinnakerConversionError will fix this bug.
  • Loading branch information
Pranav-b-7 committed Apr 17, 2024
1 parent 83aa47f commit 3148a3f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
}

Expand Down

0 comments on commit 3148a3f

Please sign in to comment.