forked from spinnaker/gate
-
Notifications
You must be signed in to change notification settings - Fork 10
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
OP-7604 : Handling Exceptions #48
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
deb7722
OP-7604: Added log to see status code
rahul-chekuri 33a0098
OP-7604: returning response to avoid status code issue
rahul-chekuri 21effb1
OP-7604: logs statements
rahul-chekuri 0d34bae
OP-7604: logs statements
rahul-chekuri 6829e5d
OP-7604: logs statements
rahul-chekuri 86be87d
OP-7604: logs statements
rahul-chekuri e3060d7
OP-7604: Handling exception cases
rahul-chekuri a6bd66e
OP-7604: Handling exception cases
rahul-chekuri 21abf31
OP-7604: Handling exception cases
rahul-chekuri af37578
OP-7604: Handling exception cases
rahul-chekuri 5d77506
OP-7604: Handling exception cases
rahul-chekuri ec2d17b
OP-7604: Handling exception cases
rahul-chekuri 3ead41b
OP-7604: Handling exception cases
rahul-chekuri 363291a
OP-7604: Removed copy right
rahul-chekuri 63d9862
OP-7604: Logging the errors
rahul-chekuri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import java.util.stream.Collectors | |
import com.netflix.spinnaker.gate.config.ServiceConfiguration | ||
import com.netflix.spinnaker.gate.services.internal.OpsmxOesService | ||
import com.netflix.spinnaker.security.AuthenticatedRequest | ||
import com.netflix.spinnaker.gate.exceptions.OesRequestException | ||
|
||
import groovy.util.logging.Slf4j | ||
import io.swagger.annotations.ApiOperation | ||
|
@@ -319,16 +320,24 @@ class OpsmxOesController { | |
else | ||
headersMap.putAt(key,"") | ||
} | ||
AuthenticatedRequest.propagate { | ||
def obj = AuthenticatedRequest.propagate { | ||
def request = new Request.Builder() | ||
.url(serviceConfiguration.getServiceEndpoint("opsmx").url +"/oes/accountsConfig/spinnakerX509") | ||
.headers(Headers.of(headersMap)) | ||
.post(uploadFileOkHttp(data,files)) | ||
.build() | ||
|
||
def response = okHttpClient.newCall(request).execute() | ||
return response.body()?.string() ?: "Unknown reason: " + response.code() | ||
}.call() as Object | ||
return response | ||
}.call() as okhttp3.Response | ||
|
||
if (!obj.isSuccessful()) { | ||
def error = obj.body().string(); | ||
log.error("Failed to setup the Spinnaker : {}", error) | ||
throw new OesRequestException(error) | ||
} else{ | ||
return obj.body()?.string() ?: "Unknown reason: " + obj.code() as Object | ||
} | ||
} | ||
|
||
private Object createOrUpdateSpinnaker(MultipartFile files, String data, String version) { | ||
|
@@ -340,16 +349,25 @@ class OpsmxOesController { | |
else | ||
headersMap.putAt(key,"") | ||
} | ||
AuthenticatedRequest.propagate { | ||
def obj = AuthenticatedRequest.propagate { | ||
def request = new Request.Builder() | ||
.url(serviceConfiguration.getServiceEndpoint("opsmx").url +"/oes/accountsConfig/version/spinnakerX509".replace("version", version)) | ||
.headers(Headers.of(headersMap)) | ||
.post(uploadFileOkHttp(data,files)) | ||
.build() | ||
|
||
def response = okHttpClient.newCall(request).execute() | ||
return response.body()?.string() ?: "Unknown reason: " + response.code() | ||
}.call() as Object | ||
return response | ||
}.call() as okhttp3.Response | ||
|
||
if (!obj.isSuccessful()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add log error |
||
def error = obj.body().string(); | ||
log.error("Failed to setup the Spinnaker : {}", error) | ||
throw new OesRequestException(error) | ||
} else{ | ||
return obj.body()?.string() ?: "Unknown reason: " + obj.code() as Object | ||
} | ||
|
||
} | ||
|
||
private String addOrUpdateCloudProverAccount(MultipartFile files, String data) { | ||
|
12 changes: 12 additions & 0 deletions
12
gate-web/src/main/java/com/netflix/spinnaker/gate/exceptions/OesRequestException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.netflix.spinnaker.gate.exceptions; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) | ||
public class OesRequestException extends RuntimeException { | ||
|
||
public OesRequestException(String message) { | ||
super(message); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add log error