From 7778e24bf7bb7bd2c1a19fde5fb711b8d8086446 Mon Sep 17 00:00:00 2001 From: Nathan Johnson Date: Wed, 27 Apr 2016 14:49:50 -0500 Subject: [PATCH] Log responses from asynchronous api commands This is mainly useful so that we can see the job ids in the logs whenever the job is created via the API. --- server/src/com/cloud/api/ApiServer.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index f76b851f5d8..6ec2f18e774 100644 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -686,14 +686,21 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer s_logger.warn(errorMsg); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, errorMsg); } - + final String response; if (objectId != null) { final String objUuid = (objectUuid == null) ? objectId.toString() : objectUuid; - return getBaseAsyncCreateResponse(jobId, (BaseAsyncCreateCmd)asyncCmd, objUuid); + response = getBaseAsyncCreateResponse(jobId, (BaseAsyncCreateCmd)asyncCmd, objUuid); } else { SerializationContext.current().setUuidTranslation(true); - return getBaseAsyncResponse(jobId, asyncCmd); + response = getBaseAsyncResponse(jobId, asyncCmd); } + // Always log response for async for now, I don't think any sensitive data will be in here. + // It might be nice to send this through scrubbing similar to how + // ApiResponseSerializer.toSerializedStringWithSecureLogs works. For now, this gets jobid's + // in the api logs. + log.append(response); + return response; + } else { dispatcher.dispatch(cmdObj, params, false);