Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 48
Log response payload for better troubleshooting#320
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
26 changes: 24 additions & 2 deletions
26 src/main/java/software/amazon/cloudformation/AbstractWrapper.java
This file contains hidden or 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 |
|---|---|---|
| @@ -231,7 +231,7 @@ public void processRequest(final InputStream inputStream, final OutputStream out | ||
| } finally { | ||
| // A response will be output on all paths, though CloudFormation will | ||
| // not block on invoking the handlers, but rather listen for callbacks | ||
| writeResponse(outputStream, handlerResponse); | ||
| writeResponse(outputStream, handlerResponse, request); | ||
| publishExceptionCodeAndCountMetrics(request == null ? null : request.getAction(), handlerResponse.getErrorCode()); | ||
| } | ||
| } | ||
| @@ -372,7 +372,9 @@ public void processRequest(final InputStream inputStream, final OutputStream out | ||
| } | ||
| protected void writeResponse(final OutputStream outputStream, final ProgressEvent<ResourceT, CallbackT> response) | ||
| protected void writeResponse(final OutputStream outputStream, | ||
| final ProgressEvent<ResourceT, CallbackT> response, | ||
| final HandlerRequest<ResourceT, CallbackT> request) | ||
| throws IOException { | ||
| if (response.getResourceModel() != null) { | ||
| // strip write only properties on final results, we will need the intact model | ||
| @@ -383,10 +385,21 @@ protected void writeResponse(final OutputStream outputStream, final ProgressEven | ||
| } | ||
| String output = this.serializer.serialize(response); | ||
| if (response.getStatus() != OperationStatus.IN_PROGRESS) { | ||
| // if status is not IN_PROGRESS, it means the response has been sanitized | ||
| final String logicalResourceId = getLogicalResourceId(request); | ||
| final String stackId = getStackId(request); | ||
| this.log(String.format("StackId=%s LogicalResourceId=%s Response=%s", stackId, logicalResourceId, output)); | ||
ammokhov marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| outputStream.write(output.getBytes(StandardCharsets.UTF_8)); | ||
| outputStream.flush(); | ||
| } | ||
| protected void writeResponse(final OutputStream outputStream, final ProgressEvent<ResourceT, CallbackT> response) | ||
| throws IOException { | ||
| this.writeResponse(outputStream, response, null); | ||
| } | ||
| protected ResourceT sanitizeModel(final ResourceT model) throws IOException { | ||
| // strip write only properties on final results, we will need the intact model | ||
| // while provisioning | ||
| @@ -570,6 +583,15 @@ protected String getStackId(final HandlerRequest<ResourceT, CallbackT> request) | ||
| return null; | ||
| } | ||
| @VisibleForTesting | ||
| protected String getLogicalResourceId(final HandlerRequest<ResourceT, CallbackT> request) { | ||
| if (request != null && request.getRequestData() != null) { | ||
| return request.getRequestData().getLogicalResourceId(); | ||
| } | ||
| return null; | ||
| } | ||
| private void replaceInMap(final Map<String, String> targetMap, final Map<String, String> sourceMap) { | ||
| if (targetMap == null) { | ||
| return; | ||
12 changes: 11 additions & 1 deletion
12 src/test/java/software/amazon/cloudformation/WrapperTest.java
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
This seems a break change for the generated code. I would suggest you do following to keep backward compatible. And also update the code generate to use new method. In such way, it won't break old code if still use old plugin, but it just won't have additional logging data.
After updated the plugin tool, it can then benefit with new feature.