Skip to content

Commit fee2bfc

Browse files
committed
CLOUDSTACK-7344:VOLUME.DELETE usage event missing for VM's in ERROR
state.
1 parent 5607184 commit fee2bfc

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,9 @@ public void destroyVolume(Volume volume) {
13731373
} else {
13741374
volService.destroyVolume(volume.getId());
13751375
}
1376+
// publish usage event for the volume
1377+
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(),
1378+
Volume.class.getName(), volume.getUuid(), volume.isDisplayVolume());
13761379
} catch (Exception e) {
13771380
s_logger.debug("Failed to destroy volume" + volume.getId(), e);
13781381
throw new CloudRuntimeException("Failed to destroy volume" + volume.getId(), e);

server/src/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
import javax.inject.Inject;
3636
import javax.naming.ConfigurationException;
3737

38+
import org.apache.commons.codec.binary.Base64;
39+
import org.apache.log4j.Logger;
40+
3841
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
3942
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
4043
import org.apache.cloudstack.affinity.AffinityGroupService;
@@ -84,8 +87,6 @@
8487
import org.apache.cloudstack.storage.command.DettachCommand;
8588
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
8689
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
87-
import org.apache.commons.codec.binary.Base64;
88-
import org.apache.log4j.Logger;
8990

9091
import com.cloud.agent.AgentManager;
9192
import com.cloud.agent.api.Answer;
@@ -4747,8 +4748,6 @@ public UserVm restoreVMInternal(Account caller, UserVmVO vm, Long newTemplateId)
47474748
// Detach, destroy and create the usage event for the old root volume.
47484749
_volsDao.detachVolume(root.getId());
47494750
volumeMgr.destroyVolume(root);
4750-
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, root.getAccountId(), root.getDataCenterId(), root.getId(), root.getName(),
4751-
Volume.class.getName(), root.getUuid(), root.isDisplayVolume());
47524751

47534752
// For VMware hypervisor since the old root volume is replaced by the new root volume, force expunge old root volume if it has been created in storage
47544753
if (vm.getHypervisorType() == HypervisorType.VMware) {

0 commit comments

Comments
 (0)