Skip to content

Commit d7b7bd5

Browse files
authored
Fix infrastructure leak on exception while attaching/detaching volumes in VMware (#10860)
* Handled exception separately to prevent infrastructure data leak
1 parent 1574013 commit d7b7bd5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
import com.cloud.event.ActionEvent;
150150
import com.cloud.event.EventTypes;
151151
import com.cloud.event.UsageEventUtils;
152+
import com.cloud.exception.AgentUnavailableException;
152153
import com.cloud.exception.ConcurrentOperationException;
153154
import com.cloud.exception.InvalidParameterValueException;
154155
import com.cloud.exception.PermissionDeniedException;
@@ -3206,6 +3207,8 @@ private Volume orchestrateDetachVolumeFromVM(long vmId, long volumeId) {
32063207

32073208
try {
32083209
answer = _agentMgr.send(hostId, cmd);
3210+
} catch (AgentUnavailableException e) {
3211+
throw new CloudRuntimeException(String.format("%s. Please contact your system administrator.", errorMsg));
32093212
} catch (Exception e) {
32103213
throw new CloudRuntimeException(errorMsg + " due to: " + e.getMessage());
32113214
}
@@ -4769,6 +4772,11 @@ private VolumeVO sendAttachVolumeCommand(UserVmVO vm, VolumeVO volumeToAttach, L
47694772

47704773
try {
47714774
answer = (AttachAnswer)_agentMgr.send(hostId, cmd);
4775+
} catch (AgentUnavailableException e) {
4776+
if (host != null) {
4777+
volService.revokeAccess(volFactory.getVolume(volumeToAttach.getId()), host, dataStore);
4778+
}
4779+
throw new CloudRuntimeException(String.format("%s. Please contact your system administrator.", errorMsg));
47724780
} catch (Exception e) {
47734781
if (host != null) {
47744782
volService.revokeAccess(volFactory.getVolume(volumeToAttach.getId()), host, dataStore);

0 commit comments

Comments
 (0)