This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.18
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.18 by this push:
new 0acc66f51d7 server: Add check on host's status while deleting config
drive on host cache (#7584)
0acc66f51d7 is described below
commit 0acc66f51d7a0fddc59b7e416056a5e744e321dd
Author: Vishesh <[email protected]>
AuthorDate: Fri Jun 23 13:46:22 2023 +0530
server: Add check on host's status while deleting config drive on host
cache (#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: #7428
---
.../java/com/cloud/network/element/ConfigDriveNetworkElement.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git
a/server/src/main/java/com/cloud/network/element/ConfigDriveNetworkElement.java
b/server/src/main/java/com/cloud/network/element/ConfigDriveNetworkElement.java
index be536226034..83900ff2d43 100644
---
a/server/src/main/java/com/cloud/network/element/ConfigDriveNetworkElement.java
+++
b/server/src/main/java/com/cloud/network/element/ConfigDriveNetworkElement.java
@@ -16,6 +16,7 @@
// under the License.
package com.cloud.network.element;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -50,6 +51,7 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.UnsupportedServiceException;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
+import com.cloud.host.Status;
import com.cloud.hypervisor.HypervisorGuruManager;
import com.cloud.network.Network;
import com.cloud.network.Network.Capability;
@@ -573,6 +575,10 @@ public class ConfigDriveNetworkElement extends AdapterBase
implements NetworkEle
LOG.warn(String.format("Host %s appears to be unavailable,
skipping deletion of config-drive ISO on host cache", hostId));
return false;
}
+ if (!Arrays.asList(Status.Up,
Status.Connecting).contains(hostVO.getStatus())) {
+ LOG.warn(String.format("Host status %s is not Up or Connecting,
skipping deletion of config-drive ISO on host cache", hostId));
+ return false;
+ }
final HandleConfigDriveIsoAnswer answer = (HandleConfigDriveIsoAnswer)
agentManager.easySend(hostId, configDriveIsoCommand);
if (answer == null) {