root / docs / design / volume-snapshots.rst @ f67b55ee
History | View | Annotate | Download (8.8 kB)
1 |
==================== |
---|---|
2 |
Volume snapshots |
3 |
==================== |
4 |
|
5 |
The goal of this design document is to record and present the proposed method |
6 |
for Volume snapshotting in Synnefo. We will describe the whole work-flow from |
7 |
the user's API down to Archipelago and up again. |
8 |
|
9 |
Snapshot functionality |
10 |
======================= |
11 |
|
12 |
The snapshot functionality aims to provide the user with the following: |
13 |
|
14 |
a. A thin snapshot of an Archipelago volume: |br| |
15 |
The snapshot should capture the volume's data state at the time the |
16 |
snapshot was requested. |br| |
17 |
**Note:** The VM user is accountable for the consistency of its volume. |
18 |
Journaled filesystems or prior shutdown of the VM is advised. |
19 |
#. Presenting the snapshot instantly as a regular file |
20 |
on Pithos: |br| |
21 |
Users can view their snapshots in Pithos as any other file that they have |
22 |
uploaded and can subsequently download them. |
23 |
#. A registered Synnefo snapshot, ready to be deployed: |br| |
24 |
Essentially, if a snapshotted volume includes an OS installation, it can be |
25 |
used as any other Synnefo OS image. This allows users to create |
26 |
*restoration points* for their VMs. |
27 |
|
28 |
Side goals |
29 |
^^^^^^^^^^ |
30 |
|
31 |
In order to make the snapshot process as slim as possible, the following goals |
32 |
must also be met: |
33 |
|
34 |
a. Low computational/storage overhead: |br| |
35 |
If many users send snapshot requests, the service should be able to respond |
36 |
quick. Also, a snapshotted volume should not incur any significant storage |
37 |
overhead. |
38 |
#. Solid reconciliation process: |br| |
39 |
If a snapshot request fails, the system should do the necessary cleanups or |
40 |
at least make it easy to reconcile the affected databases. |
41 |
|
42 |
Snapshot creation |
43 |
======================== |
44 |
|
45 |
An illustration of the proposed method follows below: |
46 |
|
47 |
|create_snapshot| |
48 |
|
49 |
Each step of the procedure is explained below: |
50 |
|
51 |
#. The Cyclades App receives a snapshot request. The request is expected to |
52 |
originate from the user and be sent via an API client or the Cyclades UI. A |
53 |
valid snapshot request should target an existing volume ID. |
54 |
#. The Cyclades App uses its Pithos Backend to create a `snapshot record`_ in |
55 |
the Pithos database. The snapshot record is explained in the following |
56 |
section. It is initially set with the values that are seen in the diagram. |
57 |
#. The Cyclades App creates a snapshot job and sends it to the Ganeti |
58 |
Master. |
59 |
#. The Ganeti Master in turn, designates the snapshot job to the appropriate |
60 |
Ganeti Noded. |
61 |
#. The Ganeti Noded runs the corresponding Archipelago ``ExtStorage`` script |
62 |
and invokes the Vlmc tool to create the snapshot. |
63 |
#. The Vlmc tool instructs Archipelago to create a snapshot by sending a |
64 |
snapshot request. |
65 |
|
66 |
Once Archipelago has (un)successfully created the snapshot, the response is |
67 |
propagated to the Ganeti Master which in turn creates an event about this |
68 |
snapshot job and its execution result. |
69 |
|
70 |
7. snf-ganeti-eventd is informed about this event, using an ``inotify()`` |
71 |
mechanism, and forwards it to the snf-dispatcher. |
72 |
#. The snf-dispatcher uses its Pithos Backend to update the ``snapshot status`` |
73 |
property of the snapshot record that was created in Step 2. According to the |
74 |
result of the snapshot request, the snapshot status is set as ``Ready`` or |
75 |
``Error``. This means that, as far as Cinder is concerned, the snapshot is |
76 |
ready. |
77 |
#. The ``Available`` attribute however is still ``0``. Swift (Pithos) will make |
78 |
it available (``1``) and thus usable, the first time it will try to ping |
79 |
back (a.k.a. the first time someone tries to access it). |
80 |
|
81 |
Snapshot record |
82 |
^^^^^^^^^^^^^^^^^ |
83 |
|
84 |
The snapshot record has the following attributes: |
85 |
|
86 |
+-------------------+--------------------------------------+---------------+ |
87 |
| Key | Value | Service | |
88 |
+===================+======================================+===============+ |
89 |
| file_name | Generated (string - see below) | Swift | |
90 |
+-------------------+--------------------------------------+---------------+ |
91 |
| available | Generated (boolean) | Swift | |
92 |
+-------------------+--------------------------------------+---------------+ |
93 |
|
94 |
and the following properties: |
95 |
|
96 |
+-------------------+--------------------------------------+---------------+ |
97 |
| Key | Value | Service | |
98 |
+===================+======================================+===============+ |
99 |
| snapshot_name | User-provided (string) | Cinder | |
100 |
+-------------------+--------------------------------------+---------------+ |
101 |
| snapshot_status | Generated (see Cinder API) | Cinder | |
102 |
+-------------------+--------------------------------------+---------------+ |
103 |
| EXCLUDE_ALL_TASKS | Generated (string) | Glance | |
104 |
+-------------------+--------------------------------------+---------------+ |
105 |
|
106 |
The file_name is a string that has the following form:: |
107 |
|
108 |
snf-snap-<vol_id>-<counter> |
109 |
|
110 |
where: |
111 |
|
112 |
* ``<vol_id>`` is the Volume ID and |
113 |
* ``<counter>`` is the number of times that the volume has been snapshotted and |
114 |
increases monotonically. |
115 |
|
116 |
The snapshot name should thus be unique. |
117 |
|
118 |
"Available" attribute |
119 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
120 |
|
121 |
The ``available`` attribute is a Swift attribute that is introduced with |
122 |
snapshots and applies to all Pithos files. When a Pithos file is "available", |
123 |
it means that its map file has been created and points to the correct data. |
124 |
Normally, all Pithos files have their map file properly created before adding a |
125 |
record in the Pithos database. Snapshots however are an exception to this rule, |
126 |
since their map file is created asynchronously. |
127 |
|
128 |
Therefore, the creation of a Pithos file has the following rules: |
129 |
|
130 |
* If the file is a snapshot, the ``available`` attribute is set to "0". |
131 |
* For all other files, the ``available`` attribute is set to "1". |
132 |
|
133 |
**Note:** ``available`` can change from "0" to "1", but never the opposite. |
134 |
|
135 |
The update of the ``available`` attribute happens implicitly after the creation |
136 |
of the snapshot, when a request reads the file record from the |
137 |
Pithos database. The following diagram shows how can a request (download |
138 |
request for example) update the ``available`` attribute. |
139 |
|
140 |
|available_attribute| |
141 |
|
142 |
In short, what happens is: |
143 |
|
144 |
#. The user asks to download the file from the Pithos App. |
145 |
#. The Pithos App checks the file record and finds that the ``available`` |
146 |
attribute is "0". |
147 |
#. It then pings Archipelago to check the status of the map. |
148 |
#. If the map exists, it sets ``available`` to "1" and can use the map file to |
149 |
serve the data. |
150 |
|
151 |
VM creation from snapshot |
152 |
=============================== |
153 |
|
154 |
The following diagram illustrates the VM creation process from a snapshot |
155 |
image. |
156 |
|
157 |
|spawn_from_snapshot| |
158 |
|
159 |
The steps are explained in detail below: |
160 |
|
161 |
#. A user who has the registered Images list (which includes all Snapshots |
162 |
too), requests to create a VM from the Cyclades App, using one of the |
163 |
registered snapshots of the list. |
164 |
#. The Cyclades App sends a VM creation job to the Ganeti Master with the |
165 |
appropriate data. The data differ according to the disk template: |
166 |
|
167 |
* If the template is ext, then the "origin" field has the archipelago map |
168 |
name. |
169 |
* For any other template, the archipelago map name is passed in the "img_id" |
170 |
property of OS parameters. |
171 |
|
172 |
#. The Ganeti Master designates the job to the appropriate Ganeti Noded. |
173 |
#. The Ganeti Noded will create the disks, according to the requested disk |
174 |
template: |
175 |
|
176 |
a. If the disk template is "ext", the following execution path is taken: |
177 |
|
178 |
1. The Ganeti Noded runs the corresponding Archipelago ``ExtStorage`` |
179 |
script and invokes the Vlmc tool. |
180 |
#. The Vlmc tool instructs Archipelago to create a volume from a |
181 |
snapshot. |
182 |
|
183 |
b. If the disk template is other than "ext", e.g. "drbd", Ganeti Noded |
184 |
creates a new, empty disk. |
185 |
|
186 |
#. After the volume has been created, Ganeti Noded instructs snf-image to |
187 |
prepare it for deployment. The parameters that are passed to snf-image are |
188 |
the OS parameters of Step 2, and the main ones for each disk template are |
189 |
shown in the diagram, next to the "Ext?" decision box. According to the disk |
190 |
template, snf-image has two possible execution paths: |
191 |
|
192 |
a. If the disk template is "ext", there is no need to copy any data. |
193 |
Also, the image has the "EXCLUDE_ALL_TASKS" property set to "yes", so |
194 |
snf-image will run no customization scripts and will simply return. |
195 |
b. If the disk template is other than "ext", e.g. "drbd", snf-image will |
196 |
copy the snapshot's data from Pithos to the created DRBD disk. As above, |
197 |
since the image has the "EXCLUDE_ALL_TASKS" property set to "yes", |
198 |
snf-image will run no customization scripts. |
199 |
|
200 |
.. |br| raw:: html |
201 |
|
202 |
<br /> |
203 |
|
204 |
.. |create_snapshot| image:: /images/create-snapshot.png |
205 |
|
206 |
.. |available_attribute| image:: /images/available-attribute.png |
207 |
|
208 |
.. |spawn_from_snapshot| image:: /images/spawn-from-snapshot.png |
209 |
|