Skip to content

Commit f253a2d

Browse files
vishesh92rohityadavcloud
authored andcommitted
server: Add check on host's status while deleting config drive on host cache (apache#7584)
This PR adds a check on host's status. Without this if the agent is not in Up or Connecting state, expunging of a VM fails. Steps to reproduce: - Enable vm.configdrive.force.host.cache.use in Global Configuration. - Create a L2 network with config drive - Deploy a vm with the L2 network created in previous step - Stop the vm and destroy vm (not expunge it) - Stop the cloudstack-agent on the VM's host - Expunge the vm Fixes: apache#7428 (cherry picked from commit 0acc66f) Signed-off-by: Rohit Yadav <[email protected]>
1 parent 0574087 commit f253a2d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717
package com.cloud.network.element;
1818

19+
import java.util.Arrays;
1920
import java.util.HashMap;
2021
import java.util.List;
2122
import java.util.Map;
@@ -50,6 +51,7 @@
5051
import com.cloud.exception.ResourceUnavailableException;
5152
import com.cloud.exception.UnsupportedServiceException;
5253
import com.cloud.host.dao.HostDao;
54+
import com.cloud.host.Status;
5355
import com.cloud.hypervisor.HypervisorGuruManager;
5456
import com.cloud.network.Network;
5557
import com.cloud.network.Network.Capability;
@@ -571,6 +573,10 @@ private boolean deleteConfigDriveIsoOnHostCache(final VirtualMachine vm, final L
571573
LOG.warn(String.format("Host %s appears to be unavailable, skipping deletion of config-drive ISO on host cache", hostId));
572574
return false;
573575
}
576+
if (!Arrays.asList(Status.Up, Status.Connecting).contains(hostVO.getStatus())) {
577+
LOG.warn(String.format("Host status %s is not Up or Connecting, skipping deletion of config-drive ISO on host cache", hostId));
578+
return false;
579+
}
574580

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

0 commit comments

Comments
 (0)