- Notifications
You must be signed in to change notification settings - Fork2.9k
Commit68eb128
pkg/hooks: Version the hook structure and add 1.0.0 hooks
This shifts the matching logic out of libpod/container_internal andinto the hook package, where we can reuse it after vendoring intoCRI-O. It also adds unit tests with almost-complete coverage. Nowlibpod is even more isolated from the hook internals, which makes itfairly straightforward to bump the hook config file to 1.0.0. I'vedubbed the old format 0.1.0, although it doesn't specify an explicitversion. Motivation for some of my changes with 1.0.0:* Add an explicit version field. This will make any future JSON structure migrations more straightforward by avoiding the need for version-guessing heuristics.* Collect the matching properties in a new When sub-structure. This makes the root Hook structure easier to understand, because you don't have to read over all the matching properties when wrapping your head around Hook.* Replace the old 'hook' and 'arguments' with a direct embedding of the runtime-spec's hook structure. This provides access to additional upstream properties (args[0], env, and timeout) and avoids the complication of a CRI-O-specific analog structure.* Add a 'when.always' property. You can usually accomplish this effect in another way (e.g. when.commands = [".*"]), but having a boolean explicitly for this use-case makes for easier reading and writing.* Replace the previous annotations array with an annotations map. The 0.1.0 approach matched only the values regardless of key, and that seems unreliable.* Replace 'cmds' with 'when.commands', because while there are a few ways to abbreviate "commands", there's only one way to write it out in full ;). This gives folks one less thing to remember when writing hook JSON.* Replace the old "inject if any specified condition matches" with "inject if all specified conditions match". This allows for more precise targeting. Users that need more generous targeting can recover the previous behavior by creating a separate 1.0.0 hook file for each specified 0.1.0 condition.I've added doc-compat support for the various pluralizations of the0.1.0 properties. Previously, the docs and code were not inagreement. More on this particular facet in [1].I've updated the docs to point out that the annotations being matchedare the OCI config annotations. This differs from CRI-O, where theannotations used are the Kubernetes-supplied annotations [2,3]. Forexample, io.kubernetes.cri-o.Volumes [4] is part of CRI-O's runtimeconfig annotations [5], but not part of the Kubernetes-suppliedannotations CRI-O uses for matching hooks.The Monitor method supports the CRI-O use-case [6]. podman doesn'tneed it directly, but CRI-O will need it when we vendor this packagethere.I've used nvidia-container-runtime-hook for the annotation examplesbecause Dan mentioned the Nvidia folks as the motivation behindannotation matching. The environment variables are documented in [7].The 0.1.0 hook config, which does not allow for environment variables,only works because runc currently leaks the host environment into thehooks [8]. I haven't been able to find documentation for their usualannotation trigger or hook-install path, so I'm just guessing there.[1]:cri-o/cri-o#1235[2]:https://github.com/kubernetes-incubator/cri-o/blob/v1.10.0/server/container_create.go#L760[3]:https://github.com/kubernetes-incubator/cri-o/blob/v1.10.0/server/container_create.go#L772[4]:https://github.com/kubernetes-incubator/cri-o/blob/v1.10.0/pkg/annotations/annotations.go#L97-L98[5]:https://github.com/kubernetes-incubator/cri-o/blob/v1.10.0/server/container_create.go#L830-L834[6]:cri-o/cri-o#1345[7]:https://github.com/NVIDIA/nvidia-container-runtime/tree/v1.3.0-1#environment-variables-oci-spec[8]:opencontainers/runc#1738Signed-off-by: W. Trevor King <wking@tremily.us>Closes:#686Approved by: mheon1 parent9657cd6 commit68eb128
File tree
19 files changed
+1822
-255
lines changed- cmd/podman
- libpod
- pkg/hooks
- 0.1.0
- 1.0.0
19 files changed
+1822
-255
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
| 40 | + | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
139 | | - | |
| 140 | + | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
1064 | 1063 | | |
1065 | 1064 | | |
1066 | 1065 | | |
1067 | | - | |
| 1066 | + | |
1068 | 1067 | | |
1069 | 1068 | | |
1070 | 1069 | | |
| |||
1283 | 1282 | | |
1284 | 1283 | | |
1285 | 1284 | | |
1286 | | - | |
1287 | | - | |
1288 | | - | |
1289 | | - | |
1290 | | - | |
1291 | | - | |
1292 | | - | |
1293 | | - | |
1294 | | - | |
1295 | | - | |
1296 | | - | |
1297 | | - | |
1298 | | - | |
1299 | | - | |
1300 | | - | |
| 1285 | + | |
| 1286 | + | |
1301 | 1287 | | |
1302 | 1288 | | |
1303 | | - | |
1304 | | - | |
1305 | | - | |
1306 | | - | |
1307 | | - | |
1308 | | - | |
1309 | | - | |
1310 | | - | |
1311 | | - | |
1312 | | - | |
1313 | | - | |
1314 | | - | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
1324 | | - | |
1325 | | - | |
1326 | | - | |
1327 | | - | |
1328 | | - | |
1329 | | - | |
1330 | | - | |
1331 | | - | |
1332 | | - | |
1333 | | - | |
1334 | | - | |
1335 | | - | |
1336 | | - | |
1337 | | - | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
1338 | 1293 | | |
1339 | | - | |
| 1294 | + | |
| 1295 | + | |
1340 | 1296 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
0 commit comments
Comments
(0)