Repository navigation
Extend Preferred storage pool setting to Account, Domain and Cluster scope #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
base: main
Are you sure you want to change the base?
Changes from all commits
70cdd14
6715fc6
bb4fc89
b3dde53
2acce94
45b2f17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| import org.apache.cloudstack.engine.subsystem.api.storage.Scope; | ||
| import org.apache.cloudstack.framework.config.ConfigKey; | ||
| import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; | ||
| import org.apache.commons.lang3.StringUtils; | ||
|
|
||
| import com.cloud.agent.api.Answer; | ||
| import com.cloud.agent.api.Command; | ||
|
|
@@ -177,7 +178,11 @@ public interface StorageManager extends StorageService { | |
| "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.class, "preferred.storage.pool", "Advanced", "", | ||
| "The UUID of preferred storage pool for allocation.", true, ConfigKey.Scope.Account, null); | ||
| "The UUID of preferred storage pool for allocation. It can be set at Account, Domain or Cluster level: " + | ||
| "the Account value takes precedence over the Domain value, " + | ||
| "the Domain value takes precedence over the Cluster value; which takes precedence over the Global value. " + | ||
| "The preferred storage pool is only used if it is suitable for the allocation, otherwise it is ignored.", | ||
| true, List.of(ConfigKey.Scope.Account, ConfigKey.Scope.Domain, ConfigKey.Scope.Cluster), null); | ||
|
|
||
| ConfigKey<Boolean> MountDisabledStoragePool = new ConfigKey<>(Boolean.class, | ||
| "mount.disabled.storage.pool", | ||
|
|
@@ -447,4 +452,25 @@ void connectHostsToPool(DataStore primaryStore, List<Long> hostIds, Scope scope, | |
| static ConfigKey<Boolean> getMountDisabledStoragePool() { | ||
| return MountDisabledStoragePool; | ||
| } | ||
|
|
||
| /** | ||
| * Resolves the preferred storage pool UUID, checking the Account scope first, then the Cluster scope and finally the Global value. | ||
| * @return a pair of the scope where the value was found and the storage pool UUID, or null if it is not set at any level | ||
| */ | ||
| static Pair<ConfigKey.Scope, String> getPreferredStoragePoolUuid(Long accountId, Long clusterId) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why implement this in the interface. We should move the implementation to StorageManagerImpl
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, fixed |
||
| if (accountId != null) { | ||
| String uuid = PreferredStoragePool.valueInScope(ConfigKey.Scope.Account, accountId, true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are already doing account scope, should we also add a domain scope?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added, thanks |
||
| if (StringUtils.isNotBlank(uuid)) { | ||
| return new Pair<>(ConfigKey.Scope.Account, uuid); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nvazquez if the account's pool isnt usable for this vm, should we still try the cluster and then the global pool? right now it stops at the account value, so the cluster setting is ignored
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that may add some complexity to the logic, but can be a good enhancement. Would like to address it in a separate follow up PR, leaving this PR to the extension of the setting only
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nvazquez fine to move the cluster and domain fallback to a follow up, those are new. can we keep the global fallback here though? main still tries the global pool when the account pool isnt usable, so this would break setups that rely on it today |
||
| } | ||
| } | ||
| if (clusterId != null) { | ||
| String uuid = PreferredStoragePool.valueInScope(ConfigKey.Scope.Cluster, clusterId, true); | ||
| if (StringUtils.isNotBlank(uuid)) { | ||
| return new Pair<>(ConfigKey.Scope.Cluster, uuid); | ||
| } | ||
| } | ||
| String uuid = PreferredStoragePool.value(); | ||
| return StringUtils.isNotBlank(uuid) ? new Pair<>(ConfigKey.Scope.Global, uuid) : null; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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
changing from Account to Cluster may be disliked by some users (maybe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @weizhouapache - there is now an option to define multiple scopes per setting: https://docs.cloudstack.apache.org/en/4.22.0.0/installguide/configuration.html#granular-global-configuration-parameters. I will explore this