Skip to content

Commit

Permalink
Merge pull request #611 from qoxown12/compress
Browse files Browse the repository at this point in the history
DRS 기능 수정
  • Loading branch information
jschoiRR authored Feb 19, 2025
2 parents 0dc584e + edba76a commit 5b2a7b0
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,10 @@ public UserVmResponse newUserVmResponse(ResponseView view, String objectName, Us
userVmResponse.setKvdoInUse(false);
List<VolumeVO> volumesForVm = _volsDao.findUsableVolumesForInstance(userVm.getId());
for (VolumeVO vol : volumesForVm) {
if (vol.getDiskOfferingId() != null) {
DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId());
if (diskOffering.getKvdoEnable()) {
userVmResponse.setKvdoInUse(true);
break;
}
DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId());
if (diskOffering.getKvdoEnable()) {
userVmResponse.setKvdoInUse(true);
break;
}
}
if (details.contains(VMDetails.all) || details.contains(VMDetails.backoff)) {
Expand Down
10 changes: 4 additions & 6 deletions server/src/main/java/com/cloud/resource/ResourceManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1513,12 +1513,10 @@ public Host maintain(final PrepareForMaintenanceCmd cmd) {
for (VMInstanceVO vm : activeVMs) {
List<VolumeVO> volumesForVm = volumeDao.findUsableVolumesForInstance(vm.getId());
for (VolumeVO vol : volumesForVm) {
if (vol.getDiskOfferingId() != null) {
DiskOfferingVO diskOffering = diskOfferingDao.findById(vol.getDiskOfferingId());
if (diskOffering.getKvdoEnable()) {
logger.debug("The host on which maintenance mode is to be set cannot be run because there is a virtual machine using a compressed/deduplicated volume. Check the VM: " + vm.getInstanceName());
throw new InvalidParameterValueException("The host on which maintenance mode is to be set cannot be run because there is a virtual machine using a compressed/deduplicated volume. Check the VM: " + vm.getInstanceName());
}
DiskOfferingVO diskOffering = diskOfferingDao.findById(vol.getDiskOfferingId());
if (diskOffering.getKvdoEnable()) {
logger.debug("The host on which maintenance mode is to be set cannot be run because there is a virtual machine using a compressed/deduplicated volume. Check the VM: " + vm.getInstanceName());
throw new InvalidParameterValueException("The host on which maintenance mode is to be set cannot be run because there is a virtual machine using a compressed/deduplicated volume. Check the VM: " + vm.getInstanceName());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
import com.cloud.org.Cluster;
import com.cloud.server.ManagementServer;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.utils.DateUtil;
Expand Down Expand Up @@ -125,6 +129,12 @@ public class ClusterDrsServiceImpl extends ManagerBase implements ClusterDrsServ
@Inject
ManagementServer managementServer;

@Inject
private VolumeDao volumeDao;

@Inject
private DiskOfferingDao diskOfferingDao;

List<ClusterDrsAlgorithm> drsAlgorithms = new ArrayList<>();

Map<String, ClusterDrsAlgorithm> drsAlgorithmMap = new HashMap<>();
Expand Down Expand Up @@ -449,6 +459,21 @@ Pair<VirtualMachine, Host> getBestMigration(Cluster cluster, ClusterDrsAlgorithm
) {
continue;
}

List<VolumeVO> volumesForVm = volumeDao.findUsableVolumesForInstance(vm.getId());
boolean kvdoVm = false;
for (VolumeVO vol : volumesForVm) {
DiskOfferingVO diskOffering = diskOfferingDao.findById(vol.getDiskOfferingId());
if (diskOffering.getKvdoEnable()) {
kvdoVm = true;
break;
}
}

if (kvdoVm) {
continue;
}

Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Host, Boolean>> hostsForMigrationOfVM = managementServer
.listHostsForMigrationOfVM(
vm, 0L, 500L, null, vmList);
Expand Down
34 changes: 30 additions & 4 deletions server/src/main/java/org/apache/cloudstack/ha/HAManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
import com.cloud.vm.UserVmService;
import com.cloud.org.Cluster;
import com.cloud.resource.ResourceService;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.component.PluggableService;
Expand Down Expand Up @@ -142,6 +146,12 @@ public final class HAManagerImpl extends ManagerBase implements HAManager, Clust
@Inject
private AgentManager _agentMgr;

@Inject
private VolumeDao volumeDao;

@Inject
private DiskOfferingDao diskOfferingDao;

private List<HAProvider<HAResource>> haProviders;
private Map<String, HAProvider<HAResource>> haProviderMap = new HashMap<>();

Expand Down Expand Up @@ -665,10 +675,26 @@ public int compare(Entry<Long, Integer> e1, Entry<Long, Integer> e2) {

//가장 작은 ramsize의 vm을 가장 작은 메모리used의 호스트로 migration
try {
logger.info("===4.vm migration===");
Host destinationHost = resourceService.getHost(minHostId);
logger.info("minEntry.getKey() : " + minEntry.getKey() + ", destinationHost : " + destinationHost);
userVmService.migrateVirtualMachine(minEntry.getKey(), destinationHost);
List<VolumeVO> volumesForVm = volumeDao.findUsableVolumesForInstance(minEntry.getKey());
boolean kvdoVm = false;
for (VolumeVO vol : volumesForVm) {
DiskOfferingVO diskOffering = diskOfferingDao.findById(vol.getDiskOfferingId());
if (diskOffering.getKvdoEnable()) {
kvdoVm = true;
break;
}
}

if (kvdoVm) {
logger.info("===4.vm migration===");
logger.debug("The host on which maintenance mode is to be set cannot be run because there is a virtual machine using a compressed/deduplicated volume. Check the VM id: " + minEntry.getKey());
logger.info("");
} else {
logger.info("===4.vm migration===");
Host destinationHost = resourceService.getHost(minHostId);
logger.info("minEntry.getKey() : " + minEntry.getKey() + ", destinationHost : " + destinationHost);
userVmService.migrateVirtualMachine(minEntry.getKey(), destinationHost);
}
} catch (ResourceUnavailableException ex) {
logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
Expand Down
75 changes: 38 additions & 37 deletions ui/src/views/infra/network/IpRangesTabGuest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,6 @@

<template>
<a-spin :spinning="componentLoading">
<a-button
:disabled="!('createGuestNetworkIpv6Prefix' in $store.getters.apis)"
type="dashed"
style="margin-bottom: 20px; width: 100%"
@click="handleOpenAddIpv6PrefixForm()">
<template #icon><plus-outlined /></template>
{{ $t('label.add.ip.v6.prefix') }}
</a-button>
<a-table
style="overflow-y: auto"
size="small"
:columns="ipv6Columns"
:dataSource="ipv6Prefixes"
:rowKey="record => record.id + record.prefix"
:pagination="false"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'allocated'">
{{ record.usedsubnets + '/' + record.totalsubnets }}
</template>
<template v-if="column.key === 'actions'">
<div class="actions">
<tooltip-button
tooltipPlacement="bottom"
:tooltip="$t('label.delete.ip.v6.prefix')"
type="primary"
icon="delete-outlined"
:danger="true"
@click="handleDeleteIpv6Prefix(record)"
:disabled="!('deleteGuestNetworkIpv6Prefix' in $store.getters.apis)" />
</div>
</template>
</template>
</a-table>
<br>
<br>

<a-button
:disabled="!('createNetwork' in $store.getters.apis)"
type="dashed"
Expand Down Expand Up @@ -97,6 +60,44 @@
</template>
</a-pagination>

<br>
<br>

<a-button
:disabled="!('createGuestNetworkIpv6Prefix' in $store.getters.apis)"
type="dashed"
style="margin-bottom: 20px; width: 100%"
@click="handleOpenAddIpv6PrefixForm()">
<template #icon><plus-outlined /></template>
{{ $t('label.add.ip.v6.prefix') }}
</a-button>
<a-table
style="overflow-y: auto"
size="small"
:columns="ipv6Columns"
:dataSource="ipv6Prefixes"
:rowKey="record => record.id + record.prefix"
:pagination="false"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'allocated'">
{{ record.usedsubnets + '/' + record.totalsubnets }}
</template>
<template v-if="column.key === 'actions'">
<div class="actions">
<tooltip-button
tooltipPlacement="bottom"
:tooltip="$t('label.delete.ip.v6.prefix')"
type="primary"
icon="delete-outlined"
:danger="true"
@click="handleDeleteIpv6Prefix(record)"
:disabled="!('deleteGuestNetworkIpv6Prefix' in $store.getters.apis)" />
</div>
</template>
</template>
</a-table>

<a-modal
v-if="showCreateForm"
:visible="showCreateForm"
Expand Down
6 changes: 3 additions & 3 deletions ui/src/views/network/NicsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</span>
</a-select-option>
</a-select>
<p class="modal-form__label">{{ $t('label.publicip') }}:</p>
<p class="modal-form__label">{{ $t('label.ipaddress') }}:</p>
<a-input v-model:value="addNetworkData.ip"></a-input>
<br>
<a-checkbox v-model:checked="addNetworkData.makedefault">
Expand Down Expand Up @@ -144,7 +144,7 @@

<a-form @finish="submitUpdateIP" v-ctrl-enter="submitUpdateIP">
<div class="modal-form">
<p class="modal-form__label">{{ $t('label.publicip') }}:</p>
<p class="modal-form__label">{{ $t('label.ipaddress') }}:</p>
<a-select
v-if="editNicResource.type==='Shared'"
v-model:value="editIpAddressValue"
Expand Down Expand Up @@ -187,7 +187,7 @@
<a-divider />
<div v-ctrl-enter="submitSecondaryIP">
<div class="modal-form">
<p class="modal-form__label">{{ $t('label.publicip') }}:</p>
<p class="modal-form__label">{{ $t('label.ipaddress') }}:</p>
<a-select
v-if="editNicResource.type==='Shared'"
v-model:value="newSecondaryIp"
Expand Down

0 comments on commit 5b2a7b0

Please sign in to comment.