cs-image-system-tf-docker-plugin 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ .envrc
2
+ # Okta API-integration key material -- never commit
3
+ .private_key.pem
4
+ .private_key.json
5
+ .public_key.json
6
+ *.pem
7
+ __pycache__/
8
+ *.py[cod]
9
+ .pytest_cache/
10
+ *.egg-info/
11
+ dist/
12
+ build/
13
+ .venv/
14
+ .DS_Store
15
+ packages/**/*.code-workspace
16
+ # the IDE rewrites the root workspace file whenever folders are opened: it is the editor's, not the repository's (hygiene XXI)
17
+ /*.code-workspace
18
+ trial
19
+ tfmodules/tftest
20
+ YAML_DUMP.yaml
21
+ .obsidian
22
+ .tofu-plugin-cache/
23
+ _uncommitted/
24
+ target/
25
+ # never publishable, whatever the root (stage 35 refuses them; stage 40's publish-tree checks the policy)
26
+ tfplan
27
+ *.tfstate
28
+ *.tfstate.backup
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,320 @@
1
+ Metadata-Version: 2.5
2
+ Name: cs-image-system-tf-docker-plugin
3
+ Version: 0.1.6
4
+ Summary: The OpenTofu plugin for a container runtime: containers and volumes on a Docker Engine API daemon as module calls
5
+ Project-URL: Repository, https://github.com/infrastructurebuilder/cs-image-system-3
6
+ Project-URL: Documentation, https://github.com/infrastructurebuilder/cs-image-system-3/blob/develop/docs/OPERATIONS.md
7
+ Project-URL: Package README, https://github.com/infrastructurebuilder/cs-image-system-3/blob/develop/packages/tf-docker-plugin/README.md
8
+ Author-email: Mykel Alvis <mykelalvis@infrastructurebuilder.org>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Requires-Python: >=3.13
12
+ Requires-Dist: cs-image-system-base==0.1.6
13
+ Requires-Dist: cs-image-system-contract==0.1.6
14
+ Requires-Dist: cs-image-system-docker-runtime-plugin==0.1.6
15
+ Requires-Dist: cs-image-system-hashicorp-utils==0.1.6
16
+ Requires-Dist: cs-image-system-tf-ebs-instance-plugin==0.1.6
17
+ Requires-Dist: pydantic>=2.13
18
+ Description-Content-Type: text/markdown
19
+
20
+ <!--
21
+ SPDX-FileCopyrightText: 2026 Mykel Alvis <mykelalvis@infrastructurebuilder.org>
22
+
23
+ SPDX-License-Identifier: Apache-2.0
24
+ -->
25
+
26
+ # cs-image-system-tf-docker-plugin
27
+
28
+ The OpenTofu plugin for a container runtime (stage 103, branch 2): the
29
+ instance builder `tofu-docker` and the storage builder `tf-docker-volume`.
30
+ Each emits one terraform root on the `kreuzwerker/docker` provider against a
31
+ release-owned module (`tfmodules/docker_container`, `tfmodules/docker_volume`,
32
+ which every starter carries), exactly as the clouds' tofu plugins do against
33
+ theirs. The runtime is the `docker` runtime of
34
+ [cs-image-system-docker-runtime-plugin](../docker-runtime-plugin/README.md):
35
+ a durable host running a daemon that speaks the Docker Engine API.
36
+
37
+ Three things are different from a cloud, and each is a decision recorded in
38
+ the stage:
39
+
40
+ - **The power state is the operator's.** A container is declared with
41
+ `must_run = false`, so the next apply leaves a stopped container stopped
42
+ (proved against the provider before anything else in the branch), and
43
+ with the restart policy `unless-stopped`, so a daemon restart brings back
44
+ what was running and nothing else.
45
+ - **No first boot.** A cloud runs the launch script from user data. A
46
+ container has no user data: the root uploads the same rendered script
47
+ into the container when it is created (`/var/lib/csis/launch.sh`), and
48
+ the system runs it through `docker exec` after the apply, once, the way
49
+ it runs the accounts script. Its last act writes
50
+ `/var/lib/csis/launch-applied`, which the verification reads.
51
+ - **Labels are fixed at creation.** A container's and a volume's labels
52
+ cannot change in place; `lineage relabel` reports what a re-create would
53
+ set and re-creates nothing.
54
+
55
+ ## What it registers
56
+
57
+ One entry point under `cs_image_system.plugins.instance`
58
+ (`tf-docker-plugin`), registering two `type:` keys:
59
+
60
+ | `type:` | Model | Builder | Classified as |
61
+ |---|---|---|---|
62
+ | `tofu-docker` | `TofuDockerInstanceBuilderModel` | `TofuDockerInstanceBuilder` | an instance builder |
63
+ | `tf-docker-volume` | `TofuDockerVolumeStorageBuilderModel` | `TofuDockerVolumeStorageBuilder` | a storage builder |
64
+
65
+ Both subclass the AWS plugin's tofu bases (`TofuInstanceBuilder`,
66
+ `TofuStorageBuilder`), so the apply gate, the decommission whitelist, the
67
+ ephemeral sequence, the storage state machine and the state query are the
68
+ shared machinery.
69
+
70
+ ## Models
71
+
72
+ ### `TofuDockerInstanceBuilderModel` (`tofu-docker`)
73
+
74
+ The fields of every tofu instance builder: `runtime` (a `docker` runtime),
75
+ `executable` (the `cfg/executables.yml` entry for tofu), `state_configuration`
76
+ (the root's state manager; `default` inherits the runtime's, else the
77
+ default), `required_plugins` (the terraform providers; with none declared the
78
+ root requires `kreuzwerker/docker` unpinned). Nothing docker-specific is
79
+ declared on the builder: the daemon's address and the machine types live on
80
+ the runtime.
81
+
82
+ ### `TofuDockerVolumeStorageBuilderModel` (`tf-docker-volume`)
83
+
84
+ The same universal fields, plus `variables` (a `DockerVolumeVariables`):
85
+ `driver` (the volume driver; the daemon's `local` when unset), `driver_opts`
86
+ (its options) and `tags`, emitted as labels under the storage item's own.
87
+
88
+ ### The runtime builder the plugin reads
89
+
90
+ `host` or `context` (the daemon's address, which rides in the environment of
91
+ every tofu process the roots run, never in a `.tf` file), `networking.network`
92
+ (the network every container joins, by name), `machine_types` (a name to
93
+ `{cpus, memory}`; an instance's `machine_type` picks one, the runtime's
94
+ `default_machine_type` otherwise) and `repository` (where the floating tag
95
+ of a deferred image lives).
96
+
97
+ ## The builder
98
+
99
+ ### `TofuDockerInstanceBuilder` (phase `instance-generation`)
100
+
101
+ One `module "instance_<label>"` call per instance against
102
+ `tfmodules/docker_container`:
103
+
104
+ - `name` is the instance's declared name (a container's name is unique on a
105
+ daemon, and every instance hook finds the container by it); `hostname` is
106
+ the canonical name `<name>-NNN` the launch parameters decide;
107
+ - `image` is the pinned build (an image id, `sha256:...`), else the resolved
108
+ provider-specific image, else the per-instance variable `<label>_image`
109
+ that finalization fills from the packer manifest, with `image_tag` (the
110
+ series' floating tag) as the module's fallback through a `docker_image`
111
+ data source;
112
+ - `cpus` and `memory` are the machine type's limits (`cpus` rendered with a
113
+ decimal point, `1.0`, because that is how the provider reads it back;
114
+ memory in MB from docker's own spelling, `4g`);
115
+ - `labels` carry the configuration id (`csis_config`), the instance
116
+ (`csis_instance`) and its generation (`csis_generation`); the module adds
117
+ `csis_build` from the image it resolved;
118
+ - `volumes` map each attached storage to `{volume_name, container_path}`,
119
+ the name by remote-state reference to the storage root's outputs;
120
+ - `launch_script` is `templatefile` over `launch-<label>.sh.tftpl`, the same
121
+ script `launch_params.user_data_template` renders for the clouds, with the
122
+ group's gid by the group builder's expression (a posix group's gid is a
123
+ number of the configuration). On this runtime the script sets no hostname
124
+ (the container was created with it) and, for a volume, formats and mounts
125
+ nothing: the daemon mounted it, and the script makes the group's subtree
126
+ and sets its ownership and mode.
127
+
128
+ The module declares `must_run = false`, `start = true`, `init = true`, the
129
+ restart policy `unless-stopped`, and ignores later changes to `image`,
130
+ `labels`, `upload` and `memory_swap` (the daemon computes the last from
131
+ `memory`). An upgrade is a `-replace` of `module.instance_<label>.docker_container.this`
132
+ through the gate, as on the clouds; a decommission destroys the module.
133
+
134
+ Every tofu process the root runs (`fmt`, `init`, `validate`, `plan`, `apply`)
135
+ carries the runtime's `DOCKER_HOST` or `DOCKER_CONTEXT` (and the TLS pair)
136
+ in its environment; the runner script renders them as an assignment prefix
137
+ on the line, an ENC `host` as a `cs-image-system decrypt` call. The
138
+ `provider "docker"` block is empty.
139
+
140
+ ### `TofuDockerVolumeStorageBuilder` (phase `storage-generation`)
141
+
142
+ One `module "storage_<label>"` call per live storage against
143
+ `tfmodules/docker_volume`: the volume's name (the storage's name as the
144
+ daemon allows it), the driver and its options when declared, and labels
145
+ (`csis_storage`, `csis_config`, one `csis_group_<group>` per allowed group,
146
+ the builder's and the item's tags). Capability type `volume`: many
147
+ containers may attach one, it is POSIX, it is not zonal (the zone comparison
148
+ has nothing to compare), and `platform_mounts` is true. A `destroyed` storage
149
+ is removed with its data (N19); the volume is not archivable yet (a volume
150
+ has no snapshot; a `tar` from a throwaway container is the obvious later
151
+ shape).
152
+
153
+ ### The instance hooks, on the runtime
154
+
155
+ The hooks the core calls after the apply are the docker runtime's
156
+ (`docker_runtime_builders.py`): the power state (`running`; `exited` and
157
+ `created` as stopped; `paused` as suspended; `restarting` as starting;
158
+ absent), `start_instance` and `stop_instance`, the identity (the container
159
+ id is the provider id, so a re-create is a new generation), the booted image
160
+ (`.Image`, the build id itself), `verify_instance` by exec (the launch
161
+ marker, each declared mount point in `/proc/mounts`, the booted image),
162
+ `run_session_command` (`docker exec -i -u root <name> bash -s`), no
163
+ `ssh_proxy_command` (login is by exec), `inventory` by the configuration's
164
+ label, and `instance_tags`/`retag_instance` (read; refuse to change).
165
+
166
+ ## Emission
167
+
168
+ For an instance `docker-test` on builder `tofu-docker-local`, the root
169
+ `generated/instance-image/tofu-docker-local/instance-generation/` holds
170
+ `instance-generation.tf` (the `terraform` block requiring `kreuzwerker/docker`,
171
+ an empty aliased provider, the variables, the remote-state data sources, the
172
+ backend file beside it), `instance-docker-test.tf` (the module call) and
173
+ `launch-docker_test.sh.tftpl` (the script). The storage root
174
+ `generated/storage/<builder>/storage-generation/` holds the volume module
175
+ calls and one `output "storage_<label>"` per volume for the instance root
176
+ to read.
177
+
178
+ ## Example configuration
179
+
180
+ ```yaml
181
+ # cfg/instance-builders.yml
182
+ instance_builders:
183
+ - name: tofu-docker
184
+ type: tofu-docker
185
+ runtime: docker-host
186
+ executable: open-tofu-1
187
+ state_configuration: local-dev
188
+ required_plugins:
189
+ - name: docker
190
+ source: kreuzwerker/docker
191
+ version: ">= 3.0.0"
192
+
193
+ # cfg/storage-builders.yml
194
+ storage_builders:
195
+ - name: docker-volumes
196
+ type: tf-docker-volume
197
+ executable: open-tofu-1
198
+ runtime: docker-host
199
+ state_configuration: local-dev
200
+ variables:
201
+ tags:
202
+ project: example
203
+
204
+ # storages/volumes.yaml
205
+ storages:
206
+ - name: scratch
207
+ type: docker-volumes
208
+ runtime: docker-host
209
+ mount_point: /mnt/scratch
210
+ groups: [pxgroup]
211
+
212
+ # instances/containers.yaml
213
+ instances:
214
+ - name: docker-test
215
+ image: imgfile-docker # a posix-owned image baked on docker-host
216
+ runtime: docker-host
217
+ type: tofu-docker
218
+ machine_type: small # one of the runtime's machine_types
219
+ storages:
220
+ - name: scratch
221
+ mount_point: /mnt/scratch
222
+ ```
223
+
224
+ The base image the instance image descends from declares `storage_types:
225
+ [volume]` (N4: a type must be declared to be attached), and the image's
226
+ group is a posix group (an OPA group on a docker runtime is refused at
227
+ validation).
228
+
229
+ ## Prerequisites and integration
230
+
231
+ - A `docker` runtime (the docker runtime plugin) whose daemon the operator's
232
+ shell can reach, and the `docker` CLI it names in `cfg/executables.yml`.
233
+ - `tofu` in `cfg/executables.yml`, and the `kreuzwerker/docker` provider,
234
+ which `tofu init` downloads (version 3.0.0 or later; 4.6.0 proved it).
235
+ - A state manager for the roots: the runtime's `state_configuration`, often
236
+ `local` for a tree with no cloud.
237
+ - The modules `tfmodules/docker_container` and `tfmodules/docker_volume`
238
+ beside the configuration root (`module_source_base`); every starter carries
239
+ them.
240
+ - `bash` on the baked image (the session runs `bash -s`), which the docker
241
+ runtime's settle step installs with `sudo` and `python3` where a vendor
242
+ container lacks them.
243
+
244
+ The plugin depends on `cs-image-system-tf-ebs-instance-plugin` (the tofu
245
+ bases) and `cs-image-system-docker-runtime-plugin` (the names and the
246
+ runtime's hooks).
247
+
248
+ ## Configuration reference
249
+
250
+ Builder entries (`cfg/instance-builders.yml`, `cfg/storage-builders.yml`):
251
+ `name`, `type` (`tofu-docker` | `tf-docker-volume`), `runtime` (a `docker`
252
+ runtime), `executable`, `state_configuration`, `required_plugins[]`
253
+ (`{name, source, version}`), `is_default`, `description`, `tags`; the volume
254
+ builder's `variables: {driver, driver_opts, tags}`.
255
+
256
+ The instance item (`instances/*.yaml`, `type:` a `tofu-docker` builder):
257
+ `name` (the container's name and the hostname label), `image`, `runtime`,
258
+ `machine_type` (one of the runtime's `machine_types`; empty = its default),
259
+ `storages[]` (`{name, mount_point}`), `image_policy`, `ephemeral`,
260
+ `on_failure`, `teardown_after`, `userdata` (lines appended to the launch
261
+ script), `tags` (labels, fixed at creation). `availability_zone` is accepted
262
+ and compares with nothing (a daemon has no zones).
263
+
264
+ The storage item (`storages/*.yaml`, `type:` a `tf-docker-volume` builder):
265
+ `name`, `runtime`, `mount_point`, `groups[]`, `share_mode`, `public_read`,
266
+ `state` (`active` | `destroyed`; `archived` is refused: not supported yet),
267
+ `tags`. `lifecycle` is refused (no data lifecycle on a volume).
268
+
269
+ Execution knobs read through the base: `config.apply_instances` and
270
+ `config.apply_storage` (a bool, or the roots that may apply, by builder name
271
+ or runtime), `config.use_state_backends`, `config.module_source_base`.
272
+
273
+ ## What it tests and verifies
274
+
275
+ - `packages/tf-docker-plugin/tests/`: the module arguments from a resolved,
276
+ a pinned and a deferred provider-specific image; the machine type's
277
+ limits; the memory and cpus spellings; the volume's module arguments and
278
+ labels; the launch-script template on a volume mount.
279
+ - `tests/test_v2_stage_103_instances.py`: a dry run over an overlay of the
280
+ frozen fixture emits both roots, the module calls, the uploaded launch
281
+ script, the environment prefix on every tofu line and the gated apply
282
+ sequence; the hooks' answers over a stubbed daemon; the fixture and the
283
+ golden do not change.
284
+ - `tests/test_v2_docker_cycle_live.py` (`just test-docker-cycle`, a leg of
285
+ `just full-test`): the cycle on the local daemon from nothing to nothing:
286
+ bake, launch two containers on one volume, verify, reconcile accounts,
287
+ stop one and show the next apply leaves it stopped, start it, upgrade one
288
+ to a new build (a new generation), decommission, destroy the volume,
289
+ dispose the images.
290
+ - The verification of a launched container (`verify instance`): the launch
291
+ marker, each declared mount point, the booted image, and the image's
292
+ declared post-bake tests over the session.
293
+
294
+ ## When it fails
295
+
296
+ - `the daemon at ... cannot be reached`: the runtime's `host` or `context`
297
+ does not answer; preflight says the same in one line.
298
+ - `machine_type 'x' is not one of runtime ...'s machine_types`: the instance
299
+ names a type the runtime does not declare.
300
+ - `memory '...' is not a size docker understands`: a machine type's memory
301
+ is not `512m`, `4g` or a number of MB.
302
+ - A plan that wants to replace a container the operator did not upgrade:
303
+ a volume attachment changed (a detach on a container is a re-create, not
304
+ an in-place detach as on the clouds), or `cpus`/`memory` of its machine
305
+ type changed. The gate refuses the unwhitelisted destroy; an `upgrade
306
+ instance` sanctions the replacement.
307
+ - `relabel: could not retag instance ...: a container's labels are fixed`:
308
+ expected; the labels arrive with the next re-create.
309
+ - `verify ...: launch script: no completion marker`: the launch script did
310
+ not run or failed; the next applying run delivers it again
311
+ (`csis launch:` lines in the log say why).
312
+
313
+ ## Related
314
+
315
+ - [cs-image-system-docker-runtime-plugin](../docker-runtime-plugin/README.md):
316
+ the runtime, the bake and the instance hooks.
317
+ - [cs-image-system-tf-ebs-instance-plugin](../tf-ebs-instance-plugin/README.md):
318
+ the tofu bases this plugin subclasses.
319
+ - `tfmodules/docker_container`, `tfmodules/docker_volume`: the modules.
320
+ - `docs/OPERATIONS.md`: the cycle, power states and generations.