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): move url attribute from SpinnakerHttpException to SpinnakerServerException #1110

Merged

Conversation

dbyron-sf
Copy link
Contributor

so it's available to exception handling code that currently has access to the url via RetrofitError.

to use fluent assertions and other small tweaks
to prepare to move url to SpinnakerServerException
…2ErrorHandleTest

testRetrofitSimpleSpinnakerServerException actually generates a SpinnakerNetworkException and so it's effectively the same test as testRetrofitSimpleSpinnakerNetworkException.
…nnakerServerException

so it's available to exception handling code that currently has access to the url via RetrofitError.
Copy link
Contributor

@xibz xibz left a comment

Choose a reason for hiding this comment

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

Overall looks good! One minor design consideration, but overall I like the approach

@@ -59,11 +59,11 @@ public Throwable handleError(RetrofitError e) {
}
return retval;
case NETWORK:
return new SpinnakerNetworkException(e.getMessage(), e.getCause());
return new SpinnakerNetworkException(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

This becomes easy to change too

Suggested change
return new SpinnakerNetworkException(e);
return new SpinnakerNetworkException(e.getMessage(), e.getCause(), e.getUrl());

}

public SpinnakerServerException() {}
public SpinnakerServerException(String message, Throwable cause, String url) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think with this new method signature, we can probably get rid of all the retrofit constructors tbh.

This will at least clean up the other exceptions and only require updating the one constructor in each other exception. This also keeps the SpinnakerServerException pretty agnostic to retrofit, which may be a better approach for now since we are only interested in the URL at this point. Further, if we do end up with more fields from retrofit in this particular class, we can revisit. However, let's keep it simple and just add the one field :)

case CONVERSION:
return new SpinnakerConversionException(e.getMessage(), e.getCause());
return new SpinnakerConversionException(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return new SpinnakerConversionException(e);
return new SpinnakerConversionException(e.getMessage(), e.getCause(), e.getUrl());

default:
return new SpinnakerServerException(e.getMessage(), e.getCause());
return new SpinnakerServerException(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return new SpinnakerServerException(e);
return new SpinnakerServerException(e.getMessage(), e.getCause(), e.getUrl());

super(message, cause);
private final String url;

public SpinnakerServerException(RetrofitError e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Then these go away and allows for only the SpinnakerHttpException to utilize all the retrofit fields

… Request

instead of a url, to pave the way for storing other attributes of requests (e.g. the http request method)
…e new SpinnakerConversionException constructors
public SpinnakerConversionException(RetrofitError e) {
super(e);
setRetryable(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Oof, that sucks we need to add the false everywhere. May be nice to have a implements NonRetryableException or something like that, but that is separate from this PR

Copy link
Contributor

@xibz xibz left a comment

Choose a reason for hiding this comment

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

@dbyron-sf Thank you for the improvements! The javadocs are fantastic :) and really helped me understand the use cases.

I had one very minor nit comment, but this change looks really good :)

@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Oct 29, 2023
@mergify mergify bot added the auto merged label Oct 29, 2023
@mergify mergify bot merged commit c90aabb into spinnaker:master Oct 29, 2023
5 checks passed
@dbyron-sf dbyron-sf deleted the move-url-to-SpinnakerServerException branch October 29, 2023 23:16
dbyron-sf added a commit to spinnakerbot/orca that referenced this pull request Oct 30, 2023
dbyron-sf added a commit to spinnakerbot/rosco that referenced this pull request Oct 30, 2023
mergify bot pushed a commit to spinnaker/rosco that referenced this pull request Oct 30, 2023
* chore(dependencies): Autobump korkVersion

* fix(manifests/test): keep up with SpinnakerNetworkException constructor changes

from spinnaker/kork#1110

---------

Co-authored-by: root <root@2f91e8016c3c>
Co-authored-by: David Byron <dbyron@salesforce.com>
mergify bot pushed a commit to spinnaker/orca that referenced this pull request Oct 30, 2023
* chore(dependencies): Autobump korkVersion

* fix(retrofit/test): keep up with SpinnakerServerException, SpinnakerNetworkException constructor changes

from spinnaker/kork#1110

---------

Co-authored-by: root <root@2f91e8016c3c>
Co-authored-by: David Byron <dbyron@salesforce.com>
dbyron-sf added a commit to spinnakerbot/igor that referenced this pull request Oct 30, 2023
…OfProject

The jenkinsClient inside JenkinsService comes from JenkinsConfig, wihch, as of
spinnaker#1130, uses SpinnakerRetrofitErrorHandler.
Therefore, the getBuilds calls inside the try/catch block inside processBuildsOfProject
throws a SpinnakerServerException.

spinnaker#1130 updated the 'should continue processing other
builds from a master even if one or more build fetches fail' test to throw a
SpinnakerServerException with a RetrofitError as its cause instead of a RuntimeException
with a RetrofitError as its cause.  With spinnaker/kork#1110, the
SpinnakerServerException no longer has a RetrofitError as its cause.  It has the "mock
root cause" exception as its cause.  But, because
spinnaker/kork#1110 adds a url attribute to
SpinnakerServerException, the cause is no longer necessary for including a url in the
"Error communicating with jenkins" log message, and this commit updates the logic
accordingly.
mergify bot pushed a commit to spinnaker/igor that referenced this pull request Oct 30, 2023
* chore(dependencies): Autobump korkVersion

* fix(web): fix exception handling in JenkinsBuildMonitor.processBuildsOfProject

The jenkinsClient inside JenkinsService comes from JenkinsConfig, wihch, as of
#1130, uses SpinnakerRetrofitErrorHandler.
Therefore, the getBuilds calls inside the try/catch block inside processBuildsOfProject
throws a SpinnakerServerException.

#1130 updated the 'should continue processing other
builds from a master even if one or more build fetches fail' test to throw a
SpinnakerServerException with a RetrofitError as its cause instead of a RuntimeException
with a RetrofitError as its cause.  With spinnaker/kork#1110, the
SpinnakerServerException no longer has a RetrofitError as its cause.  It has the "mock
root cause" exception as its cause.  But, because
spinnaker/kork#1110 adds a url attribute to
SpinnakerServerException, the cause is no longer necessary for including a url in the
"Error communicating with jenkins" log message, and this commit updates the logic
accordingly.

* refactor(web/test): clean up exception mocking in JenkinsBuildMonitorSpec

remove unused runtimeException and rename retrofitEx since it's no longer a retrofitEx

---------

Co-authored-by: root <root@2f91e8016c3c>
Co-authored-by: David Byron <dbyron@salesforce.com>
dbyron-sf added a commit to spinnakerbot/clouddriver that referenced this pull request Oct 30, 2023
mergify bot pushed a commit to spinnaker/clouddriver that referenced this pull request Oct 30, 2023
* chore(dependencies): Autobump korkVersion

* fix(aws/test): keep up with SpinnakerNetworkException constructor changes

from spinnaker/kork#1110

---------

Co-authored-by: root <root@2f91e8016c3c>
Co-authored-by: David Byron <dbyron@salesforce.com>
dbyron-sf added a commit to spinnakerbot/kayenta that referenced this pull request Oct 30, 2023
mergify bot pushed a commit to spinnaker/kayenta that referenced this pull request Oct 30, 2023
* chore(dependencies): Autobump orcaVersion

* fix(core/test): keep up with SpinnakerNetworkException constructor changes

from spinnaker/kork#1110

---------

Co-authored-by: root <root@37e47cedb6bb>
Co-authored-by: David Byron <dbyron@salesforce.com>
Pranav-b-7 pushed a commit to Pranav-b-7/orca that referenced this pull request Nov 2, 2023
* chore(dependencies): Autobump korkVersion

* fix(retrofit/test): keep up with SpinnakerServerException, SpinnakerNetworkException constructor changes

from spinnaker/kork#1110

---------

Co-authored-by: root <root@2f91e8016c3c>
Co-authored-by: David Byron <dbyron@salesforce.com>

feat(retrofit2): orca-clouddriver: InstanceService - Eliminated the usage of RetrofitError in the catch blocks and added SpinnakerRetrofitErrorHandler in the retrofit config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants