server: fix remove management server (#12147)

Fixes #12137

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
Abhishek Kumar 2026-01-27 15:01:20 +05:30 committed by GitHub
parent cabd9a98e1
commit 5fd5b62570
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 7 deletions

View File

@ -682,15 +682,15 @@ import com.cloud.alert.AlertManager;
import com.cloud.alert.AlertVO;
import com.cloud.alert.dao.AlertDao;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.query.dao.ManagementServerJoinDao;
import com.cloud.api.query.dao.StoragePoolJoinDao;
import com.cloud.api.query.vo.ManagementServerJoinVO;
import com.cloud.api.query.vo.StoragePoolJoinVO;
import com.cloud.capacity.Capacity;
import com.cloud.capacity.CapacityVO;
import com.cloud.capacity.dao.CapacityDao;
import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
import com.cloud.cluster.ClusterManager;
import com.cloud.cluster.ManagementServerHostVO;
import com.cloud.cluster.dao.ManagementServerHostDao;
import com.cloud.configuration.Config;
import com.cloud.configuration.ConfigurationManagerImpl;
import com.cloud.consoleproxy.ConsoleProxyManagementState;
@ -790,7 +790,6 @@ import com.cloud.storage.GuestOSHypervisorVO;
import com.cloud.storage.GuestOSVO;
import com.cloud.storage.GuestOsCategory;
import com.cloud.storage.ScopeType;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.storage.Storage;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool;
@ -807,6 +806,7 @@ import com.cloud.storage.dao.StoragePoolTagsDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.secondary.SecondaryStorageVmManager;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.tags.ResourceTagVO;
import com.cloud.tags.dao.ResourceTagDao;
import com.cloud.template.TemplateManager;
@ -1045,7 +1045,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@Inject
private BackupManager backupManager;
@Inject
protected ManagementServerJoinDao managementServerJoinDao;
protected ManagementServerHostDao managementServerHostDao;
@Inject
ClusterManager _clusterMgr;
@ -5875,7 +5875,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
@ActionEvent(eventType = EventTypes.EVENT_MANAGEMENT_SERVER_REMOVE, eventDescription = "removing Management Server")
public boolean removeManagementServer(RemoveManagementServerCmd cmd) {
final Long id = cmd.getId();
ManagementServerJoinVO managementServer = managementServerJoinDao.findById(id);
ManagementServerHostVO managementServer = managementServerHostDao.findById(id);
if (managementServer == null) {
throw new InvalidParameterValueException(String.format("Unable to find a Management Server with ID equal to [%s].", id));
@ -5885,8 +5885,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
throw new InvalidParameterValueException(String.format("Unable to remove Management Server with ID [%s]. It can only be removed when it is in the [%s] state, however currently it is in the [%s] state.", managementServer.getUuid(), ManagementServerHost.State.Down.name(), managementServer.getState().name()));
}
managementServer.setRemoved(new Date());
return managementServerJoinDao.update(id, managementServer);
managementServerHostDao.remove(id);
return true;
}