Skip to content

Commit aad234e

Browse files
committed
Address comments
1 parent 998cada commit aad234e

8 files changed

Lines changed: 39 additions & 53 deletions

File tree

api/src/main/java/com/cloud/user/ResourceLimitService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ public interface ResourceLimitService {
5050
"The default maximum number of projects that can be created for an account",false);
5151
static final ConfigKey<Long> DefaultMaxDomainProjects = new ConfigKey<>("Domain Defaults",Long.class,"max.domain.projects","50",
5252
"The default maximum number of projects that can be created for a domain",false);
53+
static final ConfigKey<Long> DefaultMaxAccountGpus = new ConfigKey<>("Account Defaults",Long.class,"max.account.gpus","20",
54+
"The default maximum number of GPU devices that can be used for an account", false);
55+
static final ConfigKey<Long> DefaultMaxDomainGpus = new ConfigKey<>("Domain Defaults",Long.class,"max.domain.gpus","20",
56+
"The default maximum number of GPU devices that can be used for a domain", false);
57+
static final ConfigKey<Long> DefaultMaxProjectGpus = new ConfigKey<>("Project Defaults",Long.class,"max.project.gpus","20",
58+
"The default maximum number of GPU devices that can be used for a project", false);
5359

5460
static final List<ResourceType> HostTagsSupportingTypes = List.of(ResourceType.user_vm, ResourceType.cpu, ResourceType.memory, ResourceType.gpu);
5561
static final List<ResourceType> StorageTagsSupportingTypes = List.of(ResourceType.volume, ResourceType.primary_storage);

api/src/main/java/org/apache/cloudstack/gpu/GpuService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public interface GpuService extends Manager {
9393
void allocateGpuDevicesToVmOnHost(long vmId, long hostId, List<VgpuTypesInfo> gpuDevices);
9494

9595
/**
96-
* Discover GPU devices on a host by using the GetGpuStatistics command and updating the GPU details for the host.
96+
* Discover GPU devices on a host by using the getGPUStatistics command and updating the GPU details for the host.
9797
*
9898
* @param cmd The command to discover GPU devices.
9999
* @return The list of GPU devices.

engine/components-api/src/main/java/com/cloud/resource/ResourceManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ public interface ResourceManager extends ResourceService, Configurable {
200200
/**
201201
* Check if host has GPU devices available
202202
*
203-
* @param host the host to be checked
204-
* @param groupName: gpuCard name
205-
* @param vgpuType the VGPU type
203+
* @param host the host to be checked
204+
* @param groupName gpuCard name
205+
* @param vgpuType the VGPU type
206206
* @return true when the host has the capacity with given VGPU type
207207
*/
208208
boolean isGPUDeviceAvailable(Host host, String groupName, String vgpuType);
@@ -241,9 +241,9 @@ public interface ResourceManager extends ResourceService, Configurable {
241241
/**
242242
* Return listof available GPU devices
243243
*
244-
* @param hostId, the host to be checked
245-
* @param groupName: gpuCard name
246-
* @param vgpuType the VGPU type
244+
* @param hostId the host to be checked
245+
* @param groupName gpuCard name
246+
* @param vgpuType the VGPU type
247247
* @return List of HostGpuGroupsVO.
248248
*/
249249
List<HostGpuGroupsVO> listAvailableGPUDevice(long hostId, String groupName, String vgpuType);
@@ -258,7 +258,7 @@ public interface ResourceManager extends ResourceService, Configurable {
258258
/**
259259
* Update GPU device details (post VM deployment)
260260
*
261-
* @param vm the VirtualMachine object
261+
* @param vm the VirtualMachine object
262262
* @param gpuDeviceTO GPU device details
263263
*/
264264
void updateGPUDetailsForVmStop(VirtualMachine vm, GPUDeviceTO gpuDeviceTO);

engine/schema/src/main/java/com/cloud/gpu/dao/VGPUTypesDaoImpl.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,27 @@
3939
@Component
4040
public class VGPUTypesDaoImpl extends GenericDaoBase<VGPUTypesVO, Long> implements VGPUTypesDao {
4141

42+
@Inject
43+
protected HostGpuGroupsDao hostGpuGroupsDao;
44+
4245
private static final String LIST_ZONE_POD_CLUSTER_WIDE_GPU_CAPACITIES =
4346
"SELECT host_gpu_groups.group_name, vgpu_type, max_vgpu_per_pgpu, SUM(remaining_capacity) AS remaining_capacity, SUM(max_capacity) AS total_capacity FROM" +
4447
" `cloud`.`vgpu_types` INNER JOIN `cloud`.`host_gpu_groups` ON vgpu_types.gpu_group_id = host_gpu_groups.id INNER JOIN `cloud`.`host`" +
4548
" ON host_gpu_groups.host_id = host.id WHERE host.type = 'Routing' AND vgpu_types.max_capacity > 0 AND host.data_center_id = ?";
46-
private final SearchBuilder<VGPUTypesVO> _searchByGroupId;
47-
private final SearchBuilder<VGPUTypesVO> _searchByGroupIdVGPUType;
48-
@Inject
49-
protected HostGpuGroupsDao _hostGpuGroupsDao;
49+
50+
private final SearchBuilder<VGPUTypesVO> searchByGroupId;
51+
private final SearchBuilder<VGPUTypesVO> searchByGroupIdVGPUType;
5052

5153
public VGPUTypesDaoImpl() {
5254

53-
_searchByGroupId = createSearchBuilder();
54-
_searchByGroupId.and("groupId", _searchByGroupId.entity().getGpuGroupId(), SearchCriteria.Op.EQ);
55-
_searchByGroupId.done();
55+
searchByGroupId = createSearchBuilder();
56+
searchByGroupId.and("groupId", searchByGroupId.entity().getGpuGroupId(), SearchCriteria.Op.EQ);
57+
searchByGroupId.done();
5658

57-
_searchByGroupIdVGPUType = createSearchBuilder();
58-
_searchByGroupIdVGPUType.and("groupId", _searchByGroupIdVGPUType.entity().getGpuGroupId(), SearchCriteria.Op.EQ);
59-
_searchByGroupIdVGPUType.and("vgpuType", _searchByGroupIdVGPUType.entity().getVgpuType(), SearchCriteria.Op.EQ);
60-
_searchByGroupIdVGPUType.done();
59+
searchByGroupIdVGPUType = createSearchBuilder();
60+
searchByGroupIdVGPUType.and("groupId", searchByGroupIdVGPUType.entity().getGpuGroupId(), SearchCriteria.Op.EQ);
61+
searchByGroupIdVGPUType.and("vgpuType", searchByGroupIdVGPUType.entity().getVgpuType(), SearchCriteria.Op.EQ);
62+
searchByGroupIdVGPUType.done();
6163
}
6264

6365
@Override
@@ -103,14 +105,14 @@ public List<VgpuTypesInfo> listGPUCapacities(Long dcId, Long podId, Long cluster
103105

104106
@Override
105107
public List<VGPUTypesVO> listByGroupId(long groupId) {
106-
SearchCriteria<VGPUTypesVO> sc = _searchByGroupId.create();
108+
SearchCriteria<VGPUTypesVO> sc = searchByGroupId.create();
107109
sc.setParameters("groupId", groupId);
108110
return listBy(sc);
109111
}
110112

111113
@Override
112114
public VGPUTypesVO findByGroupIdVGPUType(long groupId, String vgpuType) {
113-
SearchCriteria<VGPUTypesVO> sc = _searchByGroupIdVGPUType.create();
115+
SearchCriteria<VGPUTypesVO> sc = searchByGroupIdVGPUType.create();
114116
sc.setParameters("groupId", groupId);
115117
sc.setParameters("vgpuType", vgpuType);
116118
return findOneBy(sc);
@@ -121,7 +123,7 @@ public void persist(long hostId, HashMap<String, HashMap<String, VgpuTypesInfo>>
121123
Iterator<Entry<String, HashMap<String, VgpuTypesInfo>>> it1 = groupDetails.entrySet().iterator();
122124
while (it1.hasNext()) {
123125
Entry<String, HashMap<String, VgpuTypesInfo>> entry = it1.next();
124-
HostGpuGroupsVO gpuGroup = _hostGpuGroupsDao.findByHostIdGroupName(hostId, entry.getKey());
126+
HostGpuGroupsVO gpuGroup = hostGpuGroupsDao.findByHostIdGroupName(hostId, entry.getKey());
125127
HashMap<String, VgpuTypesInfo> values = entry.getValue();
126128
Iterator<Entry<String, VgpuTypesInfo>> it2 = values.entrySet().iterator();
127129
while (it2.hasNext()) {

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ CREATE TABLE IF NOT EXISTS `cloud`.`vgpu_profile` (
236236
CONSTRAINT `fk_vgpu_profile_card_id` FOREIGN KEY (`card_id`) REFERENCES `gpu_card`(`id`) ON DELETE CASCADE
237237
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='vGPU profiles supported by CloudStack';
238238

239-
240239
-- Create the GPU device table to hold the GPU device information on different hosts
241240
CREATE TABLE IF NOT EXISTS `cloud`.`gpu_device` (
242241
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
@@ -260,7 +259,7 @@ CREATE TABLE IF NOT EXISTS `cloud`.`gpu_device` (
260259
CONSTRAINT `fk_gpu_devices__parent_gpu_device_id` FOREIGN KEY (`parent_gpu_device_id`) REFERENCES `gpu_device` (`id`) ON DELETE SET NULL
261260
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='GPU devices installed on hosts';
262261

263-
262+
-- Add references to GPU tables
264263
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.service_offering', 'vgpu_profile_id', 'bigint unsigned DEFAULT NULL COMMENT "vgpu profile ID"');
265264
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.service_offering', 'gpu_count', 'int unsigned DEFAULT NULL COMMENT "number of GPUs"');
266265
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.service_offering', 'gpu_display', 'boolean DEFAULT false COMMENT "enable GPU display"');

server/src/main/java/com/cloud/configuration/Config.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,14 +1371,6 @@ public enum Config {
13711371
"10",
13721372
"The default maximum number of projects that can be created for an account",
13731373
null),
1374-
DefaultMaxAccountGpus(
1375-
"Account Defaults",
1376-
ManagementServer.class,
1377-
Long.class,
1378-
"max.account.gpus",
1379-
"20",
1380-
"The default maximum number of gpu cores that can be used for an account",
1381-
null),
13821374

13831375
//disabling lb as cluster sync does not work with distributed cluster
13841376
SubDomainNetworkAccess(
@@ -1430,14 +1422,6 @@ public enum Config {
14301422
DefaultMaxDomainSecondaryStorage("Domain Defaults", ManagementServer.class, Long.class, "max.domain.secondary.storage", "800", "The default maximum secondary storage space (in GiB) that can be used for a domain", null),
14311423
DefaultMaxDomainProjects("Domain Defaults",ManagementServer.class,Long.class,"max.domain.projects","50","The default maximum number of projects that can be created for a domain",null),
14321424

1433-
DefaultMaxDomainGpus(
1434-
"Domain Defaults",
1435-
ManagementServer.class,
1436-
Long.class,
1437-
"max.domain.gpus",
1438-
"40",
1439-
"The default maximum number of gpu cores that can be used for a domain",
1440-
null),
14411425
DefaultMaxProjectUserVms(
14421426
"Project Defaults",
14431427
ManagementServer.class,
@@ -1518,14 +1502,6 @@ public enum Config {
15181502
"200",
15191503
"The default maximum primary storage space (in GiB) that can be used for an project",
15201504
null),
1521-
DefaultMaxProjectGpus(
1522-
"Project Defaults",
1523-
ManagementServer.class,
1524-
Long.class,
1525-
"max.project.gpus",
1526-
"20",
1527-
"The default maximum number of gpu cores that can be used for a project",
1528-
null),
15291505

15301506
ProjectInviteRequired(
15311507
"Project Defaults",

server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public boolean configure(final String name, final Map<String, Object> params) th
297297
projectResourceLimitMap.put(Resource.ResourceType.vpc.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectVpcs.key())));
298298
projectResourceLimitMap.put(Resource.ResourceType.cpu.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectCpus.key())));
299299
projectResourceLimitMap.put(Resource.ResourceType.memory.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectMemory.key())));
300-
projectResourceLimitMap.put(Resource.ResourceType.gpu.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectGpus.key())));
300+
projectResourceLimitMap.put(Resource.ResourceType.gpu.name(), DefaultMaxProjectGpus.value());
301301
projectResourceLimitMap.put(Resource.ResourceType.primary_storage.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxProjectPrimaryStorage.key())));
302302
projectResourceLimitMap.put(Resource.ResourceType.secondary_storage.name(), MaxProjectSecondaryStorage.value());
303303
projectResourceLimitMap.put(Resource.ResourceType.backup.name(), Long.parseLong(_configDao.getValue(BackupManager.DefaultMaxProjectBackups.key())));
@@ -314,7 +314,7 @@ public boolean configure(final String name, final Map<String, Object> params) th
314314
accountResourceLimitMap.put(Resource.ResourceType.vpc.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountVpcs.key())));
315315
accountResourceLimitMap.put(Resource.ResourceType.cpu.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountCpus.key())));
316316
accountResourceLimitMap.put(Resource.ResourceType.memory.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountMemory.key())));
317-
accountResourceLimitMap.put(Resource.ResourceType.gpu.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountGpus.key())));
317+
accountResourceLimitMap.put(Resource.ResourceType.gpu.name(), DefaultMaxAccountGpus.value());
318318
accountResourceLimitMap.put(Resource.ResourceType.primary_storage.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxAccountPrimaryStorage.key())));
319319
accountResourceLimitMap.put(Resource.ResourceType.secondary_storage.name(), MaxAccountSecondaryStorage.value());
320320
accountResourceLimitMap.put(Resource.ResourceType.project.name(), DefaultMaxAccountProjects.value());
@@ -335,7 +335,7 @@ public boolean configure(final String name, final Map<String, Object> params) th
335335
domainResourceLimitMap.put(Resource.ResourceType.primary_storage.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainPrimaryStorage.key())));
336336
domainResourceLimitMap.put(Resource.ResourceType.secondary_storage.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainSecondaryStorage.key())));
337337
domainResourceLimitMap.put(Resource.ResourceType.project.name(), DefaultMaxDomainProjects.value());
338-
domainResourceLimitMap.put(Resource.ResourceType.gpu.name(), Long.parseLong(_configDao.getValue(Config.DefaultMaxDomainGpus.key())));
338+
domainResourceLimitMap.put(Resource.ResourceType.gpu.name(), DefaultMaxDomainGpus.value());
339339
domainResourceLimitMap.put(Resource.ResourceType.backup.name(), Long.parseLong(_configDao.getValue(BackupManager.DefaultMaxDomainBackups.key())));
340340
domainResourceLimitMap.put(Resource.ResourceType.backup_storage.name(), Long.parseLong(_configDao.getValue(BackupManager.DefaultMaxDomainBackupStorage.key())));
341341
domainResourceLimitMap.put(Resource.ResourceType.bucket.name(), Long.parseLong(_configDao.getValue(BucketApiService.DefaultMaxDomainBuckets.key())));
@@ -2291,7 +2291,10 @@ public ConfigKey<?>[] getConfigKeys() {
22912291
ResourceLimitHostTags,
22922292
ResourceLimitStorageTags,
22932293
DefaultMaxAccountProjects,
2294-
DefaultMaxDomainProjects
2294+
DefaultMaxDomainProjects,
2295+
DefaultMaxAccountGpus,
2296+
DefaultMaxDomainGpus,
2297+
DefaultMaxProjectGpus
22952298
};
22962299
}
22972300

tools/marvin/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
raise RuntimeError("python setuptools is required to build Marvin")
2828

2929

30-
VERSION = "4.21.0.0"
30+
VERSION = "4.21.0.0-SNAPSHOT"
3131

3232
setup(name="Marvin",
3333
version=VERSION,

0 commit comments

Comments
 (0)