Skip to content

Commit 741aa44

Browse files
author
Wenbing Li
committed
Revert "Log response payload for better troubleshooting (#320)"
This reverts commit 4bdae6e.
1 parent d1e4600 commit 741aa44

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

src/main/java/software/amazon/cloudformation/AbstractWrapper.java

+2-24
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public void processRequest(final InputStream inputStream, final OutputStream out
231231
} finally {
232232
// A response will be output on all paths, though CloudFormation will
233233
// not block on invoking the handlers, but rather listen for callbacks
234-
writeResponse(outputStream, handlerResponse, request);
234+
writeResponse(outputStream, handlerResponse);
235235
publishExceptionCodeAndCountMetrics(request == null ? null : request.getAction(), handlerResponse.getErrorCode());
236236
}
237237
}
@@ -376,9 +376,7 @@ public void processRequest(final InputStream inputStream, final OutputStream out
376376

377377
}
378378

379-
protected void writeResponse(final OutputStream outputStream,
380-
final ProgressEvent<ResourceT, CallbackT> response,
381-
final HandlerRequest<ResourceT, CallbackT> request)
379+
protected void writeResponse(final OutputStream outputStream, final ProgressEvent<ResourceT, CallbackT> response)
382380
throws IOException {
383381
if (response.getResourceModel() != null) {
384382
// strip write only properties on final results, we will need the intact model
@@ -389,21 +387,10 @@ protected void writeResponse(final OutputStream outputStream,
389387
}
390388

391389
String output = this.serializer.serialize(response);
392-
if (response.getStatus() != OperationStatus.IN_PROGRESS) {
393-
// if status is not IN_PROGRESS, it means the response has been sanitized
394-
final String logicalResourceId = getLogicalResourceId(request);
395-
final String stackId = getStackId(request);
396-
this.log(String.format("StackId=%s LogicalResourceId=%s Response=%s", stackId, logicalResourceId, output));
397-
}
398390
outputStream.write(output.getBytes(StandardCharsets.UTF_8));
399391
outputStream.flush();
400392
}
401393

402-
protected void writeResponse(final OutputStream outputStream, final ProgressEvent<ResourceT, CallbackT> response)
403-
throws IOException {
404-
this.writeResponse(outputStream, response, null);
405-
}
406-
407394
protected ResourceT sanitizeModel(final ResourceT model) throws IOException {
408395
// strip write only properties on final results, we will need the intact model
409396
// while provisioning
@@ -587,15 +574,6 @@ protected String getStackId(final HandlerRequest<ResourceT, CallbackT> request)
587574
return null;
588575
}
589576

590-
@VisibleForTesting
591-
protected String getLogicalResourceId(final HandlerRequest<ResourceT, CallbackT> request) {
592-
if (request != null && request.getRequestData() != null) {
593-
return request.getRequestData().getLogicalResourceId();
594-
}
595-
596-
return null;
597-
}
598-
599577
private void replaceInMap(final Map<String, String> targetMap, final Map<String, String> sourceMap) {
600578
if (targetMap == null) {
601579
return;

src/test/java/software/amazon/cloudformation/WrapperTest.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public void invokeHandler_nullResponse_returnsFailure(final String requestDataPa
160160
}
161161

162162
verify(providerEventsLogger).refreshClient();
163-
verify(providerEventsLogger, times(3)).publishLogEvent(any());
163+
verify(providerEventsLogger, times(2)).publishLogEvent(any());
164164
verifyNoMoreInteractions(providerEventsLogger);
165165

166166
// verify output response
@@ -1029,14 +1029,4 @@ public void getStackId_setAndGetStackId() {
10291029
assertThat(stackId).isNotNull();
10301030
assertThat(stackId).isEqualTo("AWSStackId");
10311031
}
1032-
1033-
@Test
1034-
public void getLogicalResourceId_setAndGetLogicalResourceId() {
1035-
final HandlerRequest<TestModel, TestContext> request = new HandlerRequest<>();
1036-
final RequestData<TestModel> requestData = new RequestData<>();
1037-
requestData.setLogicalResourceId("MyResource");
1038-
request.setRequestData(requestData);
1039-
1040-
assertThat(wrapper.getLogicalResourceId(request)).isEqualTo("MyResource");
1041-
}
10421032
}

0 commit comments

Comments
 (0)