Cyborg 数据库模型提案¶
蓝图:https://blueprints.launchpad.net/openstack-cyborg/+spec/cyborg-database-modelling
本规范提出一个新的数据库建模模式,用于跟踪 cyborg 资源
问题描述¶
异构加速资源在云、边缘和高性能计算场景中变得至关重要。这些设备通过针对特定领域的特性定制架构来实现更高的效率。它们提供有效的并行性、有效的内存带宽利用率等。因此,跟踪和部署这些加速器是急需的功能。
用例¶
例如,当用户请求 FPGA 资源时,调度器将使用 placement agent 选择具有请求的 FPGA 资源的适当主机。
例如,当 Nova 选择设备(GPU/FPGA 等)资源提供程序分配给 VM 时,Cyborg 需要在数据库中跟踪分配了哪个确切的设备。另一方面,当资源释放时,Cyborg 需要将其分离并释放确切的资源。
当新设备插入系统(主机)时,Cyborg 需要发现它并将所有相关信息存储到数据库中
此外,当设备从系统中移除时,cyborg 也需要相应地更新数据库。
提议的变更¶
我们需要向 Cyborg 数据库添加 5 个表。第一个是 Devices(设备)。其目的是跟踪异构设备的物理存在。第二个是 AttachHandles(连接句柄),它跟踪将加速器连接到 VM 所需的连接信息。第三个是 ControlPathID 表,本质上包含加速器所在位置和准备连接的设备特定信息。第四个是 ExtARQs(加速器请求)表。它是 Nova 与加速器请求的同步点。最后,还添加了 DeviceProfiles(设备配置文件)表。它跟踪加速器的需求集。
此外,我们需要重用现有的表:Deployables(可部署项)。并删除现有的 Accelerators(加速器)表。
Devices 表包含描述数据中心系统中硬件设备的物理存在所需的所有字段。例如,类型、std_board_info、vendor_board_info 等。此表应由 discovery API 填充。
AttachHandles 表跟踪将加速器连接到 VM 所需的连接信息。其记录是在 Nova 请求连接加速器时生成的。
ControlPathID 表跟踪设备控制路径接口的标识符。例如,PCI PF。也称为设备 ID。设备可能具有多个这样的标识符,在这种情况下,Cyborg 驱动程序需要知道如何处理这些标识符。
ExtARQs 表跟踪 Nova 发送的加速器请求。它包含 Nova 可确认的字段以及 Cyborg 特有的字段。对于 Nova 可确认的字段,它们将用于形成 ARQ 对象。另一方面,对于 cyborg 特有的字段,它们将用于形成 ExtARQ 对象。
DeviceProfiles1 表跟踪加速器的需求集。设备配置文件是用户对一个或多个加速器的需求命名集合。它可以被视为设备的 flavor(风味)。广义上,它包括两件事:特定资源类别的所需数量以及资源提供程序必须满足的要求。虽然资源类别与 Placement 已知的相同,但有些要求对应于 Placement traits(特征),而另一些则对应于 Cyborg 独有的属性。
Deployables 表现在用于描述从给定 Device(在 device_uuid 中引用作为外键)派生的所有资源。 类似地,它包含所有公共属性列以及 parent_id 和 root_id。parent_id 将指向关联的父 deployable,root_id 将指向关联的根 deployable。通过这样做,我们可以形成一个嵌套树结构来表示不同的层次结构。对于 FPGA 未加载任何 bitstreams 的情况,它们仍然会被跟踪为 Deployable,但没有其他 Deployables 引用它。一旦加载了 bitstream,deployables 的结构和属性可以改变。在 Nova 的 Placement 上下文中,deployable 的对应物是 Resource Provider
Accelerators 表现在应该被删除。但是,加速器的概念已经改变,deployable 表跟踪一个 num_accelerators 字段。它表示当前 deployable 可以生成的加速器数量。 此外,一旦分配了加速器,Cyborg 就会创建一个 attach handle,指向相应的 deployable
例如,可以使用设备、deployables、accelerators 和属性在以下方案中形成设备层次网络
-------------------
|Device - FPGA|
-------------------
/\
device_uuid / \ device_uuid
/ \
----------------- -----------------
|-------->| Deployable | | Deployable |<----------|
| ----------------- ----------------- |
root_id| / \ |
| parent_id / parent_id \ root_id |
| / \ |
| / \ |
----------------- ----------------- |
| Deployable |num_accelerators=2 | Deployable |---------|
----------------- -----------------
/ \ ^ ^ -------------
/ \ deployable_id | |--|Attribute A|
/deployable_id \ | -------------
----------------- ----------------- | -------------
|Attach Handle A| |Attach Handle B| |---- |Attribute B|
----------------- ----------------- -------------
Attributes 表应保持与之前相同,包含一个 key(键)和一个 value(值)列,以表示任意的 k-v 对。
例如,bitstream_id 和 function kpi 可以在此表中跟踪。 此外,一个外键 deployable_id 引用 Deployables 表,一个 parent_attribute_id 形成嵌套结构的属性关系。
备选方案¶
或者,与其使用一个扁平的表来跟踪任意层次结构,我们可以在 Cyborg 数据库中使用两个不同的表,一个用于物理函数,一个用于虚拟函数。physical_functions 应该有一个外键约束来引用 Accelerators 表中的 id。 此外,virtual_functions 应该有一个外键约束来引用 physical_functions 中的 id。
此设计的存在问题如下。 首先,它只能跟踪最多 3 层资源层次结构。如果我们需要添加另一层,将需要大量的迁移工作。 其次,即使我们只需要向现有的资源类型添加一些新属性,我们也需要为它们创建新的迁移脚本。 总而言之,维护工作非常繁琐。
数据模型影响¶
如前几节所述,将添加 5 个表:Devices
CREATE TABLE Devices
(
id INTEGER NOT NULL , /*Primary Key*/
uuid VARCHAR2 (36 BYTE) , /*uuid v4 format for the device itself*/
std_board_info TEXT , /*A dictionary with standard fields*/
vendor_board_info TEXT , /*A dictionary with driver-specific keys*/
type VARCHAR2 (30 BYTE) /*Device Type*/
vendor VARCHAR2 (255 BYTE) /*Device vendor*/
model VARCHAR2 (255 BYTE) /*Device model*/
hostname VARCHAR2 (255 BYTE) /*host name to identify which host this device is located*/
) ;
ALTER TABLE Devices ADD CONSTRAINT Devices_PK PRIMARY KEY ( id ) ;
CREATE TABLE AttachHandles
(
id INTEGER NOT NULL , /*Primary Key*/
attach_info TEXT , /*information needed to attach the accelerator to VMs*/
device_id INTEGER NOT NULL /*foreign key references to the devices table*/
handle_type INTEGER NOT NULL , /*An enum to indicate the handle type, such as PCI, mdev, etc*/
) ;
PRIMARY KEY (id),
FOREIGN KEY (device_id) REFERENCES devices(id) ON
DELETE RESTRICT ;
CREATE TABLE DeviceProfiles
(
id INTEGER NOT NULL , /*Primary Key*/
uuid VARCHAR2 (36 BYTE) , /*uuid v4 format for the DeviceProfile itself*/
name VARCHAR2 (32 BYTE) , /*Name of the DeviceProfile*/
json TEXT , /*JSON blob with all the deivce/vendor specifc information*/
) ;
CREATE TABLE ExtARQs
(
id INTEGER NOT NULL , /*Primary Key*/
uuid VARCHAR2 (36 BYTE) , /*uuid v4 format for the ARQ itself*/
state VARCHAR2 (32 BYTE) , /*represents current state of the request*/
device_profile_id INTEGER NOT NULL /*foreign key references to the device profile table*/
hostname VARCHAR2 (255 BYTE) /*host name to identify which host this request is targeting*/
device_rp_uuid VARCHAR2 (36 BYTE) , /*uuid v4 format for the resource provider which this ARQ is pointing to*/
instance_uuid VARCHAR2 (36 BYTE) , /*uuid v4 format for the instance which this ARQ is pointing to*/
attach_handle_id INTEGER NOT NULL /*foreign key references to the attach handle table*/
) ;
PRIMARY KEY (id),
FOREIGN KEY (device_profile_id) REFERENCES DeviceProfiles(id),
FOREIGN KEY (attach_handle_id) REFERENCES AttachHandles(id) ON
DELETE RESTRICT ;
CREATE TABLE ControlPathID
(
id INTEGER NOT NULL , /*Primary Key*/
type_name VARCHAR2 (255 BYTE) , /*Name of the ControlPathID*/
device_id INTEGER NOT NULL , /*Foreign Key to point to the device*/
json TEXT , /*JSON blob for type specific information*/
) ;
此外,Deployables 和 Accelerators 将更改为以下方案
CREATE TABLE Deployables
(
id INTEGER NOT NULL , /*Primary Key*/
parent_id INTEGER , /*Pointer to the parent deployable's primary key*/
root_id INTEGER , /*Pointer to the root deployable's primary key*/
num_accelerators INTEGER , /*Number of accelerators contained in this deployable*/
name VARCHAR2 (32 BYTE) , /*Name of the deployable*/
uuid VARCHAR2 (36 BYTE) , /*uuid v4 format for the deployable itself*/
device_id INTEGER NOT NULL /*foreign key references to the device table*/
) ;
PRIMARY KEY (id),
FOREIGN KEY (device_id) REFERENCES Devices(id) ON
DELETE RESTRICT ;
免责声明:可以向特定表添加更多字段,并且随着实施的进展,模式可能会略有演变。
RPC API 影响¶
本规范的范围之外
REST API 影响¶
本规范的范围之外
安全影响¶
无
通知影响¶
无
其他最终用户影响¶
无
性能影响¶
无
其他部署影响¶
无
开发者影响¶
由于这项工作,开发人员将可以使用新的功能。
实现¶
负责人¶
- 主要负责人
Zhenghao Wang <wangzh21@lenovo.com> Coco Gao <gaojh4@lenovo.com>
工作项¶
创建迁移脚本以向数据库添加两个表
在 sqlalchemy 中创建模型以及相关的 conductor APIs
创建相应的对象
创建 Conductor APIs 以允许资源报告
依赖项¶
测试¶
将添加单元测试以测试 Cyborg 通用驱动程序。
文档影响¶
记录 Cyborg 项目中的 FPGA 建模
参考资料¶
历史记录¶
发布 |
描述 |
|---|---|
Stein |
引入 |