Allow expunging a VM on a deleted host when using host cache and ConfigDrive userdata service (#6234)

This commit is contained in:
Pearl Dsilva 2022-04-11 19:49:37 +05:30 committed by GitHub
parent ee2ded8200
commit b6072fc826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,7 @@ import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.host.HostVO;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
@ -563,6 +564,11 @@ public class ConfigDriveNetworkElement extends AdapterBase implements NetworkEle
LOG.debug("Deleting config drive ISO for vm: " + vm.getInstanceName() + " on host: " + hostId); LOG.debug("Deleting config drive ISO for vm: " + vm.getInstanceName() + " on host: " + hostId);
final String isoPath = ConfigDrive.createConfigDrivePath(vm.getInstanceName()); final String isoPath = ConfigDrive.createConfigDrivePath(vm.getInstanceName());
final HandleConfigDriveIsoCommand configDriveIsoCommand = new HandleConfigDriveIsoCommand(isoPath, null, null, false, true, false); final HandleConfigDriveIsoCommand configDriveIsoCommand = new HandleConfigDriveIsoCommand(isoPath, null, null, false, true, false);
HostVO hostVO = _hostDao.findById(hostId);
if (hostVO == null) {
LOG.warn(String.format("Host %s appears to be unavailable, skipping deletion of config-drive ISO on host cache", hostId));
return false;
}
final HandleConfigDriveIsoAnswer answer = (HandleConfigDriveIsoAnswer) agentManager.easySend(hostId, configDriveIsoCommand); final HandleConfigDriveIsoAnswer answer = (HandleConfigDriveIsoAnswer) agentManager.easySend(hostId, configDriveIsoCommand);
if (answer == null) { if (answer == null) {