Merge ~smoser/cloud-init:cleanup/drop-ubuntu-init-switch into cloud-init:master

Proposed by Scott Moser
Status: Merged
Approved by: Scott Moser
Approved revision: bc9d1b4806c8125ad2a4f954338955fa6f3e75aa
Merged at revision: fa266bf8818a08e37cd32a603d076ba2db300124
Proposed branch: ~smoser/cloud-init:cleanup/drop-ubuntu-init-switch
Merge into: cloud-init:master
Diff against target: 254 lines (+4/-170)
8 files modified
config/cloud.cfg.tmpl (+0/-3)
dev/null (+0/-160)
doc/rtd/topics/modules.rst (+0/-1)
packages/bddeb (+1/-2)
packages/debian/dirs (+0/-1)
packages/debian/rules.in (+1/-1)
setup.py (+2/-0)
tests/cloud_tests/configs/modules/TODO.md (+0/-2)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Chad Smith Approve
Review via email: mp+329946@code.launchpad.net

Commit message

upstart: do not package upstart jobs, drop ubuntu-init-switch module.

The ubuntu-init-switch module allowed the use to launch an instance that
was booted with upstart and have it switch its init system to systemd and
then reboot itself. It was only useful for the time period when Ubuntu was
transitioning to systemd but only produced images using upstart.

Also, do not run setup with --init-system=upstart. This means that by
default, debian packages built with packages/bddeb will not have upstart
unit files included. No other removal is done here.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:801c0cf7da205dc2bb0313eb99a53df2b2b7c01b
https://jenkins.ubuntu.com/server/job/cloud-init-ci/230/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/230/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

We need to drop the module from doc/rtd/topics/modules.rst too.

.. automodule:: cloudinit.config.cc_ubuntu_init_switch

Revision history for this message
Chad Smith (chad.smith) wrote :

so that I understand intent here. We are leaving upstart logic in place so that tip could be used to still generate upstart-based packages if we wanted. We just don't want to package that init system by default anymore right?

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

> so that I understand intent here. We are leaving upstart logic in place so
> that tip could be used to still generate upstart-based packages if we wanted.
> We just don't want to package that init system by default anymore right?

correct.
we leave it all in place, but the upstream deb doesn't package it.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:8555dddadd54187e0a5902d0b356f0803a50e896
https://jenkins.ubuntu.com/server/job/cloud-init-ci/232/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/232/rebuild

review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:91675024ed03e6dec2116aa48975746bc1ff66af
https://jenkins.ubuntu.com/server/job/cloud-init-ci/234/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/234/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

Hrm, I'm still seeing upstart jobs included in /etc/init/*conf

dpkg -L cloud-init | grep etc/init
/etc/init
/etc/init/cloud-init-blocknet.conf
/etc/init/cloud-init-container.conf
/etc/init/cloud-init-nonet.conf
/etc/init/cloud-final.conf
/etc/init/cloud-init-local.conf
/etc/init/cloud-log-shutdown.conf
/etc/init/cloud-init.conf
/etc/init/cloud-config.conf
root@lxd-xenial:~# dpkg-query --show cloud-init
cloud-init 0.7.9-256-g8555ddd-1~bddeb

Revision history for this message
Chad Smith (chad.smith) :
review: Needs Information
Revision history for this message
Scott Moser (smoser) wrote :

I dont see the issues you're seeing . the etc/init/ files are not
present for me. See below. There was the empty etc/init/ directory
but I have a fix for that too i think.

$ git describe
0.7.9-257-g91675024

$ ./packages/bddeb -S -d
Creating a temporary tarball using the 'make-tarball' helper
Extracting temporary tarball 'cloud-init_0.7.9-257-g91675024.orig.tar.gz'
Creating a debian/ folder in '/tmp/tmpe5frrdol/cloud-init-0.7.9-257-g91675024'
Running 'debuild -S -d -us -uc' in '/tmp/tmpe5frrdol/cloud-init-0.7.9-257-g91675024'
Wrote 'cloud-init_0.7.9-257-g91675024-1~bddeb.debian.tar.xz'
Wrote 'cloud-init_0.7.9-257-g91675024-1~bddeb_source.build'
Wrote 'cloud-init_0.7.9-257-g91675024-1~bddeb_source.buildinfo'
Wrote 'cloud-init_0.7.9-257-g91675024-1~bddeb_source.changes'
Wrote 'cloud-init_0.7.9-257-g91675024.orig.tar.gz'
Wrote 'cloud-init_0.7.9-257-g91675024-1~bddeb.dsc'
Linked 'cloud-init_0.7.9-257-g91675024-1~bddeb.dsc' to 'cloud-init.dsc'

$ sbuild --dist=artful --arch=amd64 --arch-all cloud-init_0.7.9-257-g91675024-1~bddeb.dsc

$ pastebinit cloud-init_0.7.9-257-g91675024-1~bddeb_amd64.build
http://paste.ubuntu.com/25435409/

$ dpkg -c cloud-init_0.7.9-257-g91675024-1~bddeb_all.deb | grep etc/init
drwxr-xr-x root/root 0 2011-12-16 11:50 ./etc/init/

$ dpkg -c cloud-init_0.7.9-257-g91675024-1~bddeb_all.deb | pastebinit
http://paste.ubuntu.com/25435415/

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

$ dpkg -c /home/smoser-public/src/cloud-init/build/../cloud-init_0.7.9-258-g8d180ece-1~bddeb_all.deb | grep etc/init || echo none there
nonoe there.

$ dpkg -c ../cloud-init_0.7.9-258-g8d180ece-1~bddeb_all.deb | pastebinit
http://paste.ubuntu.com/25435440/

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:8d180ecee1bc71747e4145bf8e20e0aec3050acb
https://jenkins.ubuntu.com/server/job/cloud-init-ci/238/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/238/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

+1 once unit tests complete here. Thanks for the fix. This is the issue I was seeing on my side

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:bc9d1b4806c8125ad2a4f954338955fa6f3e75aa
https://jenkins.ubuntu.com/server/job/cloud-init-ci/240/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/240/rebuild

review: Approve (continuous-integration)

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/cloudinit/config/cc_ubuntu_init_switch.py b/cloudinit/config/cc_ubuntu_init_switch.py
2deleted file mode 100644
3index 5dd2690..0000000
4--- a/cloudinit/config/cc_ubuntu_init_switch.py
5+++ /dev/null
6@@ -1,160 +0,0 @@
7-# Copyright (C) 2014 Canonical Ltd.
8-#
9-# Author: Scott Moser <scott.moser@canonical.com>
10-#
11-# This file is part of cloud-init. See LICENSE file for license information.
12-
13-"""
14-Ubuntu Init Switch
15-------------------
16-**Summary:** reboot system into another init.
17-
18-This module provides a way for the user to boot with systemd even if the image
19-is set to boot with upstart. It should be run as one of the first
20-``cloud_init_modules``, and will switch the init system and then issue a
21-reboot. The next boot will come up in the target init system and no action
22-will be taken. This should be inert on non-ubuntu systems, and also
23-exit quickly.
24-
25-.. note::
26- best effort is made, but it's possible this system will break, and probably
27- won't interact well with any other mechanism you've used to switch the init
28- system.
29-
30-**Internal name:** ``cc_ubuntu_init_switch``
31-
32-**Module frequency:** once per instance
33-
34-**Supported distros:** ubuntu
35-
36-**Config keys**::
37-
38- init_switch:
39- target: systemd (can be 'systemd' or 'upstart')
40- reboot: true (reboot if a change was made, or false to not reboot)
41-"""
42-
43-from cloudinit.distros import ubuntu
44-from cloudinit import log as logging
45-from cloudinit.settings import PER_INSTANCE
46-from cloudinit import util
47-
48-import os
49-import time
50-
51-frequency = PER_INSTANCE
52-REBOOT_CMD = ["/sbin/reboot", "--force"]
53-
54-DEFAULT_CONFIG = {
55- 'init_switch': {'target': None, 'reboot': True}
56-}
57-
58-SWITCH_INIT = """
59-#!/bin/sh
60-# switch_init: [upstart | systemd]
61-
62-is_systemd() {
63- [ "$(dpkg-divert --listpackage /sbin/init)" = "systemd-sysv" ]
64-}
65-debug() { echo "$@" 1>&2; }
66-fail() { echo "$@" 1>&2; exit 1; }
67-
68-if [ "$1" = "systemd" ]; then
69- if is_systemd; then
70- debug "already systemd, nothing to do"
71- else
72- [ -f /lib/systemd/systemd ] || fail "no systemd available";
73- dpkg-divert --package systemd-sysv --divert /sbin/init.diverted \\
74- --rename /sbin/init
75- fi
76- [ -f /sbin/init ] || ln /lib/systemd/systemd /sbin/init
77-elif [ "$1" = "upstart" ]; then
78- if is_systemd; then
79- rm -f /sbin/init
80- dpkg-divert --package systemd-sysv --rename --remove /sbin/init
81- else
82- debug "already upstart, nothing to do."
83- fi
84-else
85- fail "Error. expect 'upstart' or 'systemd'"
86-fi
87-"""
88-
89-distros = ['ubuntu']
90-
91-
92-def handle(name, cfg, cloud, log, args):
93- """Handler method activated by cloud-init."""
94-
95- if not isinstance(cloud.distro, ubuntu.Distro):
96- log.debug("%s: distro is '%s', not ubuntu. returning",
97- name, cloud.distro.__class__)
98- return
99-
100- cfg = util.mergemanydict([cfg, DEFAULT_CONFIG])
101- target = cfg['init_switch']['target']
102- reboot = cfg['init_switch']['reboot']
103-
104- if len(args) != 0:
105- target = args[0]
106- if len(args) > 1:
107- reboot = util.is_true(args[1])
108-
109- if not target:
110- log.debug("%s: target=%s. nothing to do", name, target)
111- return
112-
113- if not util.which('dpkg'):
114- log.warn("%s: 'dpkg' not available. Assuming not ubuntu", name)
115- return
116-
117- supported = ('upstart', 'systemd')
118- if target not in supported:
119- log.warn("%s: target set to %s, expected one of: %s",
120- name, target, str(supported))
121-
122- if os.path.exists("/run/systemd/system"):
123- current = "systemd"
124- else:
125- current = "upstart"
126-
127- if current == target:
128- log.debug("%s: current = target = %s. nothing to do", name, target)
129- return
130-
131- try:
132- util.subp(['sh', '-s', target], data=SWITCH_INIT)
133- except util.ProcessExecutionError as e:
134- log.warn("%s: Failed to switch to init '%s'. %s", name, target, e)
135- return
136-
137- if util.is_false(reboot):
138- log.info("%s: switched '%s' to '%s'. reboot=false, not rebooting.",
139- name, current, target)
140- return
141-
142- try:
143- log.warn("%s: switched '%s' to '%s'. rebooting.",
144- name, current, target)
145- logging.flushLoggers(log)
146- _fire_reboot(log, wait_attempts=4, initial_sleep=4)
147- except Exception as e:
148- util.logexc(log, "Requested reboot did not happen!")
149- raise
150-
151-
152-def _fire_reboot(log, wait_attempts=6, initial_sleep=1, backoff=2):
153- util.subp(REBOOT_CMD)
154- start = time.time()
155- wait_time = initial_sleep
156- for _i in range(0, wait_attempts):
157- time.sleep(wait_time)
158- wait_time *= backoff
159- elapsed = time.time() - start
160- log.debug("Rebooted, but still running after %s seconds", int(elapsed))
161- # If we got here, not good
162- elapsed = time.time() - start
163- raise RuntimeError(("Reboot did not happen"
164- " after %s seconds!") % (int(elapsed)))
165-
166-# vi: ts=4 expandtab
167diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl
168index f4b9069..a537d65 100644
169--- a/config/cloud.cfg.tmpl
170+++ b/config/cloud.cfg.tmpl
171@@ -45,9 +45,6 @@ datasource_list: ['ConfigDrive', 'Azure', 'OpenStack', 'Ec2']
172 # The modules that run in the 'init' stage
173 cloud_init_modules:
174 - migrator
175-{% if variant in ["ubuntu", "unknown", "debian"] %}
176- - ubuntu-init-switch
177-{% endif %}
178 - seed_random
179 - bootcmd
180 - write-files
181diff --git a/doc/rtd/topics/modules.rst b/doc/rtd/topics/modules.rst
182index c963c09..cdb0f41 100644
183--- a/doc/rtd/topics/modules.rst
184+++ b/doc/rtd/topics/modules.rst
185@@ -50,7 +50,6 @@ Modules
186 .. automodule:: cloudinit.config.cc_ssh_authkey_fingerprints
187 .. automodule:: cloudinit.config.cc_ssh_import_id
188 .. automodule:: cloudinit.config.cc_timezone
189-.. automodule:: cloudinit.config.cc_ubuntu_init_switch
190 .. automodule:: cloudinit.config.cc_update_etc_hosts
191 .. automodule:: cloudinit.config.cc_update_hostname
192 .. automodule:: cloudinit.config.cc_users_groups
193diff --git a/packages/bddeb b/packages/bddeb
194index 609a94f..7c12354 100755
195--- a/packages/bddeb
196+++ b/packages/bddeb
197@@ -112,8 +112,7 @@ def get_parser():
198 parser.add_argument("--init-system", dest="init_system",
199 help=("build deb with INIT_SYSTEM=xxx"
200 " (default: %(default)s"),
201- default=os.environ.get("INIT_SYSTEM",
202- "upstart,systemd"))
203+ default=os.environ.get("INIT_SYSTEM", "systemd"))
204
205 parser.add_argument("--release", dest="release",
206 help=("build with changelog referencing RELEASE"),
207diff --git a/packages/debian/dirs b/packages/debian/dirs
208index 9a633c6..1315cf8 100644
209--- a/packages/debian/dirs
210+++ b/packages/debian/dirs
211@@ -1,6 +1,5 @@
212 var/lib/cloud
213 usr/bin
214-etc/init
215 usr/share/doc/cloud
216 etc/cloud
217 lib/udev/rules.d
218diff --git a/packages/debian/rules.in b/packages/debian/rules.in
219index 053b764..b87a5e8 100755
220--- a/packages/debian/rules.in
221+++ b/packages/debian/rules.in
222@@ -1,6 +1,6 @@
223 ## template:basic
224 #!/usr/bin/make -f
225-INIT_SYSTEM ?= upstart,systemd
226+INIT_SYSTEM ?= systemd
227 export PYBUILD_INSTALL_ARGS=--init-system=$(INIT_SYSTEM)
228 PYVER ?= python${pyver}
229
230diff --git a/setup.py b/setup.py
231index 5c65c7f..7662bd8 100755
232--- a/setup.py
233+++ b/setup.py
234@@ -191,6 +191,8 @@ class InitsysInstallData(install):
235 datakeys = [k for k in INITSYS_ROOTS
236 if k.partition(".")[0] == system]
237 for k in datakeys:
238+ if not INITSYS_FILES[k]:
239+ continue
240 self.distribution.data_files.append(
241 (INITSYS_ROOTS[k], INITSYS_FILES[k]))
242 # Force that command to reinitalize (with new file list)
243diff --git a/tests/cloud_tests/configs/modules/TODO.md b/tests/cloud_tests/configs/modules/TODO.md
244index d496da9..0b933b3 100644
245--- a/tests/cloud_tests/configs/modules/TODO.md
246+++ b/tests/cloud_tests/configs/modules/TODO.md
247@@ -89,8 +89,6 @@ Not applicable to write a test for this as it specifies when something should be
248 ## ssh authkey fingerprints
249 The authkey_hash key does not appear to work. In fact the default claims to be md5, however syslog only shows sha256
250
251-## ubuntu init switch
252-
253 ## update etc hosts
254 2016-11-17: Issues with changing /etc/hosts and lxc backend.
255

Subscribers

People subscribed via source and target branches