DaanHoogland commented on code in PR #6891:
URL: https://github.com/apache/cloudstack/pull/6891#discussion_r1018805029


##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -8062,8 +8062,22 @@ private void validateVolumes(List<VolumeVO> volumes) {
     private void detachVolumesFromVm(List<VolumeVO> volumes) {
 
         for (VolumeVO volume : volumes) {
-
-            Volume detachResult = 
_volumeService.detachVolumeViaDestroyVM(volume.getInstanceId(), volume.getId());
+            CallContext vmContext = CallContext.current();
+            // Create new context and inject correct event resource type, id 
and details,
+            // otherwise VOLUME.DETACH event will be associated with 
VirtualMachine and contain VM id and other information.
+            CallContext volumeContext = 
CallContext.register(vmContext.getCallingUserId(), 
vmContext.getCallingAccountId());
+            volumeContext.setEventDetails("Volume Id: " + 
this._uuidMgr.getUuid(Volume.class, volume.getId()) + " Vm Id: " + 
this._uuidMgr.getUuid(VirtualMachine.class, volume.getInstanceId()));
+            volumeContext.setEventResourceType(ApiCommandResourceType.Volume);
+            volumeContext.setEventResourceId(volume.getId());
+            volumeContext.setStartEventId(vmContext.getStartEventId());

Review Comment:
   this comment looks like it should be in the javadoc description of this 
method



-- 
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]

Reply via email to