From 0da33ad39a6db783f62baf7d5cab41aaeb33fd66 Mon Sep 17 00:00:00 2001 From: abhishek Date: Mon, 27 Dec 2010 11:26:54 -0800 Subject: [PATCH] bug 7673,7645: fixing the vm expunge issue. also modifying the delete pod flow to only check for hosts that are NOT removed from the pod. also, checking for alerts on the pod whilst deleting pod is not right. we should be able to delete a pod regardless of alerts issued on the pod. the resolution of alerts is a separate issue status 7673, 7645: resolved fixed --- .../configuration/ConfigurationManagerImpl.java | 16 ++++++++++------ server/src/com/cloud/vm/UserVmManagerImpl.java | 2 +- .../com/cloud/vm/VirtualMachineManagerImpl.java | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index ca72f13db00..351bc736ff0 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -397,11 +397,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura vmInstance.add(2, "there are virtual machines running in this pod"); tablesToCheck.add(vmInstance); - List alert = new ArrayList(); - alert.add(0, "alert"); - alert.add(1, "pod_id"); - alert.add(2, "there are alerts for this pod"); - tablesToCheck.add(alert); +// List alert = new ArrayList(); +// alert.add(0, "alert"); +// alert.add(1, "pod_id"); +// alert.add(2, "there are alerts for this pod"); +// tablesToCheck.add(alert); for (List table : tablesToCheck) { String tableName = table.get(0); @@ -418,7 +418,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura } String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?"; - + + if(tableName.equals("host")){ + selectSql += " and removed IS NULL"; + } + Transaction txn = Transaction.currentTxn(); try { PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 99da678a76f..3d891f66b0e 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1470,7 +1470,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager vm.setGuestNetmask(null); vm.setGuestMacAddress(null); if (!_itMgr.stateTransitTo(vm, VirtualMachine.Event.ExpungeOperation, null)) { - s_logger.info("vm " + vmId + " is skipped because it is no longer in Destroyed state"); + s_logger.info("vm " + vmId + " is skipped because it is no longer in Destroyed or Error state"); continue; } diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 36e966b8517..09d6660a840 100644 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -586,6 +586,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Cluster _stateMachine.addTransition(State.Creating, VirtualMachine.Event.OperationFailed, State.Error); _stateMachine.addTransition(State.Stopped, VirtualMachine.Event.StartRequested, State.Starting); _stateMachine.addTransition(State.Error, VirtualMachine.Event.DestroyRequested, State.Expunging); + _stateMachine.addTransition(State.Error, VirtualMachine.Event.ExpungeOperation, State.Expunging); _stateMachine.addTransition(State.Stopped, VirtualMachine.Event.DestroyRequested, State.Destroyed); _stateMachine.addTransition(State.Stopped, VirtualMachine.Event.StopRequested, State.Stopped); _stateMachine.addTransition(State.Stopped, VirtualMachine.Event.AgentReportStopped, State.Stopped);