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

refactor(clouddriver) : InstanceService - Eliminated the usages of RetrofitError exception handling and replaced it with SpinnakerRetrofitErrorHandler #4580

Merged

Conversation

Pranav-b-7
Copy link
Contributor

As part of this PR , the target is to eliminate the usage of RetrofitError in InstanceService retrofit client under module orca-clouddriver.

Replaced the exception handling logic with the handleError method under SpinnakerRetrofitErrorHandler class.

@Pranav-b-7 Pranav-b-7 force-pushed the instance-service-eliminate-RetrofitError branch 3 times, most recently from 6da5ea7 to e1be772 Compare November 2, 2023 10:32
@Pranav-b-7 Pranav-b-7 changed the title feat(retrofit2): orca-clouddriver module : InstanceService - Eliminated the usages of RetrofitError exception handling and replaced it with SpinnakerRetrofitErrorHandler refactor(clouddriver) : InstanceService - Eliminated the usages of RetrofitError exception handling and replaced it with SpinnakerRetrofitErrorHandler Nov 2, 2023
@dbyron-sf dbyron-sf force-pushed the instance-service-eliminate-RetrofitError branch from d69e28b to 662abe2 Compare November 2, 2023 15:15
@@ -121,6 +122,7 @@ class JarDiffsTask implements DiffTask {
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(address)
.setClient(new OkClient(okHttpClient))
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised spotless doesn't complain about this.

Suggested change
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance())
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code formatted as per the suggestion.

@@ -103,7 +113,7 @@ class JarDiffsTaskSpec extends Specification {
Response jarsResponse = new Response('http://foo.com', 200, 'OK', [], new TypedString(sourceJarsResponse))

when:
1 * instanceService.getJars() >> {throw new RetrofitError(null, null, null, null, null, null, null)}
1 * instanceService.getJars() >> {throw new SpinnakerServerException(request)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be a smaller change to wrap the RetrofitError in a SpinnakerServerException since that's what SpinnakerRetrofitErrorHandler does. The exception handling here is simple enough that it probably doesn't matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified the test cases to wrap the Spinnaker*Exception with RetrofitError

@Pranav-b-7 Pranav-b-7 force-pushed the instance-service-eliminate-RetrofitError branch 3 times, most recently from 3cd6705 to 5d2d11e Compare November 3, 2023 10:46
@Pranav-b-7 Pranav-b-7 requested a review from dbyron-sf November 3, 2023 11:53
…ofitError in the catch blocks and added SpinnakerRetrofitErrorHandler in the retrofit config which handles the RetrofitError and throws a customised Spinnaker*Exception
…r to wrap up the customised Spinnaker*Exception
…itError to more specific Retrofit network error
@Pranav-b-7 Pranav-b-7 force-pushed the instance-service-eliminate-RetrofitError branch from ad810fa to 104a510 Compare November 5, 2023 14:39
@Pranav-b-7 Pranav-b-7 requested a review from dbyron-sf November 5, 2023 14:39
@Pranav-b-7 Pranav-b-7 marked this pull request as ready for review November 5, 2023 14:40
import java.nio.charset.Charset
import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus
import com.netflix.spinnaker.orca.api.pipeline.TaskResult
import com.netflix.spinnaker.orca.clouddriver.InstanceService
import com.netflix.spinnaker.orca.pipeline.model.PipelineExecutionImpl
import com.netflix.spinnaker.orca.pipeline.model.StageExecutionImpl
import retrofit.RetrofitError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised spotless doesn't re-order the imports. Can you reconfigure intellij to match what was here before and minimize the diffs please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reordered the import statement

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have been good to re-order the other two as well.

@Pranav-b-7 Pranav-b-7 requested a review from dbyron-sf November 5, 2023 17:44
@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Nov 5, 2023
@mergify mergify bot added the auto merged Merged automatically by a bot label Nov 5, 2023
@mergify mergify bot merged commit a5d151f into spinnaker:master Nov 5, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merged Merged automatically by a bot ready to merge Approved and ready for merge target-release/1.33
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants