Skip to content

Commit b6072fc

Browse files
authored
Allow expunging a VM on a deleted host when using host cache and ConfigDrive userdata service (#6234)
1 parent ee2ded8 commit b6072fc

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

server/src/main/java/com/cloud/network/element/ConfigDriveNetworkElement.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import javax.inject.Inject;
2525

26+
import com.cloud.host.HostVO;
2627
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
2728
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
2829
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
@@ -563,6 +564,11 @@ private boolean deleteConfigDriveIsoOnHostCache(final VirtualMachine vm, final L
563564
LOG.debug("Deleting config drive ISO for vm: " + vm.getInstanceName() + " on host: " + hostId);
564565
final String isoPath = ConfigDrive.createConfigDrivePath(vm.getInstanceName());
565566
final HandleConfigDriveIsoCommand configDriveIsoCommand = new HandleConfigDriveIsoCommand(isoPath, null, null, false, true, false);
567+
HostVO hostVO = _hostDao.findById(hostId);
568+
if (hostVO == null) {
569+
LOG.warn(String.format("Host %s appears to be unavailable, skipping deletion of config-drive ISO on host cache", hostId));
570+
return false;
571+
}
566572

567573
final HandleConfigDriveIsoAnswer answer = (HandleConfigDriveIsoAnswer) agentManager.easySend(hostId, configDriveIsoCommand);
568574
if (answer == null) {

0 commit comments

Comments
 (0)