Merge ~simpoir/ubuntu/+source/landscape-client:beyond_19.04_bionic into ubuntu/+source/landscape-client:ubuntu/bionic-devel

Proposed by Simon Poirier
Status: Merged
Approved by: Andreas Hasenack
Approved revision: 8d11f9bc42b67bdef9e5f3a6540c650bbfa4288b
Merged at revision: 8d11f9bc42b67bdef9e5f3a6540c650bbfa4288b
Proposed branch: ~simpoir/ubuntu/+source/landscape-client:beyond_19.04_bionic
Merge into: ubuntu/+source/landscape-client:ubuntu/bionic-devel
Diff against target: 377 lines (+326/-1)
6 files modified
debian/changelog (+12/-0)
debian/landscape-client.init (+2/-1)
debian/landscape-client.postinst (+3/-0)
debian/patches/product-name-vminfo-1828217.patch (+49/-0)
debian/patches/series (+2/-0)
debian/patches/stagger-launch-1788518.patch (+258/-0)
Reviewer Review Type Date Requested Status
Andreas Hasenack Approve
git-ubuntu developers Pending
Review via email: mp+370075@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Verified it's the same change that already went into disco, bar the changelog:
$ git range-diff pkg/ubuntu/bionic-devel..beyond_19.04_bionic pkg/ubuntu/disco-devel..beyond_19.04_disco
1: a939d04 = 1: 643b439 Add d/p/product-name-vminfo-1828217.patch
2: 74bc2ea = 2: 3d0177f Default data_path in postinst (LP: #1728681)
3: 6dd6f7a = 3: 65bd8bf Add d/p/stagger-launch-1788518.patch
4: 75db615 = 4: 9188d8c Fix regression with d/landscape-client.init
5: 8d11f9b ! 5: a4c9ce7 Update changelog
(...)

The bugs will need the respective ubuntu release tasks, and note that the init one is claimed to only affect disco, so it would probably be good to add a note to the bug explaining why it's being "fixed" for non-disco, i.e., we want to keep the source package the same for all releases, etc, something like that.

+1

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Sponsoring 8d11f9bc42b67bdef9e5f3a6540c650bbfa4288b

Tagged and uploaded:
$ git push pkg upload/18.01-0ubuntu3.4
Enumerating objects: 32, done.
Counting objects: 100% (32/32), done.
Delta compression using up to 2 threads
Compressing objects: 100% (25/25), done.
Writing objects: 100% (25/25), 6.96 KiB | 713.00 KiB/s, done.
Total 25 (delta 17), reused 0 (delta 0)
To ssh://git.launchpad.net/~usd-import-team/ubuntu/+source/landscape-client
 * [new tag] upload/18.01-0ubuntu3.4 -> upload/18.01-0ubuntu3.4

$ dput ubuntu ../landscape-client_18.01-0ubuntu3.4_source.changes
Checking signature on .changes
gpg: ../landscape-client_18.01-0ubuntu3.4_source.changes: Valid signature from AC983EB5BF6BCBA9
Checking signature on .dsc
gpg: ../landscape-client_18.01-0ubuntu3.4.dsc: Valid signature from AC983EB5BF6BCBA9
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading landscape-client_18.01-0ubuntu3.4.dsc: done.
  Uploading landscape-client_18.01-0ubuntu3.4.debian.tar.xz: done.
  Uploading landscape-client_18.01-0ubuntu3.4_source.buildinfo: done.
  Uploading landscape-client_18.01-0ubuntu3.4_source.changes: done.
Successfully uploaded packages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 5e26fb2..53ea9c1 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,15 @@
6+landscape-client (18.01-0ubuntu3.4) bionic; urgency=medium
7+
8+ * d/p/product-name-vminfo-1828217.patch: Add product_name to things scanned
9+ for vm_info (LP: #1828217)
10+ * d/landscape-client.postinst: Set default value if data_path is
11+ missing. (LP: #1728681)
12+ * d/p/stagger-launch-1788518.patch: Add option to stagger launch of broker
13+ plugins. (LP: #1788518)
14+ * d/landscape-client.init: Fix init script stop action (LP: #1833137)
15+
16+ -- Simon Poirier <simon.poirier@canonical.com> Thu, 27 Jun 2019 11:07:30 -0400
17+
18 landscape-client (18.01-0ubuntu3.3) bionic; urgency=medium
19
20 * debian/patches/mem-usage-1685885.patch: Reduce memory usage by
21diff --git a/debian/landscape-client.init b/debian/landscape-client.init
22index fcaeafd..ed51cc2 100644
23--- a/debian/landscape-client.init
24+++ b/debian/landscape-client.init
25@@ -63,7 +63,8 @@ case "$1" in
26
27 stop)
28 log_daemon_msg "Stopping $NAME daemon"
29- start-stop-daemon --retry 30 --stop --quiet --pidfile $PIDFILE
30+ # not a typo, linux process names are truncated to 15chars
31+ start-stop-daemon --retry 30 --stop --quiet --pidfile $PIDFILE -n landscape-clien
32 log_end_msg $?
33 ;;
34
35diff --git a/debian/landscape-client.postinst b/debian/landscape-client.postinst
36index d8d91ba..6e441ea 100644
37--- a/debian/landscape-client.postinst
38+++ b/debian/landscape-client.postinst
39@@ -102,6 +102,9 @@ END
40 # user information. The flag file will be removed by the client when
41 # the update completes.
42 DATA_PATH="`grep ^data_path /etc/landscape/client.conf | cut -d= -f2 | tr -d '[[:space:]]'`"
43+ if [ -z "$DATA_PATH" ]; then
44+ DATA_PATH=/var/lib/landscape/client
45+ fi
46 install --owner=landscape --directory $DATA_PATH
47 USER_UPDATE_FLAG_FILE="$DATA_PATH/user-update-flag"
48 install --owner=landscape /dev/null $USER_UPDATE_FLAG_FILE
49diff --git a/debian/patches/product-name-vminfo-1828217.patch b/debian/patches/product-name-vminfo-1828217.patch
50new file mode 100644
51index 0000000..4420e0c
52--- /dev/null
53+++ b/debian/patches/product-name-vminfo-1828217.patch
54@@ -0,0 +1,49 @@
55+Description: Add product_name to things scanned for vm_info
56+Author: Simon Poirier <simon.poirier@canonical.com>
57+Origin: upstream, https://github.com/CanonicalLtd/landscape-client/commit/ad28feeb7d3031268eeb206c4d8bdcd015ad79ae
58+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1828217
59+Last-Update: 2019-06-14
60+
61+--- a/landscape/lib/tests/test_vm_info.py
62++++ b/landscape/lib/tests/test_vm_info.py
63+@@ -179,6 +179,11 @@
64+ self.make_dmi_info("sys_vendor", "Some other vendor")
65+ self.assertEqual(b"", get_vm_info(root_path=self.root_path))
66+
67++ def test_get_vm_info_with_kvm_product(self):
68++ """get_vm_info returns 'kvm', if product_name is 'KVM'."""
69++ self.make_dmi_info("product_name", "KVM")
70++ self.assertEqual(b"kvm", get_vm_info(root_path=self.root_path))
71++
72+
73+ class GetContainerInfoTest(BaseTestCase):
74+
75+--- a/landscape/lib/vm_info.py
76++++ b/landscape/lib/vm_info.py
77+@@ -6,6 +6,9 @@
78+ from landscape.lib.fs import read_text_file
79+
80+
81++DMI_FILES = ("sys_vendor", "chassis_vendor", "bios_vendor", "product_name")
82++
83++
84+ def get_vm_info(root_path="/"):
85+ """
86+ Return a bytestring with the virtualization type if it's known, an empty
87+@@ -22,7 +25,7 @@
88+ # Iterate through all dmi *_vendors, as clouds can (and will) customize
89+ # sysinfo values. (https://libvirt.org/formatdomain.html#elementsSysinfo)
90+ dmi_info_path = os.path.join(root_path, "sys/class/dmi/id")
91+- for dmi_info_file in ("sys_vendor", "chassis_vendor", "bios_vendor"):
92++ for dmi_info_file in DMI_FILES:
93+ dmi_vendor_path = os.path.join(dmi_info_path, dmi_info_file)
94+ if not os.path.exists(dmi_vendor_path):
95+ continue
96+@@ -76,6 +79,7 @@
97+ ("nutanix", b"kvm"),
98+ ("openstack", b"kvm"),
99+ ("qemu", b"kvm"),
100++ ("kvm", b"kvm"),
101+ ("vmware", b"vmware"))
102+ for name, vm_type in content_vendors_map:
103+ if name in vendor:
104diff --git a/debian/patches/series b/debian/patches/series
105index 79d72dd..ebfbf13 100644
106--- a/debian/patches/series
107+++ b/debian/patches/series
108@@ -7,3 +7,5 @@ post-upgrade-reboot.patch
109 unicode-tags-script.patch
110 1616116-resync-loop.patch
111 mem-usage-1685885.patch
112+product-name-vminfo-1828217.patch
113+stagger-launch-1788518.patch
114diff --git a/debian/patches/stagger-launch-1788518.patch b/debian/patches/stagger-launch-1788518.patch
115new file mode 100644
116index 0000000..d0f2908
117--- /dev/null
118+++ b/debian/patches/stagger-launch-1788518.patch
119@@ -0,0 +1,258 @@
120+Description: Add option to stagger launch of broker plugins.
121+Author: Simon Poirier <simon.poirier@canonical.com>
122+Origin: upstream, https://github.com/CanonicalLtd/landscape-client/commit/597a584083f5245b8960e6c20d67e0fe25bdcdc2
123+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1788518
124+Last-Update: 2019-06-14
125+
126+diff --git a/example.conf b/example.conf
127+index 47dac275..3965d29d 100644
128+--- a/example.conf
129++++ b/example.conf
130+@@ -50,6 +50,16 @@ ping_url = http://landscape.canonical.com/ping
131+ #
132+ #ssl_public_key
133+
134++# The ratio over which to spread landscape intervals. This is to mitigate
135++# the impact of restarting the host of multiple landscape-client instances.
136++# Values range from 0.0 to 1.0, from unstaggered to spreading over
137++# the full interval.
138++#
139++# Default value is 0.1, meaning jobs will start with up to 10% delay
140++#
141++# Example:
142++# stagger_launch = 0.5
143++
144+ # If set to True interrupt (SIGINT) signals will be ignored by the
145+ # landscape-client daemon.
146+ ignore_sigint = False
147+diff --git a/landscape/client/broker/client.py b/landscape/client/broker/client.py
148+index 62287329..042c18a4 100644
149+--- a/landscape/client/broker/client.py
150++++ b/landscape/client/broker/client.py
151+@@ -1,5 +1,6 @@
152+-from logging import info, exception, error
153++from logging import info, exception, error, debug
154+ import sys
155++import random
156+
157+ from twisted.internet.defer import maybeDeferred, succeed
158+
159+@@ -105,9 +106,18 @@ class BrokerClientPlugin(object):
160+ if self.run_immediately:
161+ self._run_with_error_log()
162+ if self.run_interval is not None:
163+- self._loop = self.client.reactor.call_every(
164+- self.run_interval,
165+- self._run_with_error_log)
166++ delay = (random.random() * self.run_interval *
167++ self.client.config.stagger_launch)
168++ debug("delaying start of %s for %d seconds",
169++ format_object(self), delay)
170++ self._loop = self.client.reactor.call_later(
171++ delay, self._start_loop)
172++
173++ def _start_loop(self):
174++ """Launch the client loop."""
175++ self._loop = self.client.reactor.call_every(
176++ self.run_interval,
177++ self._run_with_error_log)
178+
179+ def _run_with_error_log(self):
180+ """Wrap self.run in a Deferred with a logging error handler."""
181+@@ -140,10 +150,11 @@ class BrokerClient(object):
182+ """
183+ name = "client"
184+
185+- def __init__(self, reactor):
186++ def __init__(self, reactor, config):
187+ super(BrokerClient, self).__init__()
188+ self.reactor = reactor
189+ self.broker = None
190++ self.config = config
191+ self._registered_messages = {}
192+ self._plugins = []
193+ self._plugin_names = {}
194+diff --git a/landscape/client/broker/tests/helpers.py b/landscape/client/broker/tests/helpers.py
195+index 97c5e4f4..fc010209 100644
196+--- a/landscape/client/broker/tests/helpers.py
197++++ b/landscape/client/broker/tests/helpers.py
198+@@ -206,7 +206,9 @@ class BrokerClientHelper(RemoteBrokerHelper):
199+ # The client needs its own reactor to avoid infinite loops
200+ # when the broker broadcasts and event
201+ test_case.client_reactor = FakeReactor()
202+- test_case.client = BrokerClient(test_case.client_reactor)
203++ config = BrokerConfiguration()
204++ config.stagger_launch = 0 # let's keep tests deterministic
205++ test_case.client = BrokerClient(test_case.client_reactor, config)
206+ test_case.client.broker = test_case.remote
207+
208+
209+diff --git a/landscape/client/broker/tests/test_client.py b/landscape/client/broker/tests/test_client.py
210+index 967f77db..3295b02b 100644
211+--- a/landscape/client/broker/tests/test_client.py
212++++ b/landscape/client/broker/tests/test_client.py
213+@@ -178,6 +178,26 @@ class BrokerClientTest(LandscapeTest):
214+ deferred.callback(123)
215+ self.assertEquals(runs, [True, True])
216+
217++ @mock.patch("random.random")
218++ def test_run_interval_staggered(self, mock_random):
219++ """
220++ If a plugin has a run method and staggered_launch is set,
221++ the launch gets delayed by a random factor.
222++ """
223++ mock_random.return_value = 1.0
224++ plugin = BrokerClientPlugin()
225++ plugin.run_interval = 60
226++ plugin.run = mock.Mock()
227++ self.client.config.stagger_launch = 0.5
228++ self.client.add(plugin)
229++ self.client_reactor.advance(30)
230++ self.assertEqual(0, plugin.run.call_count)
231++ self.client_reactor.advance(60)
232++ self.assertEqual(1, plugin.run.call_count)
233++ self.client_reactor.advance(60)
234++ self.assertEqual(2, plugin.run.call_count)
235++ self.assertEqual(1, mock_random.call_count)
236++
237+ def test_run_immediately(self):
238+ """
239+ If a plugin has a C{run} method and C{run_immediately} is C{True},
240+diff --git a/landscape/client/deployment.py b/landscape/client/deployment.py
241+index 8c2f905e..7c5464cb 100644
242+--- a/landscape/client/deployment.py
243++++ b/landscape/client/deployment.py
244+@@ -82,6 +82,7 @@ class Configuration(BaseConfiguration):
245+ - C{ping_url} (C{"http://landscape.canonical.com/ping"})
246+ - C{ssl_public_key}
247+ - C{ignore_sigint} (C{False})
248++ - C{stagger_launch} (C{0.1})
249+ """
250+ parser = super(Configuration, self).make_parser()
251+ logging.add_cli_options(parser, logdir="/var/log/landscape")
252+@@ -111,6 +112,10 @@ class Configuration(BaseConfiguration):
253+ metavar="INTERVAL",
254+ help="The number of seconds between flushes to disk "
255+ "for persistent data.")
256++ parser.add_option("--stagger-launch", metavar="STAGGER_RATIO",
257++ dest="stagger_launch", default=0.1, type=float,
258++ help="Ratio, between 0 and 1, by which to scatter "
259++ "various tasks of landscape.")
260+
261+ # Hidden options, used for load-testing to run in-process clones
262+ parser.add_option("--clones", default=0, type=int, help=SUPPRESS_HELP)
263+diff --git a/landscape/client/manager/manager.py b/landscape/client/manager/manager.py
264+index a662e13e..18d13148 100644
265+--- a/landscape/client/manager/manager.py
266++++ b/landscape/client/manager/manager.py
267+@@ -12,7 +12,7 @@ class Manager(BrokerClient):
268+ name = "manager"
269+
270+ def __init__(self, reactor, config):
271+- super(Manager, self).__init__(reactor)
272++ super(Manager, self).__init__(reactor, config)
273+ self.reactor = reactor
274+ self.config = config
275+ self.store = ManagerStore(self.config.store_filename)
276+diff --git a/landscape/client/monitor/monitor.py b/landscape/client/monitor/monitor.py
277+index 7ab82560..ebd3823d 100644
278+--- a/landscape/client/monitor/monitor.py
279++++ b/landscape/client/monitor/monitor.py
280+@@ -12,7 +12,7 @@ class Monitor(BrokerClient):
281+
282+ def __init__(self, reactor, config, persist, persist_filename=None,
283+ step_size=5 * 60):
284+- super(Monitor, self).__init__(reactor)
285++ super(Monitor, self).__init__(reactor, config)
286+ self.reactor = reactor
287+ self.config = config
288+ self.persist = persist
289+diff --git a/landscape/client/tests/helpers.py b/landscape/client/tests/helpers.py
290+index 73775f99..a15353fc 100644
291+--- a/landscape/client/tests/helpers.py
292++++ b/landscape/client/tests/helpers.py
293+@@ -175,6 +175,7 @@ class MonitorHelper(FakeBrokerServiceHelper):
294+ persist_filename = test_case.makePersistFile()
295+ test_case.config = MonitorConfiguration()
296+ test_case.config.load(["-c", test_case.config_filename])
297++ test_case.config.stagger_launch = 0 # let's keep tests deterministic
298+ test_case.reactor = FakeReactor()
299+ test_case.monitor = Monitor(
300+ test_case.reactor, test_case.config,
301+diff --git a/landscape/client/tests/test_configuration.py b/landscape/client/tests/test_configuration.py
302+index 58381321..36d6d3ec 100644
303+--- a/landscape/client/tests/test_configuration.py
304++++ b/landscape/client/tests/test_configuration.py
305+@@ -753,6 +753,13 @@ class LandscapeSetupScriptTest(LandscapeTest):
306+ self.assertEqual(self.config.access_group, u"webservers")
307+ mock_input.assert_not_called()
308+
309++ @mock.patch("landscape.client.configuration.input")
310++ def test_stagger_defined_on_command_line(self, mock_input):
311++ self.assertEqual(self.config.stagger_launch, 0.1)
312++ self.config.load_command_line(["--stagger-launch", "0.5"])
313++ self.assertEqual(self.config.stagger_launch, 0.5)
314++ mock_input.assert_not_called()
315++
316+ @mock.patch("landscape.client.configuration.show_help")
317+ def test_show_header(self, mock_show_help):
318+ help_snippet = "This script will"
319+diff --git a/man/landscape-client.1 b/man/landscape-client.1
320+index 3a16c4a9..adb4bdc1 100644
321+--- a/man/landscape-client.1
322++++ b/man/landscape-client.1
323+@@ -1,5 +1,5 @@
324+ .\" Text automatically generated by txt2man
325+-.TH landscape-client 1 "05 January 2017" "" ""
326++.TH landscape-client 1 "14 February 2019" "" ""
327+ .SH NAME
328+ \fBlandscape-client \fP- Landscape system client
329+ \fB
330+diff --git a/man/landscape-config.1 b/man/landscape-config.1
331+index 6f362f2f..7d398fff 100644
332+--- a/man/landscape-config.1
333++++ b/man/landscape-config.1
334+@@ -1,5 +1,5 @@
335+ .\" Text automatically generated by txt2man
336+-.TH landscape-config 1 "05 January 2017" "" ""
337++.TH landscape-config 1 "14 February 2019" "" ""
338+ .SH NAME
339+ \fBlandscape-config \fP- configure the Landscape management client
340+ \fB
341+@@ -139,6 +139,11 @@ Comma separated list of tag names to be sent to the
342+ server.
343+ .TP
344+ .B
345++\fB--stagger-launch\fP=STAGGER_RATIO
346++Ratio, between 0 and 1, by which to scatter various
347++tasks of landscape.
348++.TP
349++.B
350+ \fB--import\fP=FILENAME_OR_URL
351+ Filename or URL to import configuration from.
352+ Imported \fIoptions\fP behave as if they were passed in
353+diff --git a/man/landscape-config.txt b/man/landscape-config.txt
354+index 223398b7..5a100bf0 100644
355+--- a/man/landscape-config.txt
356++++ b/man/landscape-config.txt
357+@@ -58,6 +58,8 @@ OPTIONS
358+ EC2 or UEC. Read below for details.
359+ --tags=TAGS Comma separated list of tag names to be sent to the
360+ server.
361++ --stagger-launch=STAGGER_RATIO Ratio, between 0 and 1, by which to scatter various
362++ tasks of landscape.
363+ --import=FILENAME_OR_URL Filename or URL to import configuration from.
364+ Imported options behave as if they were passed in
365+ the command line, with precedence being given to
366+diff --git a/man/landscape-sysinfo.1 b/man/landscape-sysinfo.1
367+index e8dd2ff4..90852975 100644
368+--- a/man/landscape-sysinfo.1
369++++ b/man/landscape-sysinfo.1
370+@@ -1,5 +1,5 @@
371+ .\" Text automatically generated by txt2man
372+-.TH landscape-sysinfo 1 "07 March 2018" "" ""
373++.TH landscape-sysinfo 1 "14 February 2019" "" ""
374+ .SH NAME
375+ \fBlandscape-sysinfo \fP- Display a summary of the current system status
376+ \fB
377+

Subscribers

People subscribed via source and target branches