root / doc / design-2.0-os-interface.rst @ 0c55c24b
History | View | Annotate | Download (8.5 kB)
1 | 12222048 | Guido Trotter | Ganeti 2.0 OS Interface |
---|---|---|---|
2 | 12222048 | Guido Trotter | ======================= |
3 | 12222048 | Guido Trotter | |
4 | 12222048 | Guido Trotter | .. contents:: |
5 | 12222048 | Guido Trotter | |
6 | 12222048 | Guido Trotter | Objective |
7 | 12222048 | Guido Trotter | --------- |
8 | 12222048 | Guido Trotter | |
9 | 12222048 | Guido Trotter | We want to update the Ganeti OS Interface, which allows different operating |
10 | 12222048 | Guido Trotter | systems to be installed on instances in a Ganeti cluster. This interface has |
11 | 12222048 | Guido Trotter | been designed for Ganeti 1.2, and needs some changes to be compatible with the |
12 | 12222048 | Guido Trotter | changes introduced in Ganeti 2.0 (for a more through discussion of those please |
13 | 12222048 | Guido Trotter | check the Cluster Parameters design doc). |
14 | 12222048 | Guido Trotter | |
15 | 12222048 | Guido Trotter | |
16 | 12222048 | Guido Trotter | Background |
17 | 12222048 | Guido Trotter | ---------- |
18 | 12222048 | Guido Trotter | |
19 | 12222048 | Guido Trotter | The current Ganeti OS interface, version 5, is tailored for Ganeti 1.2. The |
20 | 12222048 | Guido Trotter | interface is composed by a series of scripts which get called with certain |
21 | 12222048 | Guido Trotter | parameters to perform OS-dependent operations on the cluster. The current |
22 | 12222048 | Guido Trotter | scripts are: |
23 | 43f30ee6 | Iustin Pop | |
24 | 12222048 | Guido Trotter | create |
25 | 12222048 | Guido Trotter | called when a new instance is added to the cluster |
26 | 12222048 | Guido Trotter | export |
27 | 12222048 | Guido Trotter | called to export an instance disk to a stream |
28 | 12222048 | Guido Trotter | import |
29 | 12222048 | Guido Trotter | called to import from a stream to a new instance |
30 | 12222048 | Guido Trotter | rename |
31 | 12222048 | Guido Trotter | called to perform the os-specific operations necessary for renaming an |
32 | 12222048 | Guido Trotter | instance |
33 | 12222048 | Guido Trotter | |
34 | 12222048 | Guido Trotter | Currently these scripts suffer from the limitations of Ganeti 1.2: for example |
35 | 12222048 | Guido Trotter | they accept exactly one block and one swap devices to operate on, rather than |
36 | 12222048 | Guido Trotter | any amount of generic block devices, they blindly assume that an instance will |
37 | 12222048 | Guido Trotter | have just one network interface to operate, they can not be configured to |
38 | 12222048 | Guido Trotter | optimise the instance for a particular hypervisor. |
39 | 12222048 | Guido Trotter | |
40 | 12222048 | Guido Trotter | Since in Ganeti 2.0 we want to support multiple hypervisors, and a non-fixed |
41 | 12222048 | Guido Trotter | number of network and disks the OS interface need to change to transmit the |
42 | 12222048 | Guido Trotter | appropriate amount of information about an instance to its managing operating |
43 | 12222048 | Guido Trotter | system, when operating on it. Moreover since some old assumptions usually used |
44 | 12222048 | Guido Trotter | in OS scripts are no longer valid we need to re-establish a common knowledge on |
45 | 12222048 | Guido Trotter | what can be assumed and what cannot be regarding Ganeti environment. |
46 | 12222048 | Guido Trotter | |
47 | 12222048 | Guido Trotter | |
48 | 12222048 | Guido Trotter | Overview |
49 | 12222048 | Guido Trotter | -------- |
50 | 12222048 | Guido Trotter | |
51 | 12222048 | Guido Trotter | When designing the new OS API our priorities are: |
52 | 12222048 | Guido Trotter | - ease of use |
53 | 12222048 | Guido Trotter | - future extensibility |
54 | 12222048 | Guido Trotter | - ease of porting from the old api |
55 | 12222048 | Guido Trotter | - modularity |
56 | 12222048 | Guido Trotter | |
57 | 12222048 | Guido Trotter | As such we want to limit the number of scripts that must be written to support |
58 | 12222048 | Guido Trotter | an OS, and make it easy to share code between them by uniforming their input. |
59 | 12222048 | Guido Trotter | We also will leave the current script structure unchanged, as far as we can, |
60 | 12222048 | Guido Trotter | and make a few of the scripts (import, export and rename) optional. Most |
61 | 12222048 | Guido Trotter | information will be passed to the script through environment variables, for |
62 | 12222048 | Guido Trotter | ease of access and at the same time ease of using only the information a script |
63 | 12222048 | Guido Trotter | needs. |
64 | 12222048 | Guido Trotter | |
65 | 12222048 | Guido Trotter | |
66 | 12222048 | Guido Trotter | Detailed Design |
67 | 12222048 | Guido Trotter | --------------- |
68 | 12222048 | Guido Trotter | |
69 | 12222048 | Guido Trotter | The Scripts |
70 | 12222048 | Guido Trotter | ~~~~~~~~~~~ |
71 | 12222048 | Guido Trotter | |
72 | 12222048 | Guido Trotter | As in Ganeti 1.2, every OS which wants to be installed in Ganeti needs to |
73 | 12222048 | Guido Trotter | support the following functionality, through scripts: |
74 | 43f30ee6 | Iustin Pop | |
75 | 12222048 | Guido Trotter | create: |
76 | 12222048 | Guido Trotter | used to create a new instance running that OS. This script should prepare the |
77 | 12222048 | Guido Trotter | block devices, and install them so that the new OS can boot under the |
78 | 12222048 | Guido Trotter | specified hypervisor. |
79 | 12222048 | Guido Trotter | export (optional): |
80 | 12222048 | Guido Trotter | used to export an installed instance using the given OS to a format which can |
81 | 12222048 | Guido Trotter | be used to import it back into a new instance. |
82 | 12222048 | Guido Trotter | import (optional): |
83 | 12222048 | Guido Trotter | used to import an exported instance into a new one. This script is similar to |
84 | 12222048 | Guido Trotter | create, but the new instance should have the content of the export, rather |
85 | 12222048 | Guido Trotter | than contain a pristine installation. |
86 | 12222048 | Guido Trotter | rename (optional): |
87 | 12222048 | Guido Trotter | used to perform the internal OS-specific operations needed to rename an |
88 | 12222048 | Guido Trotter | instance. |
89 | 12222048 | Guido Trotter | |
90 | 12222048 | Guido Trotter | If any optional script is not implemented Ganeti will refuse to perform the |
91 | 12222048 | Guido Trotter | given operation on instances using the non-implementing OS. Of course the |
92 | 12222048 | Guido Trotter | create script is mandatory, and it doesn't make sense to support the either the |
93 | 12222048 | Guido Trotter | export or the import operation but not both. |
94 | 12222048 | Guido Trotter | |
95 | 12222048 | Guido Trotter | Incompatibilities with 1.2 |
96 | 12222048 | Guido Trotter | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
97 | 12222048 | Guido Trotter | |
98 | 12222048 | Guido Trotter | We expect the following incompatibilities between the OS scripts for 1.2 and |
99 | 12222048 | Guido Trotter | the ones for 2.0: |
100 | 43f30ee6 | Iustin Pop | |
101 | 12222048 | Guido Trotter | - Input parameters: in 1.2 those were passed on the command line, in 2.0 we'll |
102 | 12222048 | Guido Trotter | use environment variables, as there will be a lot more information and not |
103 | 12222048 | Guido Trotter | all OSes may care about all of it. |
104 | ef79eb82 | Guido Trotter | - Number of calls: export scripts will be called once for each device the |
105 | ef79eb82 | Guido Trotter | instance has, and import scripts once for every exported disk. Imported |
106 | ef79eb82 | Guido Trotter | instances will be forced to have a number of disks greater or equal to the |
107 | ef79eb82 | Guido Trotter | one of the export. |
108 | 188fbf41 | Iustin Pop | - Some scripts are not compulsory: if such a script is missing the relevant |
109 | 188fbf41 | Iustin Pop | operations will be forbidden for instances of that os. This makes it easier |
110 | 188fbf41 | Iustin Pop | to distinguish between unsupported operations and no-op ones (if any). |
111 | 12222048 | Guido Trotter | |
112 | 12222048 | Guido Trotter | |
113 | 12222048 | Guido Trotter | Input |
114 | 12222048 | Guido Trotter | ~~~~~ |
115 | 12222048 | Guido Trotter | |
116 | 12222048 | Guido Trotter | Rather than using command line flags, as they do now, scripts will accept |
117 | 12222048 | Guido Trotter | inputs from environment variables. We expect the following input values: |
118 | 43f30ee6 | Iustin Pop | |
119 | 188fbf41 | Iustin Pop | OS_API_VERSION |
120 | 188fbf41 | Iustin Pop | The version of the OS api that the following parameters comply with; |
121 | 188fbf41 | Iustin Pop | this is used so that in the future we could have OSes supporting |
122 | 188fbf41 | Iustin Pop | multiple versions and thus Ganeti send the proper version in this |
123 | 188fbf41 | Iustin Pop | parameter |
124 | 12222048 | Guido Trotter | INSTANCE_NAME |
125 | 12222048 | Guido Trotter | Name of the instance acted on |
126 | 12222048 | Guido Trotter | HYPERVISOR |
127 | 12222048 | Guido Trotter | The hypervisor the instance should run on (eg. 'xen-pvm', 'xen-hvm', 'kvm') |
128 | 12222048 | Guido Trotter | DISK_COUNT |
129 | 12222048 | Guido Trotter | The number of disks this instance will have |
130 | 12222048 | Guido Trotter | NIC_COUNT |
131 | 12222048 | Guido Trotter | The number of nics this instance will have |
132 | 12222048 | Guido Trotter | DISK_<N>_PATH |
133 | 12222048 | Guido Trotter | Path to the Nth disk. |
134 | 12222048 | Guido Trotter | DISK_<N>_ACCESS |
135 | 12222048 | Guido Trotter | W if read/write, R if read only. OS scripts are not supposed to touch |
136 | 12222048 | Guido Trotter | read-only disks, but will be passed them to know. |
137 | 12222048 | Guido Trotter | DISK_<N>_FRONTEND_TYPE |
138 | 12222048 | Guido Trotter | Type of the disk as seen by the instance. Can be 'scsi', 'ide', 'virtio' |
139 | 12222048 | Guido Trotter | DISK_<N>_BACKEND_TYPE |
140 | 12222048 | Guido Trotter | Type of the disk as seen from the node. Can be 'block', 'file:loop' or |
141 | 12222048 | Guido Trotter | 'file:blktap' |
142 | 12222048 | Guido Trotter | NIC_<N>_MAC |
143 | 12222048 | Guido Trotter | Mac address for the Nth network interface |
144 | 12222048 | Guido Trotter | NIC_<N>_IP |
145 | 12222048 | Guido Trotter | Ip address for the Nth network interface, if available |
146 | 12222048 | Guido Trotter | NIC_<N>_BRIDGE |
147 | 12222048 | Guido Trotter | Node bridge the Nth network interface will be connected to |
148 | 12222048 | Guido Trotter | NIC_<N>_FRONTEND_TYPE |
149 | 12222048 | Guido Trotter | Type of the Nth nic as seen by the instance. For example 'virtio', 'rtl8139', etc. |
150 | 12222048 | Guido Trotter | DEBUG_LEVEL |
151 | 12222048 | Guido Trotter | Whether more out should be produced, for debugging purposes. Currently the |
152 | 12222048 | Guido Trotter | only valid values are 0 and 1. |
153 | 12222048 | Guido Trotter | |
154 | 12222048 | Guido Trotter | These are only the basic variables we are thinking of now, but more may come |
155 | 12222048 | Guido Trotter | during the implementation and they will be documented in the ganeti-os-api man |
156 | 12222048 | Guido Trotter | page. All these variables will be available to all scripts. |
157 | 12222048 | Guido Trotter | |
158 | 12222048 | Guido Trotter | Some scripts will need a few more information to work. These will have |
159 | 12222048 | Guido Trotter | per-script variables, such as for example: |
160 | 43f30ee6 | Iustin Pop | |
161 | 29fc6636 | Guido Trotter | OLD_INSTANCE_NAME |
162 | 29fc6636 | Guido Trotter | rename: the name the instance should be renamed from. |
163 | ef79eb82 | Guido Trotter | EXPORT_DEVICE |
164 | ef79eb82 | Guido Trotter | export: device to be exported, a snapshot of the actual device. The data must be exported to stdout. |
165 | ef79eb82 | Guido Trotter | EXPORT_INDEX |
166 | ef79eb82 | Guido Trotter | export: sequential number of the instance device targeted. |
167 | ef79eb82 | Guido Trotter | IMPORT_DEVICE |
168 | ef79eb82 | Guido Trotter | import: device to send the data to, part of the new instance. The data must be imported from stdin. |
169 | ef79eb82 | Guido Trotter | IMPORT_INDEX |
170 | ef79eb82 | Guido Trotter | import: sequential number of the instance device targeted. |
171 | 12222048 | Guido Trotter | |
172 | 12222048 | Guido Trotter | (Rationale for INSTANCE_NAME as an environment variable: the instance name is |
173 | 12222048 | Guido Trotter | always needed and we could pass it on the command line. On the other hand, |
174 | 12222048 | Guido Trotter | though, this would force scripts to both access the environment and parse the |
175 | 12222048 | Guido Trotter | command line, so we'll move it for uniformity.) |
176 | 12222048 | Guido Trotter | |
177 | 12222048 | Guido Trotter | |
178 | 12222048 | Guido Trotter | Output/Behaviour |
179 | 43f30ee6 | Iustin Pop | ~~~~~~~~~~~~~~~~ |
180 | 12222048 | Guido Trotter | |
181 | ef79eb82 | Guido Trotter | As discussed scripts should only send user-targeted information to stderr. The |
182 | 12222048 | Guido Trotter | create and import scripts are supposed to format/initialise the given block |
183 | 12222048 | Guido Trotter | devices and install the correct instance data. The export script is supposed to |
184 | ef79eb82 | Guido Trotter | export instance data to stdout in a format understandable by the the import |
185 | ef79eb82 | Guido Trotter | script. The data will be compressed by ganeti, so no compression should be |
186 | ef79eb82 | Guido Trotter | done. The rename script should only modify the instance's knowledge of what |
187 | ef79eb82 | Guido Trotter | its name is. |
188 | 12222048 | Guido Trotter | |
189 | 12222048 | Guido Trotter | Other declarative style features |
190 | 12222048 | Guido Trotter | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
191 | 12222048 | Guido Trotter | |
192 | 188fbf41 | Iustin Pop | Similar to Ganeti 1.2, OS specifications will need to provide a |
193 | 188fbf41 | Iustin Pop | 'ganeti_api_version' containing list of numbers matching the version(s) of the |
194 | 188fbf41 | Iustin Pop | api they implement. Ganeti itself will always be compatible with one version of |
195 | 188fbf41 | Iustin Pop | the API and may maintain retrocompatibility if it's feasible to do so. The |
196 | 188fbf41 | Iustin Pop | numbers are one-per-line, so an OS supporting both version 5 and version 20 |
197 | 188fbf41 | Iustin Pop | will have a file containing two lines. This is different from Ganeti 1.2, which |
198 | 188fbf41 | Iustin Pop | only supported one version number. |
199 | 12222048 | Guido Trotter | |
200 | 12222048 | Guido Trotter | In addition to that an OS will be able to declare that it does support only a |
201 | 12222048 | Guido Trotter | subset of the ganeti hypervisors, by declaring them in the 'hypervisors' file. |
202 | 12222048 | Guido Trotter | |
203 | 12222048 | Guido Trotter | |
204 | 12222048 | Guido Trotter | Caveats/Notes |
205 | 43f30ee6 | Iustin Pop | ------------- |
206 | 12222048 | Guido Trotter | |
207 | 12222048 | Guido Trotter | We might want to have a "default" import/export behaviour that just dumps all |
208 | 12222048 | Guido Trotter | disks and restores them. This can save work as most systems will just do this, |
209 | 12222048 | Guido Trotter | while allowing flexibility for different systems. |
210 | 12222048 | Guido Trotter | |
211 | 12222048 | Guido Trotter | Environment variables are limited in size, but we expect that there will be |
212 | 12222048 | Guido Trotter | enough space to store the information we need. If we discover that this is not |
213 | 12222048 | Guido Trotter | the case we may want to go to a more complex API such as storing those |
214 | 12222048 | Guido Trotter | information on the filesystem and providing the OS script with the path to a |
215 | 12222048 | Guido Trotter | file where they are encoded in some format. |