Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(clouddriver): Throw SpinnakerHttpException when Http status is 40…
…3 in DetermineSourceServerGroupTask (#4710) * test(clouddriver): Demonstrate bug in DetermineSourceServerGroupTask This task/class is suppose to throw a SpinnakerHttpException when a HTTP forbidden 403 error occurs, but instead it returns TaskResult in which the execution status and exception message is wrapped. This task/class actually makes a couple of oortService API calls: 1 - oortService.getTargetServerGroup() - API to fetch the server group based on the target. 2 - oortService.getServerGroupsFromClusterTyped() - API to fetch server group based on server group name. From the commit: 84a7106 , OortService uses SpinnakerRetrofitErrorHandler so, the expectation is to throw SpinnakerHttpException. * fix(clouddriver): Throw SpinnakerHttpException when Http status is 403 in DetermineSourceServerGroupTask This task earlier returns TaskResult with RUNNING status and exception message in context when Forbidden error 403 has occurred. With the new changes/fix it now throws SpinnakerHttpException in this scenario making it in compliance with the commit: 84a7106 Here is the stack trace that would demonstrate the bug and the fix - Before Fix: TaskResult(status=RUNNING, context={lastException=Status: 403, URL: http://localhost:39831/applications/testCluster/clusters/test/testCluster/aws/us-east-1/serverGroups/target/ancestor_asg_dynamic, Message: Forbidden com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerHttpException: Status: 403, URL: http://localhost:39831/applications/testCluster/clusters/test/testCluster/aws/us-east-1/serverGroups/target/ancestor_asg_dynamic, Message: Forbidden at com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler.handleError(SpinnakerRetrofitErrorHandler.java:55) at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:242) at jdk.proxy3/jdk.proxy3.$Proxy21.getTargetServerGroup(Unknown Source) at com.netflix.spinnaker.orca.clouddriver.OortService$getTargetServerGroup.call(Unknown Source) at com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.TargetServerGroupResolver$_resolveByTarget_closure2.doCall(TargetServerGroupResolver.groovy:76) at com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.TargetServerGroupResolver$_resolveByTarget_closure2.doCall(TargetServerGroupResolver.groovy) , attempt=2, consecutiveNotFound=0}, outputs={}) After Fix: 2024-04-24 16:48:25.900 ERROR --- [ Test worker] .n.s.o.c.p.s.s.TargetServerGroupResolver : [] Unable to locate ancestor_asg_dynamic in test/us-east-1/testCluster com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerHttpException: Status: 403, URL: http://localhost:32773/applications/testCluster/clusters/test/testCluster/aws/us-east-1/serverGroups/target/ancestor_asg_dynamic, Message: Forbidden at com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler.handleError(SpinnakerRetrofitErrorHandler.java:55) at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:242) at jdk.proxy3/jdk.proxy3.$Proxy21.getTargetServerGroup(Unknown Source) at com.netflix.spinnaker.orca.clouddriver.OortService$getTargetServerGroup.call(Unknown Source) at com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.TargetServerGroupResolver$_resolveByTarget_closure2.doCall(TargetServerGroupResolver.groovy:76) at com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.TargetServerGroupResolver$_resolveByTarget_closure2.doCall(TargetServerGroupResolver.groovy) --------- Co-authored-by: Pranav-b-7 <[email protected]>
- Loading branch information