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

feat(retrofit): add SpinnakerServerExceptionHandler #4524

Merged
merged 6 commits into from
Sep 15, 2023

Conversation

dbyron-sf
Copy link
Contributor

Not used yet, since orca doesn't use SpinnakerRetrofitErrorHandler, and doesn't explicitly throw SpinnakerServerException, nor its children. Once we do use it, we'll get similar information present in the execution context if a SpinnakerServerException happens as we get today if a RetrofitError happens, and the same retry behavior.

…s a RetrofitError

with a fix of a corner case in RetrofitExceptionHandler along the way.

This paves the way to demonstrate similar behavior when a task throws a SpinnakerServerException
…nto BaseRetrofitExceptionHandler

to pave the way to share it with a new SpinnakerServerExceptionHandler class
…o take an Exception instead of only RetrofitError

The logic in the implementation is still specific to retrofit as it looks for
retrofit-specific annotations in the stack trace.  This way though,
SpinnakerNetworkExceptions caused by e.g. IOExceptions (e.g. with no underlying
RetrofitError in the causal chain) are considered retryable when they happen in an
idempotent retrofit request.
… kind argument to a String

which decouples children of BaseRetrofitExceptionHandler from retrofit1.  This makes it easier to
remove retrofit1 from the classpath once we move to retrofit2.
to provide similar functionality when tasks throw SpinnakerServerException that
RetrofitExceptionHandler provides for RetrofitException.  Specifically, this means:

* retry behavior is the same with SpinnakerServerExceptionHandler as it is with RetrofitExceptionHandler
* the information in the pipeline execution context is similar
* the way errors appear in the UI with SpinnakerSeverExceptionHandler is a combination of
  DefaultExceptionHandler, which is an improvement over RetrofitExceptionHandler
  (e.g. http response codes and URLs are present)
so there's a SpinnakerServerExceptionHandler available to RunTaskHandler
@spinnakerbot
Copy link
Contributor

We prefer that non-test backend code be written in Java or Kotlin, rather than Groovy. The following files have been added and written in Groovy:

  • orca-retrofit/src/main/groovy/com/netflix/spinnaker/orca/retrofit/exceptions/BaseRetrofitExceptionHandler.groovy

See our server-side conventions here.

findHttpMethodAnnotation(e) in ["GET", "HEAD", "DELETE", "PUT"]
}

private static String findHttpMethodAnnotation(Exception exception) {
Copy link
Member

Choose a reason for hiding this comment

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

Only worry, just at a glance here... there's a fair bit of reflection on this that I've seen cause major perf issues. This particular code doesn't look bad off hand ... just one of those triggering a "caution" flag. I'd wonder about using AnnotationUtils or similar spring libs which as i recall do caching of reflection calls so the forName/method search is only done once.

Copy link
Member

Choose a reason for hiding this comment

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

That said... it IS a "move" soo.... ignore for now, just one of those caught my eye

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, it's a drag, but it's no more reflection than we were already doing. I don't think we need it once we move to retrofit2.

@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Sep 15, 2023
@mergify mergify bot added the auto merged Merged automatically by a bot label Sep 15, 2023
@mergify mergify bot merged commit 83d2d3a into spinnaker:master Sep 15, 2023
j-sandy added a commit to j-sandy/kayenta that referenced this pull request May 15, 2024
mergify bot pushed a commit to spinnaker/kayenta that referenced this pull request May 15, 2024
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