Merge ~smoser/cloud-init:doc-boot-stages into cloud-init:master

Proposed by Scott Moser
Status: Merged
Merge reported by: Scott Moser
Merged at revision: not available
Proposed branch: ~smoser/cloud-init:doc-boot-stages
Merge into: cloud-init:master
Diff against target: 145 lines (+128/-0)
2 files modified
doc/rtd/index.rst (+1/-0)
doc/rtd/topics/boot.rst (+127/-0)
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+310386@code.launchpad.net

Commit message

doc: Add documentation on stages of boot.

This adds long overdue documentation on stages that cloud-init
runs during boot.

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) :
Revision history for this message
Scott Moser (smoser) wrote :

updated a bit.
tried to incorporate your suggestions.

Revision history for this message
Ryan Harper (raharper) :
Revision history for this message
Scott Moser (smoser) wrote :

On Wed, 9 Nov 2016, Ryan Harper wrote:

>
>
> Diff comments:
>
> > diff --git a/doc/rtd/topics/boot.rst b/doc/rtd/topics/boot.rst
>
> Either lowercase Generator, or Upper case the rest?

Upper cased in both places (title and summary).
>
> > + * A file exists: ``/etc/cloud/cloud-init.disabled``
> > + * The kernel command line as fond in /proc/cmdline contains ``cloud-init=disabled``.
> > + When running in a container, the kernel command line is not honored, but
> > + cloud-init will read an environment variable named ``KERNEL_CMDLINE`` in
> > + its place.
> > +
>
> Should we include what the equivalent sysvinit function is here?

There is no equivalent behavior in sysvinit scripts.
I mentioned that there.

> > +local
> > +#####
> > + * **systemd service**: ``cloud-init-local.service``
> > + * **runs**: As soon as / is mounted read-write.
> > + * **blocks**: as much of boot as possible, *must* block network bringup.
> > + * **modules**: none
> > +
> > +The purpose of the local stage is:
> > + * locate "local" data sources.
> > + * apply networking configuration to the system (including "Fallback")
> > +
> > +In most cases, this stage does not do much more than that. It finds the
> > +datasource and determines the network configuration to be used. That
> > +network configuration can come from:
> > +
> > + * the datasource
> > + * fallback: Cloud-init's fallback networking consists of rendering the
> > + equivalent to "dhcp on eth0", which was historically the most popular
> > + mechanism for network configuration of a guest.
> > + * none. network configuration can be disabled entirely with '``network: {config: disabled}``'.
>
> by including the following cloud-config.

updated.

>
> > +
> > +If this is an instance's first boot, then the selected network configuration
> > +is rendered. This includes clearing of all previous (stale) configuration
> > +including persistent device naming with old mac addresses.
> > +
> > +This stage must block network bring-up or any stale configuration might
> > +already have been applied. That could have negative affects such as dchp
> > +hooks or broadcast of an old hostname. It would also put the system in
> > +an odd state to recover from as it may then have to bounce network
>
> s/bounce/restart

updated.
>
> > +devices.
> > +
> > +This stage requires networking configuration to be up, as it will fully
>
> s/configuration to be up/to be online/available
> s/it/cloud-init/

updated.
> > +This stage runs as late in boot as possible. The goal is to provide run
> > +as if the system had fully booted. Any scripts that a user is accustomed
>
> "to provide run" ?
> Maybe just drop the second sentence.

dropped.

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks for adding this! I have some comments, questions, and typo fixes.

Revision history for this message
Scott Moser (smoser) wrote :

thanks for review comments. i've updated.

Revision history for this message
Scott Moser (smoser) wrote :

I'm going to go ahead and merge this as I believe it is an important improvement and we can make further improvements to it as we go.

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/doc/rtd/index.rst b/doc/rtd/index.rst
2index f8ff3c9..116a380 100644
3--- a/doc/rtd/index.rst
4+++ b/doc/rtd/index.rst
5@@ -22,6 +22,7 @@ Summary
6 topics/format
7 topics/dir_layout
8 topics/examples
9+ topics/boot
10 topics/datasources
11 topics/logging
12 topics/modules
13diff --git a/doc/rtd/topics/boot.rst b/doc/rtd/topics/boot.rst
14new file mode 100644
15index 0000000..3de25d3
16--- /dev/null
17+++ b/doc/rtd/topics/boot.rst
18@@ -0,0 +1,127 @@
19+============
20+Boot Stages
21+============
22+In order to be able to provide the functionality that it does, cloud-init
23+must be integrated into the boot in fairly controlled way.
24+
25+There are 5 stages.
26+
27+1. **Generator**
28+2. **Local**
29+3. **Network**
30+4. **Config**
31+5. **Final**
32+
33+Generator
34+#########
35+When booting under systemd, a
36+`generator <https://www.freedesktop.org/software/systemd/man/systemd.generator.html>`_
37+will run that determines if cloud-init.target should be included in the
38+boot goals. By default, this generator will enable cloud-init. It will
39+not enable cloud-init if either:
40+
41+ * A file exists: ``/etc/cloud/cloud-init.disabled``
42+ * The kernel command line as fond in /proc/cmdline contains ``cloud-init=disabled``.
43+ When running in a container, the kernel command line is not honored, but
44+ cloud-init will read an environment variable named ``KERNEL_CMDLINE`` in
45+ its place.
46+
47+This mechanism for disabling at runtime currently only exists in systemd.
48+
49+Local
50+#####
51+ * **systemd service**: ``cloud-init-local.service``
52+ * **runs**: As soon as possible with / mounted read-write.
53+ * **blocks**: as much of boot as possible, *must* block network bringup.
54+ * **modules**: none
55+
56+The purpose of the local stage is:
57+ * locate "local" data sources.
58+ * apply networking configuration to the system (including "Fallback")
59+
60+In most cases, this stage does not do much more than that. It finds the
61+datasource and determines the network configuration to be used. That
62+network configuration can come from:
63+
64+ * the datasource
65+ * fallback: Cloud-init's fallback networking consists of rendering the
66+ equivalent to "dhcp on eth0", which was historically the most popular
67+ mechanism for network configuration of a guest.
68+ * none. network configuration can be disabled entirely with
69+ config like the following in /etc/cloud/cloud.cfg:
70+ '``network: {config: disabled}``'.
71+
72+If this is an instance's first boot, then the selected network configuration
73+is rendered. This includes clearing of all previous (stale) configuration
74+including persistent device naming with old mac addresses.
75+
76+This stage must block network bring-up or any stale configuration might
77+already have been applied. That could have negative effects such as DCHP
78+hooks or broadcast of an old hostname. It would also put the system in
79+an odd state to recover from as it may then have to restart network
80+devices.
81+
82+Cloud-init then exits and expects for the continued boot of the operating
83+system to bring network configuration up as configured.
84+
85+**Note**: In the past, local data sources have been only those that were
86+available without network (such as 'ConfigDrive'). However, as seen in
87+the recent additions to the DigitalOcean datasource, even data sources
88+that require a network can operate at this stage.
89+
90+Network
91+#######
92+ * **systemd service**: ``cloud-init.service``
93+ * **runs**: After local stage and configured networking is up.
94+ * **blocks**: As much of remaining boot as possible.
95+ * **modules**: ``init_modules``
96+
97+This stage requires all configured networking to be online, as it will fully
98+process any user-data that is found. Here, processing means:
99+
100+ * retrive any ``#include`` or ``#include-once`` (recursively) including http
101+ * uncompress any compressed content
102+ * run any part-handler found.
103+
104+This stage runs the ``disk_setup`` and ``mounts`` modules which may partition
105+and format disks and configure mount points (such as in /etc/fstab).
106+Those modules cannot run earlier as they may receive configuration input
107+from sources only available via network. For example, a user may have
108+provided user-data in a network resource that describes how local mounts
109+should be done.
110+
111+On some clouds such as Azure, this stage will create filesystems to be
112+mounted, including ones that have stale (previous instance) references in
113+/etc/fstab. As such, entries /etc/fstab other than those necessary for
114+cloud-init to run should not be done until after this stage.
115+
116+A part-handler will run at this stage, as will boothooks including
117+cloud-config ``bootcmd``. The user of this functionality has to be aware
118+that the system is in the process of booting when their code runs.
119+
120+Config
121+######
122+ * **systemd service**: ``cloud-config.service``
123+ * **runs**: After network stage.
124+ * **blocks**: None.
125+ * **modules**: ``config_modules``
126+
127+This stage runs config modules only. Modules that do not really have an
128+effect on other stages of boot are run here.
129+
130+
131+Final
132+#####
133+ * **systemd service**: ``cloud-final.service``
134+ * **runs**: As final part of boot (traditional "rc.local")
135+ * **blocks**: None.
136+ * **modules**: ``final_modules``
137+
138+This stage runs as late in boot as possible. Any scripts that a user is
139+accustomed to running after logging into a system should run correctly here.
140+Things that run here include
141+
142+ * package installations
143+ * configuration management plugins (puppet, chef, salt-minion)
144+ * user-scripts (including ``runcmd``).
145+

Subscribers

People subscribed via source and target branches