-
Notifications
You must be signed in to change notification settings - Fork 619
Expand file tree
/
Copy pathno-single-process.patch
More file actions
331 lines (323 loc) · 14.1 KB
/
no-single-process.patch
File metadata and controls
331 lines (323 loc) · 14.1 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
Description: remove single process optimization
This optimization is a big change in behavior, patch it out.
Author: Brett Holman <brett.holman@canonical.com>
Last-Update: 2024-08-02
diff -ruN a/cloudinit/cmd/status.py b/cloudinit/cmd/status.py
--- a/cloudinit/cmd/status.py 2024-08-30 14:19:57.000000000 -0700
+++ b/cloudinit/cmd/status.py 2024-09-30 16:12:15.632570075 -0700
@@ -318,9 +318,8 @@
for service in [
"cloud-final.service",
"cloud-config.service",
- "cloud-init-network.service",
+ "cloud-init.service",
"cloud-init-local.service",
- "cloud-init-main.service",
]:
try:
stdout = query_systemctl(
diff -ruN a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py
--- a/cloudinit/config/cc_mounts.py 2024-08-30 14:19:57.000000000 -0700
+++ b/cloudinit/config/cc_mounts.py 2024-09-30 16:12:50.281703594 -0700
@@ -525,7 +525,7 @@
# fs_spec, fs_file, fs_vfstype, fs_mntops, fs-freq, fs_passno
uses_systemd = cloud.distro.uses_systemd()
default_mount_options = (
- "defaults,nofail,x-systemd.after=cloud-init-network.service,_netdev"
+ "defaults,nofail,x-systemd.after=cloud-init.service,_netdev"
if uses_systemd
else "defaults,nobootwait"
)
diff -ruN a/cloudinit/config/schemas/schema-cloud-config-v1.json b/cloudinit/config/schemas/schema-cloud-config-v1.json
--- a/cloudinit/config/schemas/schema-cloud-config-v1.json 2024-08-30 14:19:57.000000000 -0700
+++ b/cloudinit/config/schemas/schema-cloud-config-v1.json 2024-09-30 16:13:48.717358398 -0700
@@ -2022,12 +2022,12 @@
},
"mount_default_fields": {
"type": "array",
- "description": "Default mount configuration for any mount entry with less than 6 options provided. When specified, 6 items are required and represent ``/etc/fstab`` entries. Default: ``defaults,nofail,x-systemd.after=cloud-init-network.service,_netdev``.",
+ "description": "Default mount configuration for any mount entry with less than 6 options provided. When specified, 6 items are required and represent ``/etc/fstab`` entries. Default: ``defaults,nofail,x-systemd.after=cloud-init.service,_netdev``.",
"default": [
null,
null,
"auto",
- "defaults,nofail,x-systemd.after=cloud-init-network.service",
+ "defaults,nofail,x-systemd.after=cloud-init.service",
"0",
"2"
],
diff -ruN a/systemd/cloud-config.service.tmpl b/systemd/cloud-config.service.tmpl
--- a/systemd/cloud-config.service.tmpl 2024-08-30 14:19:57.000000000 -0700
+++ b/systemd/cloud-config.service.tmpl 2024-09-30 16:04:45.242125447 -0700
@@ -10,14 +10,7 @@
[Service]
Type=oneshot
-# This service is a shim which preserves systemd ordering while allowing a
-# single Python process to run cloud-init's logic. This works by communicating
-# with the cloud-init process over a unix socket to tell the process that this
-# stage can start, and then wait on a return socket until the cloud-init
-# process has completed this stage. The output from the return socket is piped
-# into a shell so that the process can send a completion message (defaults to
-# "done", otherwise includes an error message) and an exit code to systemd.
-ExecStart=sh -c 'echo "start" | nc.openbsd -Uu -W1 /run/cloud-init/share/config.sock -s /run/cloud-init/share/config-return.sock | sh'
+ExecStart=/usr/bin/cloud-init modules --mode=config
RemainAfterExit=yes
TimeoutSec=0
diff -ruN a/systemd/cloud-config.target b/systemd/cloud-config.target
--- a/systemd/cloud-config.target 2024-08-30 14:19:57.000000000 -0700
+++ b/systemd/cloud-config.target 2024-09-30 16:14:21.895676757 -0700
@@ -14,5 +14,5 @@
[Unit]
Description=Cloud-config availability
-Wants=cloud-init-local.service cloud-init-network.service
-After=cloud-init-local.service cloud-init-network.service
+Wants=cloud-init-local.service cloud-init.service
+After=cloud-init-local.service cloud-init.service
diff -ruN a/systemd/cloud-final.service.tmpl b/systemd/cloud-final.service.tmpl
--- a/systemd/cloud-final.service.tmpl 2024-08-30 14:19:57.000000000 -0700
+++ b/systemd/cloud-final.service.tmpl 2024-09-30 16:06:04.764625254 -0700
@@ -15,16 +15,10 @@
[Service]
Type=oneshot
-# This service is a shim which preserves systemd ordering while allowing a
-# single Python process to run cloud-init's logic. This works by communicating
-# with the cloud-init process over a unix socket to tell the process that this
-# stage can start, and then wait on a return socket until the cloud-init
-# process has completed this stage. The output from the return socket is piped
-# into a shell so that the process can send a completion message (defaults to
-# "done", otherwise includes an error message) and an exit code to systemd.
-ExecStart=sh -c 'echo "start" | nc.openbsd -Uu -W1 /run/cloud-init/share/final.sock -s /run/cloud-init/share/final-return.sock | sh'
+ExecStart=/usr/bin/cloud-init modules --mode=final
RemainAfterExit=yes
TimeoutSec=0
+KillMode=process
{% if variant in ["almalinux", "cloudlinux", "rhel"] %}
# Restart NetworkManager if it is present and running.
ExecStartPost=/bin/sh -c 'u=NetworkManager.service; \
diff -ruN a/systemd/cloud-init-local.service.tmpl b/systemd/cloud-init-local.service.tmpl
--- a/systemd/cloud-init-local.service.tmpl 2024-08-30 14:19:57.000000000 -0700
+++ b/systemd/cloud-init-local.service.tmpl 2024-09-30 16:07:21.911075080 -0700
@@ -7,6 +7,7 @@
{% endif %}
Wants=network-pre.target
After=hv_kvp_daemon.service
+After=systemd-remount-fs.service
{% if variant in ["almalinux", "cloudlinux", "rhel"] %}
Requires=dbus.socket
After=dbus.socket
@@ -37,14 +38,7 @@
ExecStartPre=/sbin/restorecon /run/cloud-init
ExecStartPre=/usr/bin/touch /run/cloud-init/enabled
{% endif %}
-# This service is a shim which preserves systemd ordering while allowing a
-# single Python process to run cloud-init's logic. This works by communicating
-# with the cloud-init process over a unix socket to tell the process that this
-# stage can start, and then wait on a return socket until the cloud-init
-# process has completed this stage. The output from the return socket is piped
-# into a shell so that the process can send a completion message (defaults to
-# "done", otherwise includes an error message) and an exit code to systemd.
-ExecStart=sh -c 'echo "start" | nc.openbsd -Uu -W1 /run/cloud-init/share/local.sock -s /run/cloud-init/share/local-return.sock | sh'
+ExecStart=/usr/bin/cloud-init init --local
RemainAfterExit=yes
TimeoutSec=0
diff -ruN a/systemd/cloud-init-main.service.tmpl b/systemd/cloud-init-main.service.tmpl
--- a/systemd/cloud-init-main.service.tmpl 2024-08-30 14:19:57.000000000 -0700
+++ b/systemd/cloud-init-main.service.tmpl 1969-12-31 16:00:00.000000000 -0800
@@ -1,52 +0,0 @@
-## template:jinja
-# systemd ordering resources
-# ==========================
-# https://systemd.io/NETWORK_ONLINE/
-# https://docs.cloud-init.io/en/latest/explanation/boot.html
-# https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
-# https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html
-# https://www.freedesktop.org/software/systemd/man/latest/systemd-remount-fs.service.html
-[Unit]
-Description=Cloud-init: Single Process
-Wants=network-pre.target
-{% if variant in ["almalinux", "cloudlinux", "ubuntu", "unknown", "debian", "rhel"] %}
-DefaultDependencies=no
-{% endif %}
-{% if variant in ["almalinux", "cloudlinux", "rhel"] %}
-Requires=dbus.socket
-After=dbus.socket
-Before=network.service
-Before=firewalld.target
-Conflicts=shutdown.target
-{% endif %}
-{% if variant in ["ubuntu", "unknown", "debian"] %}
-Before=sysinit.target
-Conflicts=shutdown.target
-{% endif %}
-
-After=systemd-remount-fs.service
-Before=sysinit.target
-Before=cloud-init-local.service
-Conflicts=shutdown.target
-RequiresMountsFor=/var/lib/cloud
-ConditionPathExists=!/etc/cloud/cloud-init.disabled
-ConditionKernelCommandLine=!cloud-init=disabled
-ConditionEnvironment=!KERNEL_CMDLINE=cloud-init=disabled
-
-[Service]
-Type=notify
-ExecStart=/usr/bin/cloud-init --all-stages
-KillMode=process
-TasksMax=infinity
-TimeoutStartSec=infinity
-{% if variant in ["almalinux", "cloudlinux", "rhel"] %}
-ExecStartPre=/bin/mkdir -p /run/cloud-init
-ExecStartPre=/sbin/restorecon /run/cloud-init
-ExecStartPre=/usr/bin/touch /run/cloud-init/enabled
-{% endif %}
-
-# Output needs to appear in instance console output
-StandardOutput=journal+console
-
-[Install]
-WantedBy=cloud-init.target
diff -ruN a/systemd/cloud-init-network.service.tmpl b/systemd/cloud-init-network.service.tmpl
--- a/systemd/cloud-init-network.service.tmpl 2024-08-30 14:19:57.000000000 -0700
+++ b/systemd/cloud-init-network.service.tmpl 1969-12-31 16:00:00.000000000 -0800
@@ -1,64 +0,0 @@
-## template:jinja
-[Unit]
-# https://cloudinit.readthedocs.io/en/latest/explanation/boot.html
-Description=Cloud-init: Network Stage
-{% if variant not in ["almalinux", "cloudlinux", "photon", "rhel"] %}
-DefaultDependencies=no
-{% endif %}
-Wants=cloud-init-local.service
-Wants=sshd-keygen.service
-Wants=sshd.service
-After=cloud-init-local.service
-After=systemd-networkd-wait-online.service
-{% if variant in ["ubuntu", "unknown", "debian"] %}
-After=networking.service
-{% endif %}
-{% if variant in ["almalinux", "centos", "cloudlinux", "eurolinux", "fedora",
- "miraclelinux", "openeuler", "OpenCloudOS", "openmandriva", "rhel", "rocky",
- "suse", "TencentOS", "virtuozzo"] %}
-
-After=network.service
-After=NetworkManager.service
-After=NetworkManager-wait-online.service
-{% endif %}
-{% if variant in ["suse"] %}
-After=wicked.service
-# setting hostname via hostnamectl depends on dbus, which otherwise
-# would not be guaranteed at this point.
-After=dbus.service
-{% endif %}
-Before=network-online.target
-Before=sshd-keygen.service
-Before=sshd.service
-Before=systemd-user-sessions.service
-{% if variant in ["ubuntu", "unknown", "debian"] %}
-Before=sysinit.target
-Before=shutdown.target
-Conflicts=shutdown.target
-{% endif %}
-{% if variant in ["suse"] %}
-Before=shutdown.target
-Conflicts=shutdown.target
-{% endif %}
-ConditionPathExists=!/etc/cloud/cloud-init.disabled
-ConditionKernelCommandLine=!cloud-init=disabled
-ConditionEnvironment=!KERNEL_CMDLINE=cloud-init=disabled
-
-[Service]
-Type=oneshot
-# This service is a shim which preserves systemd ordering while allowing a
-# single Python process to run cloud-init's logic. This works by communicating
-# with the cloud-init process over a unix socket to tell the process that this
-# stage can start, and then wait on a return socket until the cloud-init
-# process has completed this stage. The output from the return socket is piped
-# into a shell so that the process can send a completion message (defaults to
-# "done", otherwise includes an error message) and an exit code to systemd.
-ExecStart=sh -c 'echo "start" | nc.openbsd -Uu -W1 /run/cloud-init/share/network.sock -s /run/cloud-init/share/network-return.sock | sh'
-RemainAfterExit=yes
-TimeoutSec=0
-
-# Output needs to appear in instance console output
-StandardOutput=journal+console
-
-[Install]
-WantedBy=cloud-init.target
diff -ruN a/systemd/cloud-init.service.tmpl b/systemd/cloud-init.service.tmpl
--- a/systemd/cloud-init.service.tmpl 1969-12-31 16:00:00.000000000 -0800
+++ b/systemd/cloud-init.service.tmpl 2024-09-30 16:10:27.305042289 -0700
@@ -0,0 +1,57 @@
+## template:jinja
+[Unit]
+# https://docs.cloud-init.io/en/latest/explanation/boot.html
+Description=Cloud-init: Network Stage
+{% if variant not in ["almalinux", "cloudlinux", "photon", "rhel"] %}
+DefaultDependencies=no
+{% endif %}
+Wants=cloud-init-local.service
+Wants=sshd-keygen.service
+Wants=sshd.service
+After=cloud-init-local.service
+After=systemd-networkd-wait-online.service
+{% if variant in ["ubuntu", "unknown", "debian"] %}
+After=networking.service
+{% endif %}
+{% if variant in ["almalinux", "centos", "cloudlinux", "eurolinux", "fedora",
+ "miraclelinux", "openeuler", "OpenCloudOS", "openmandriva", "rhel", "rocky",
+ "suse", "TencentOS", "virtuozzo"] %}
+
+After=network.service
+After=NetworkManager.service
+After=NetworkManager-wait-online.service
+{% endif %}
+{% if variant in ["suse"] %}
+After=wicked.service
+# setting hostname via hostnamectl depends on dbus, which otherwise
+# would not be guaranteed at this point.
+After=dbus.service
+{% endif %}
+Before=network-online.target
+Before=sshd-keygen.service
+Before=sshd.service
+Before=systemd-user-sessions.service
+{% if variant in ["ubuntu", "unknown", "debian"] %}
+Before=sysinit.target
+Before=shutdown.target
+Conflicts=shutdown.target
+{% endif %}
+{% if variant in ["suse"] %}
+Before=shutdown.target
+Conflicts=shutdown.target
+{% endif %}
+ConditionPathExists=!/etc/cloud/cloud-init.disabled
+ConditionKernelCommandLine=!cloud-init=disabled
+ConditionEnvironment=!KERNEL_CMDLINE=cloud-init=disabled
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/cloud-init init
+RemainAfterExit=yes
+TimeoutSec=0
+
+# Output needs to appear in instance console output
+StandardOutput=journalconsole
+
+[Install]
+WantedBy=cloud-init.target
\ No newline at end of file
diff -ruN a/tests/unittests/config/test_cc_mounts.py b/tests/unittests/config/test_cc_mounts.py
--- a/tests/unittests/config/test_cc_mounts.py 2024-08-30 14:19:57.000000000 -0700
+++ b/tests/unittests/config/test_cc_mounts.py 2024-09-30 16:15:11.357454290 -0700
@@ -566,9 +566,9 @@
LABEL=keepme none ext4 defaults 0 0
LABEL=UEFI
/dev/sda4 /mnt2 auto nofail,comment=cloudconfig 1 2
- /dev/sda5 /mnt3 auto defaults,nofail,x-systemd.after=cloud-init-network.service,_netdev,comment=cloudconfig 0 2
+ /dev/sda5 /mnt3 auto defaults,nofail,x-systemd.after=cloud-init.service,_netdev,comment=cloudconfig 0 2
/dev/sda1 /mnt xfs auto,comment=cloudconfig 0 2
- /dev/sda3 /mnt4 btrfs defaults,nofail,x-systemd.after=cloud-init-network.service,_netdev,comment=cloudconfig 0 2
+ /dev/sda3 /mnt4 btrfs defaults,nofail,x-systemd.after=cloud-init.service,_netdev,comment=cloudconfig 0 2
/dev/sdb1 none swap sw,comment=cloudconfig 0 0
""" # noqa: E501
).strip()