mirror of https://github.com/apache/cloudstack.git
remove affinity group mappings when a cluster is deleted
This commit is contained in:
parent
af97ea3911
commit
c58dee04d7
|
|
@ -2068,6 +2068,7 @@ public class KubernetesClusterManagerImpl extends ManagerBase implements Kuberne
|
|||
return Transaction.execute((TransactionCallback<Boolean>) status -> {
|
||||
kubernetesClusterDetailsDao.removeDetails(kubernetesClusterId);
|
||||
kubernetesClusterVmMapDao.removeByClusterId(kubernetesClusterId);
|
||||
kubernetesClusterAffinityGroupMapDao.removeByClusterId(kubernetesClusterId);
|
||||
if (kubernetesClusterDao.remove(kubernetesClusterId)) {
|
||||
deleteProjectKubernetesAccountIfNeeded(cluster);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -26,4 +26,6 @@ public interface KubernetesClusterAffinityGroupMapDao extends GenericDao<Kuberne
|
|||
List<KubernetesClusterAffinityGroupMapVO> listByClusterIdAndNodeType(long clusterId, String nodeType);
|
||||
|
||||
List<Long> listAffinityGroupIdsByClusterIdAndNodeType(long clusterId, String nodeType);
|
||||
|
||||
int removeByClusterId(long clusterId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,17 @@ public class KubernetesClusterAffinityGroupMapDaoImpl extends GenericDaoBase<Kub
|
|||
implements KubernetesClusterAffinityGroupMapDao {
|
||||
|
||||
private final SearchBuilder<KubernetesClusterAffinityGroupMapVO> clusterIdAndNodeTypeSearch;
|
||||
private final SearchBuilder<KubernetesClusterAffinityGroupMapVO> clusterIdSearch;
|
||||
|
||||
public KubernetesClusterAffinityGroupMapDaoImpl() {
|
||||
clusterIdAndNodeTypeSearch = createSearchBuilder();
|
||||
clusterIdAndNodeTypeSearch.and("clusterId", clusterIdAndNodeTypeSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||
clusterIdAndNodeTypeSearch.and("nodeType", clusterIdAndNodeTypeSearch.entity().getNodeType(), SearchCriteria.Op.EQ);
|
||||
clusterIdAndNodeTypeSearch.done();
|
||||
|
||||
clusterIdSearch = createSearchBuilder();
|
||||
clusterIdSearch.and("clusterId", clusterIdSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||
clusterIdSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -49,4 +54,11 @@ public class KubernetesClusterAffinityGroupMapDaoImpl extends GenericDaoBase<Kub
|
|||
List<KubernetesClusterAffinityGroupMapVO> maps = listByClusterIdAndNodeType(clusterId, nodeType);
|
||||
return maps.stream().map(KubernetesClusterAffinityGroupMapVO::getAffinityGroupId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeByClusterId(long clusterId) {
|
||||
SearchCriteria<KubernetesClusterAffinityGroupMapVO> sc = clusterIdSearch.create();
|
||||
sc.setParameters("clusterId", clusterId);
|
||||
return remove(sc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue