| 1 |
==================== |
| 2 |
Acceleration Service |
| 3 |
==================== |
| 4 |
|
| 5 |
The OpenStack Cyborg is running as an acceleration service that allows you to |
| 6 |
manage the lifecycle of accelerating for an instance in cloud computing |
| 7 |
platform. It gives you control over accelerators attached to instances easily. |
| 8 |
|
| 9 |
Overview |
| 10 |
-------- |
| 11 |
|
| 12 |
A good understand on how Cyborg interacts with Nova and Placement help |
| 13 |
operators manage the acceleration service more effectively. |
| 14 |
|
| 15 |
.. image:: ../figures/cyborg-nova-interaction.png |
| 16 |
:width: 700 px |
| 17 |
:scale: 99 % |
| 18 |
:align: center |
| 19 |
|
| 20 |
Coexistence with PCI whitelists |
| 21 |
------------------------------- |
| 22 |
|
| 23 |
The operator tells Nova which PCI devices to claim and to be used by |
| 24 |
configuring the PCI Whitelists mechanism. In addition, the operator installs |
| 25 |
Cyborg drivers in compute nodes and configures/enables them. Those drivers may |
| 26 |
then discover and report some PCI devices. The operator must ensure that both |
| 27 |
configurations are compatible. |
| 28 |
|
| 29 |
Ideally, there is a single way for the operator to identify which PCI |
| 30 |
devices should be claimed by Nova and which by Cyborg. Until that is figured |
| 31 |
out, the operator shall use Cyborg’s configuration file to specify which Cyborg |
| 32 |
drivers are enabled. Since each driver claims specific PCI IDs, the operator |
| 33 |
can and must ensure that none of these PCI IDs are included in Nova’s PCI |
| 34 |
whitelist. |
| 35 |
|
| 36 |
Placement update |
| 37 |
---------------- |
| 38 |
|
| 39 |
Cyborg conductor calls Placement API directly to represent devices and |
| 40 |
accelerators. Some of the intended use cases for the API invocation are: |
| 41 |
|
| 42 |
* Create or delete child RPs under the compute node RP. |
| 43 |
|
| 44 |
* Create or delete custom RCs and custom traits. |
| 45 |
|
| 46 |
* Associate traits with RPs or remove such association. |
| 47 |
|
| 48 |
* Update RP inventory. |
| 49 |
|
| 50 |
Cyborg shall not modify the RPs created by any other component, such as Nova |
| 51 |
virt drivers. |
| 52 |
|
| 53 |
User Requests |
| 54 |
------------- |
| 55 |
|
| 56 |
The user request for accelerators is encapsulated in a device profile, |
| 57 |
which is created and managed by the admin via the Cyborg API. |
| 58 |
|
| 59 |
The structure overview of a ``device_profile`` is like this: |
| 60 |
|
| 61 |
.. code:: json |
| 62 |
|
| 63 |
{ |
| 64 |
"device_profiles":[ |
| 65 |
{ |
| 66 |
"name":"fpga-dp1", |
| 67 |
"uuid":"5518a925-1c2c-49a2-a8bf-0927d9456f3e", |
| 68 |
"description": "", |
| 69 |
"groups":[ |
| 70 |
{ |
| 71 |
"trait:CUSTOM_FPGA_TRAITS":"required", |
| 72 |
"resources:FPGA":"1", |
| 73 |
"accel:bitstream_id":"d5ca2f11-3108-4426-a11c-a959987565df" |
| 74 |
} |
| 75 |
], |
| 76 |
"created_at": "2020-03-10 03:52:15+00:00", |
| 77 |
"updated_at": null, |
| 78 |
"links":[ |
| 79 |
{ |
| 80 |
"href":"http://192.168.32.217/accelerator/v2/device_profiles/5518a925-1c2c-49a2-a8bf-0927d9456f3e", |
| 81 |
"rel":"self" |
| 82 |
} |
| 83 |
] |
| 84 |
} |
| 85 |
] |
| 86 |
} |
| 87 |
|
| 88 |
The device profile is folded into the flavor as an extra spec by the operator, |
| 89 |
as below: |
| 90 |
|
| 91 |
.. code:: bash |
| 92 |
|
| 93 |
openstack flavor set --property 'accel:device_profile=<profile_name>' flavor |
| 94 |
|
| 95 |
Thus the standard Nova API can be used to create an instance with only the |
| 96 |
flavor (without device profiles), like this: |
| 97 |
|
| 98 |
.. code:: bash |
| 99 |
|
| 100 |
openstack server create --flavor f .... # instance creation |
| 101 |
|
| 102 |
In the future, device profile may be used by itself to specify accelerator |
| 103 |
resources for the instance creation API. |
| 104 |
|
| 105 |
Updating the Request Spec |
| 106 |
------------------------- |
| 107 |
|
| 108 |
When the user submits a request to create an instance, as described in Section |
| 109 |
User Requests, Nova needs to call a Cyborg API, to get back the resource |
| 110 |
request groups in the device profile and merge them into the request spec. |
| 111 |
|
| 112 |
This call, like all the others that Nova would make to Cyborg APIs, is done |
| 113 |
through a Keystone-based adapter that would locate the Cyborg service, similar |
| 114 |
to the way Nova calls Placement. A Cyborg client module added to Nova, will |
| 115 |
encapsulate such calls. |
| 116 |
|
| 117 |
VM images in Glance may be associated with image properties (other than image |
| 118 |
traits), such as bitstream/function IDs needed for that image. So, Nova should |
| 119 |
pass the VM image UUID from the request spec to Cyborg. |
| 120 |
|
| 121 |
The groups in the device profile are numbered by Cyborg. The request groups |
| 122 |
that are merged into the request spec are numbered by Nova. These numberings |
| 123 |
would not be the same in general, i.e., the N-th device profile group may not |
| 124 |
correspond to the N-th request group in the request spec. |
| 125 |
|
| 126 |
When the device profile request groups are added to other request groups in the |
| 127 |
flavor, the group_policy of the flavor shall govern the overall semantics of |
| 128 |
all request groups. |
| 129 |
|
| 130 |
Accelerator Requests |
| 131 |
-------------------- |
| 132 |
|
| 133 |
An accelerator request (ARQ) is an object that represents the state of the |
| 134 |
request for an accelerator to be assigned to an instance. The creation and |
| 135 |
management of ARQs are handled by Cyborg, and ARQs are persisted in Cyborg |
| 136 |
database. |
| 137 |
|
| 138 |
An ARQ represents a request for a single accelerator by definition. The |
| 139 |
device profile in the user request may have N request groups, each asking for M |
| 140 |
accelerators, then N * M ARQs will be created for that device profile. |
| 141 |
|
| 142 |
When an ARQ is initially created by Cyborg, it is not yet associated with a |
| 143 |
specific host name or a device resource provider. So it is said to be in an |
| 144 |
unbound state. Subsequently, Nova calls Cyborg to bind the ARQ to a host name, |
| 145 |
a device RP UUID and an instance UUID. If the instance fails to spawn, Nova |
| 146 |
would unbind the ARQ with deleting it. On instance termination, Nova would |
| 147 |
delete the ARQs after unbinding them. |
| 148 |
|
| 149 |
Each ARQ needs to be matched to the specific RP in the allocation candidate |
| 150 |
that Nova has chosen, before the ARQ is bound. The current Nova code maps |
| 151 |
request groups to RPs, while the Cyborg client module in Nova |
| 152 |
(cyborg-client-module) matches ARQs to request groups. The matching is done |
| 153 |
using the request_id field in the RequestGroup object as below: |
| 154 |
|
| 155 |
* The order of request groups in a device profile is not significant, but it is |
| 156 |
preserved by Cyborg. Thus, each device profile request group has a unique |
| 157 |
index. |
| 158 |
|
| 159 |
* When the device profile request groups returned by Cyborg are added to the |
| 160 |
request spec, the request_id field is set to ‘device_profile_<N>’ for the |
| 161 |
N-th device profile request group (starting from zero). The device profile |
| 162 |
name need not be included here because there is only one device profile per |
| 163 |
request spec. |
| 164 |
|
| 165 |
* When Cyborg creates an ARQ for a device profile, it embeds the device profile |
| 166 |
request group index in the ARQ before returning it to Nova. |
| 167 |
|
| 168 |
* The matching is done in two steps: |
| 169 |
|
| 170 |
* Each ARQ is mapped to a specific request group in the request spec using |
| 171 |
the request_id field. |
| 172 |
|
| 173 |
* Each request group is mapped to a specific RP using the same logic as the |
| 174 |
Neutron bandwidth provider. |
| 175 |
|
| 176 |
Cyborg and Nova interaction workflow |
| 177 |
------------------------------------ |
| 178 |
|
| 179 |
This flow is captured by the following sequence diagram, in which the Nova |
| 180 |
conductor and scheduler are together represented as the Nova controller. |
| 181 |
|
| 182 |
.. image:: ../figures/cyborg-nova-interaction-workflow.svg |
| 183 |
|
| 184 |
A Cyborg client module is added to nova (cyborg-client-module). All Cyborg API |
| 185 |
calls are routed through that. |
| 186 |
|
| 187 |
1. The Nova API server receives a ``POST /servers`` API request with a flavor |
| 188 |
that includes a device profile name. |
| 189 |
|
| 190 |
2. The Nova API server calls the Cyborg API |
| 191 |
``GET /v2/device_profiles?name=$device_profile_name`` and gets back |
| 192 |
the device |
| 193 |
profile. The request groups in that device profile are added to the request |
| 194 |
spec. |
| 195 |
|
| 196 |
3. The Nova scheduler invokes Placement and gets a list of allocation |
| 197 |
candidates. It selects one of those candidates and makes claim(s) in |
| 198 |
Placement. The Nova conductor then sends a RPC message |
| 199 |
build_and_run_instances to the Nova compute manager. |
| 200 |
|
| 201 |
4. Nova conductor manager calls the Cyborg API |
| 202 |
``POST /v2/accelerator_requests`` |
| 203 |
with the device profile name. Cyborg creates a set of unbound ARQs for that |
| 204 |
device profile and returns them to Nova. |
| 205 |
|
| 206 |
5. The Cyborg client in Nova matches each ARQ to the resource provider picked |
| 207 |
for that accelerator. |
| 208 |
|
| 209 |
6. The Nova compute manager calls the Cyborg API |
| 210 |
``PATCH /v2/accelerator_requests`` to bind the ARQ with the host name, |
| 211 |
device’s RP UUID and instance UUID. This is an asynchronous call which |
| 212 |
prepares or reconfigures the device in the background. |
| 213 |
|
| 214 |
7. Cyborg, on completion of the bindings (successfully or otherwise), |
| 215 |
calls Nova’s ``POST /os-server-external-events`` API with: |
| 216 |
|
| 217 |
.. code:: |
| 218 |
|
| 219 |
{ |
| 220 |
"events": [ |
| 221 |
{ "name": "accelerator-request-bound", |
| 222 |
"tag": $arq_uuid, |
| 223 |
"server_uuid": $instance_uuid, |
| 224 |
"status": "completed" # or "failed" |
| 225 |
}, |
| 226 |
... |
| 227 |
] |
| 228 |
} |
| 229 |
|
| 230 |
8. The Nova compute manager waits for the notification, subject to the timeout |
| 231 |
mentioned in Section Other deployer impact. It then calls the Cyborg REST |
| 232 |
API ``GET /v2/accelerator_requests?instance=<uuid>&bind_state=resolved`` to |
| 233 |
get the arqs in status ['Bound', 'BindFailed', 'Deleting']. |
| 234 |
|
| 235 |
9. The Nova virt driver uses the bound arqs returned from the Cyborg call |
| 236 |
to compose PCI passthrough devices into the VM’s definition. |
| 237 |
|
| 238 |
10. If there is any error after binding has been initiated, Nova must unbind |
| 239 |
the relevant ARQs by calling Cyborg API. It may then retry on another host |
| 240 |
or delete the (unbound) ARQs for the instance. |