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(deploymentmonitor): use SpinnakerRetrofitErrorHandler with DeploymentMonitorService #4628

Conversation

dbyron-sf
Copy link
Contributor

@dbyron-sf dbyron-sf commented Jan 4, 2024

Note, there's a behavior change here when http response bodies aren't json objects.
Previously, the log message would, barring an exception processing the response, include
the http response body in the log message. With SpinnakerHttpException, response bodies
that aren't json objects aren't available, so the body appears to be empty.

For example, before:

2024-01-04 12:31:59.640  WARN   --- [    Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:49179/deployment/evaluateHeal>
response body: non-json response}
retrofit.RetrofitError: 400 Bad Request
        at retrofit.RetrofitError.httpError(RetrofitError.java:40)

after:

2024-01-04 14:26:13.270  WARN   --- [    Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:58192/deployment/evaluateHeal>
response body: }
com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerHttpException: Status: 400, URL: http://localhost:58192/deployment/evaluateHealth, Message: Bad Request
        at com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler.handleError(SpinnakerRetrofitErrorHandler.java:55)

There's also a behavior change for ConversionException.

before:

2024-01-04 16:03:19.363  WARN   --- [    Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:60051/deployment/evaluateHeal>
headers:
response body: }
retrofit.RetrofitError: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.netflix.spinnaker.orca.deploymentmonitor.models.DeploymentStep` (although at least one Crea>
 at [Source: (retrofit.ExceptionCatchingTypedInput$ExceptionCatchingInputStream); line: 1, column: 13] (through reference chain: com.netflix.spinnaker.orca.deploymentmonitor.models.EvaluateHealthResponse["nextS>
        at retrofit.RetrofitError.conversionError(RetrofitError.java:33)

after:

2024-01-04 16:14:03.540  WARN   --- [    Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:59402/deployment/evaluateHeal>
com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerConversionException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.netflix.spinnaker.orca.deploymentmonit>
 at [Source: (retrofit.ExceptionCatchingTypedInput$ExceptionCatchingInputStream); line: 1, column: 13] (through reference chain: com.netflix.spinnaker.orca.deploymentmonitor.models.EvaluateHealthResponse["nextS>
        at com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler.handleError(SpinnakerRetrofitErrorHandler.java:64)
        at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:242)

@dbyron-sf dbyron-sf force-pushed the deployment-monitor-service-spinnaker-exception branch 4 times, most recently from 91fe1be to c60c839 Compare January 5, 2024 05:56
to make it possible to add tests that assert on the contents of log messages.

orca-test has a logback-test.xml file that disables logging, so add one for
orca-clouddriver that takes precedence so log messages actually get generated.

Now that logging is enabled, clock.millis() is called an additional time during a test in
ServerGroupCacheForceRefreshTaskSpec.
@dbyron-sf dbyron-sf force-pushed the deployment-monitor-service-spinnaker-exception branch from c60c839 to 21f7b10 Compare January 8, 2024 16:26
dbyron-sf and others added 3 commits January 8, 2024 08:29
to see what changes when moving to SpinnakerRetrofitErrorHandler.  Specifically, these
tests verify the contents of a log message that's tightly coupled to RetrofitError.
…e for different types of RetrofitError (spinnaker#4608)"

This reverts commit adc81ac.

With the addition of EvaluateDeploymentHealthTaskTest, we have equivalent coverage that:

- is in java instead of groovy
- doesn't increase the visibility of getRetrofitLogMessage
- more easily shows behavior changes when adopting SpinnakerRetrofitErrorHandler
- is less likely to change when moving from retrofit to retrofit2
…eploymentMonitorService

Note, there's a behavior change here when http response bodies aren't json objects.
Previously, the log message would, barring an exception processing the response, include
the http response body in the log message.  With SpinnakerHttpException, response bodies
that aren't json objects aren't available, so the body appears to be empty.

For example, before:

2024-01-04 12:31:59.640  WARN   --- [    Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:49179/deployment/evaluateHealth, status: 400 (Bad Request)
response body: non-json response}
retrofit.RetrofitError: 400 Bad Request
	at retrofit.RetrofitError.httpError(RetrofitError.java:40)

after:

2024-01-04 14:26:13.270  WARN   --- [    Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:58192/deployment/evaluateHealth, status: 400 (Bad Request)
response body: }
com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerHttpException: Status: 400, URL: http://localhost:58192/deployment/evaluateHealth, Message: Bad Request
	at com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler.handleError(SpinnakerRetrofitErrorHandler.java:55)

There's also a behavior change for ConversionException.

before:

2024-01-04 16:03:19.363  WARN   --- [    Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:60051/deployment/evaluateHealth, status: 200 (OK)
headers:
response body: }
retrofit.RetrofitError: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.netflix.spinnaker.orca.deploymentmonitor.models.DeploymentStep` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('bogus')
 at [Source: (retrofit.ExceptionCatchingTypedInput$ExceptionCatchingInputStream); line: 1, column: 13] (through reference chain: com.netflix.spinnaker.orca.deploymentmonitor.models.EvaluateHealthResponse["nextStep"])
	at retrofit.RetrofitError.conversionError(RetrofitError.java:33)

after:

2024-01-04 16:14:03.540  WARN   --- [    Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:59402/deployment/evaluateHealth, <NO RESPONSE>}
com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerConversionException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.netflix.spinnaker.orca.deploymentmonitor.models.DeploymentStep` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('bogus')
 at [Source: (retrofit.ExceptionCatchingTypedInput$ExceptionCatchingInputStream); line: 1, column: 13] (through reference chain: com.netflix.spinnaker.orca.deploymentmonitor.models.EvaluateHealthResponse["nextStep"])
	at com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler.handleError(SpinnakerRetrofitErrorHandler.java:64)
	at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:242)
@dbyron-sf dbyron-sf force-pushed the deployment-monitor-service-spinnaker-exception branch from 21f7b10 to e9b0afc Compare January 8, 2024 16:43
@dbyron-sf dbyron-sf marked this pull request as ready for review January 8, 2024 16:55
@j-sandy
Copy link
Contributor

j-sandy commented Jan 8, 2024

LGTM

@j-sandy j-sandy added the ready to merge Approved and ready for merge label Jan 8, 2024
@mergify mergify bot added the auto merged Merged automatically by a bot label Jan 8, 2024
@mergify mergify bot merged commit d13aa79 into spinnaker:master Jan 8, 2024
4 checks passed
@dbyron-sf dbyron-sf deleted the deployment-monitor-service-spinnaker-exception branch January 8, 2024 17:35
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.34
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants