Skip to content

[WIP] Preferred storage pool setting as a cluster setting #9564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ public interface StorageManager extends StorageService {
"If set to true, the disk is created only when there is a suitable storage pool that supports the disk provisioning type specified by the service/disk offering. " +
"If set to false, the disk is created with a disk provisioning type supported by the pool. Default value is false, and this is currently supported for VMware only.",
true, ConfigKey.Scope.Zone);
ConfigKey<String> PreferredStoragePool = new ConfigKey<String>(String.class, "preferred.storage.pool", "Advanced", "",
"The UUID of preferred storage pool for allocation.", true, ConfigKey.Scope.Account, null);
ConfigKey<String> PreferredStoragePool = new ConfigKey<>(String.class, "preferred.storage.pool", "Advanced", "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can have two configurations with same key

  • 1 for global/zone/cluster
  • 2 for global/domain/account

changing from Account to Cluster may be disliked by some users (maybe)

"The UUID of preferred storage pool for allocation.", true, ConfigKey.Scope.Cluster, null);

ConfigKey<Boolean> MountDisabledStoragePool = new ConfigKey<>(Boolean.class,
"mount.disabled.storage.pool",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,20 @@
}

private Optional<StoragePool> getPreferredStoragePool(List<StoragePool> poolList, VirtualMachine vm) {
String accountStoragePoolUuid = null;
String clusterPreferredStoragePoolUuid = null;
Long clusterId = null;

Check warning on line 353 in engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

View check run for this annotation

Codecov / codecov/patch

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java#L352-L353

Added lines #L352 - L353 were not covered by tests
if (vm != null) {
accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());
HostVO host = _hostDao.findById(vm.getHostId());

Check warning on line 355 in engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

View check run for this annotation

Codecov / codecov/patch

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java#L355

Added line #L355 was not covered by tests
if (host != null) {
clusterId = host.getClusterId();
clusterPreferredStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(clusterId);

Check warning on line 358 in engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

View check run for this annotation

Codecov / codecov/patch

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java#L357-L358

Added lines #L357 - L358 were not covered by tests
}
}
Optional<StoragePool> storagePool = getMatchingStoragePool(accountStoragePoolUuid, poolList);
Optional<StoragePool> storagePool = getMatchingStoragePool(clusterPreferredStoragePoolUuid, poolList);

Check warning on line 361 in engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

View check run for this annotation

Codecov / codecov/patch

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java#L361

Added line #L361 was not covered by tests

if (storagePool.isPresent()) {
String storagePoolToString = getReflectOnlySelectedFields(storagePool.get());
logger.debug("The storage pool [{}] was specified for this account [{}] and will be used for allocation.", storagePoolToString, vm.getAccountId());

logger.debug("The storage pool [{}] was specified for this cluster [{}] and will be used for allocation.", storagePoolToString, clusterId);

Check warning on line 365 in engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

View check run for this annotation

Codecov / codecov/patch

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java#L365

Added line #L365 was not covered by tests
} else {
String globalStoragePoolUuid = StorageManager.PreferredStoragePool.value();
storagePool = getMatchingStoragePool(globalStoragePoolUuid, poolList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1917,11 +1917,17 @@
}

private Optional<StoragePool> getPreferredStoragePool(List<StoragePool> poolList, VirtualMachine vm) {
String accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());
Optional<StoragePool> storagePool = getMatchingStoragePool(accountStoragePoolUuid, poolList);
Optional<StoragePool> storagePool = Optional.empty();

Check warning on line 1920 in server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java#L1920

Added line #L1920 was not covered by tests
if (vm.getHostId() != null) {
HostVO host = _hostDao.findById(vm.getHostId());

Check warning on line 1922 in server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java#L1922

Added line #L1922 was not covered by tests
if (host != null) {
String accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(host.getClusterId());
storagePool = getMatchingStoragePool(accountStoragePoolUuid, poolList);

Check warning on line 1925 in server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java#L1924-L1925

Added lines #L1924 - L1925 were not covered by tests
}
}

if (storagePool.isPresent()) {
logger.debug("A storage pool is specified for this account, so we will use this storage pool for allocation: {}", storagePool.get());
logger.debug("A storage pool is specified for this cluster, so we will use this storage pool for allocation: {}", storagePool.get());

Check warning on line 1930 in server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java#L1930

Added line #L1930 was not covered by tests
} else {
String globalStoragePoolUuid = StorageManager.PreferredStoragePool.value();
storagePool = getMatchingStoragePool(globalStoragePoolUuid, poolList);
Expand Down
Loading