Skip to content

Fix infrastructure leak on exception while attaching/detaching volumes in VMware #10860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import javax.inject.Inject;

import com.cloud.exception.AgentUnavailableException;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.InternalIdentity;
Expand Down Expand Up @@ -3165,6 +3166,8 @@ private Volume orchestrateDetachVolumeFromVM(long vmId, long volumeId) {

try {
answer = _agentMgr.send(hostId, cmd);
} catch (AgentUnavailableException e) {
throw new CloudRuntimeException(String.format("%s. Please contact your system administrator. ", errorMsg));
} catch (Exception e) {
throw new CloudRuntimeException(errorMsg + " due to: " + e.getMessage());
}
Expand Down Expand Up @@ -4657,6 +4660,11 @@ private VolumeVO sendAttachVolumeCommand(UserVmVO vm, VolumeVO volumeToAttach, L

try {
answer = (AttachAnswer)_agentMgr.send(hostId, cmd);
} catch (AgentUnavailableException e) {
if (host != null) {
volService.revokeAccess(volFactory.getVolume(volumeToAttach.getId()), host, dataStore);
}
throw new CloudRuntimeException(String.format("%s. Please, contact your system administrator", errorMsg));
} catch (Exception e) {
if (host != null) {
volService.revokeAccess(volFactory.getVolume(volumeToAttach.getId()), host, dataStore);
Expand Down
Loading