mprokopchuk commented on code in PR #7760:
URL: https://github.com/apache/cloudstack/pull/7760#discussion_r1272739061
##########
api/src/main/java/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java:
##########
@@ -765,28 +768,33 @@ public ApiCommandResourceType getApiResourceType() {
public void execute() {
UserVm result;
- try {
- CallContext.current().setEventDetails("Vm Id: " + getEntityUuid());
- result = _userVmService.startVirtualMachine(this);
- } catch (ResourceUnavailableException ex) {
- s_logger.warn("Exception: ", ex);
- throw new
ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
- } catch (ResourceAllocationException ex) {
- s_logger.warn("Exception: ", ex);
- throw new
ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, ex.getMessage());
- } catch (ConcurrentOperationException ex) {
- s_logger.warn("Exception: ", ex);
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
ex.getMessage());
- } catch (InsufficientCapacityException ex) {
- StringBuilder message = new StringBuilder(ex.getMessage());
- if (ex instanceof InsufficientServerCapacityException) {
- if
(((InsufficientServerCapacityException)ex).isAffinityApplied()) {
- message.append(", Please check the affinity groups
provided, there may not be sufficient capacity to follow them");
+ CallContext.current().setEventDetails("Vm Id: " + getEntityUuid());
Review Comment:
In this case there is a call made from the command to API:
_userVmService.startVirtualMachine(this);
startVirtualMachine(..) intercepted by ActionEventInterceptor, which needs
entity Id to add it to the event.
If startVirtualMachine(..) called by API layer, entity Id set to the context
from the filter and there is no issue, but if it is called from command or any
other layer, which may not have entity Id, then Id is missing in the event and
event itself does not point to the right resource.
This is why it is set explicitly before making call to the API layer.
As of now I don't see other simple enough way how to add Id to the context.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]