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

Subscribers

People subscribed via source and target branches