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

Proposed by Simon Poirier
Status: Merged
Approved by: Andreas Hasenack
Approved revision: 02941a172e459345abd39b3c9ee2029c258ef23d
Merged at revision: 02941a172e459345abd39b3c9ee2029c258ef23d
Proposed branch: ~simpoir/ubuntu/+source/landscape-client:beyond_19.04_xenial
Merge into: ubuntu/+source/landscape-client:ubuntu/xenial-devel
Diff against target: 338 lines (+287/-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 (+219/-0)
Reviewer Review Type Date Requested Status
Andreas Hasenack Approve
Canonical Server Team Pending
Review via email: mp+369457@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

range-diff for xenial isn't clean, that's because it's not the same base version (16.03 vs 18.01 elsewhere). So let's see.

Just two small metadata changes inline.

- d/changelog update correct for the SRU

+1 with the metadata changes

review: Approve
Revision history for this message
Simon Poirier (simpoir) wrote :

Ok. I've updated the patches metadata

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

Thanks, sponsoring 02941a172e459345abd39b3c9ee2029c258ef23d

$ git push pkg upload/16.03-0ubuntu2.16.04.7
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.47 KiB | 735.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/16.03-0ubuntu2.16.04.7 -> upload/16.03-0ubuntu2.16.04.7

$ dput ubuntu ../landscape-client_16.03-0ubuntu2.16.04.7_source.changes
Checking signature on .changes
gpg: ../landscape-client_16.03-0ubuntu2.16.04.7_source.changes: Valid signature from AC983EB5BF6BCBA9
Checking signature on .dsc
gpg: ../landscape-client_16.03-0ubuntu2.16.04.7.dsc: Valid signature from AC983EB5BF6BCBA9
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading landscape-client_16.03-0ubuntu2.16.04.7.dsc: done.
  Uploading landscape-client_16.03-0ubuntu2.16.04.7.debian.tar.xz: done.
  Uploading landscape-client_16.03-0ubuntu2.16.04.7_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 fe8549b..58ef077 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,15 @@
6+landscape-client (16.03-0ubuntu2.16.04.7) xenial; 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> Fri, 28 Jun 2019 12:18:32 -0400
17+
18 landscape-client (16.03-0ubuntu2.16.04.6) xenial; 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 a5ed302..b0c5002 100644
37--- a/debian/landscape-client.postinst
38+++ b/debian/landscape-client.postinst
39@@ -123,6 +123,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..2e27a00
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: backport, https://github.com/CanonicalLtd/landscape-client/commit/ad28feeb7d3031268eeb206c4d8bdcd015ad79ae
58+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1828217
59+Last-Update: 2019-07-02
60+
61+--- a/landscape/lib/tests/test_vm_info.py
62++++ b/landscape/lib/tests/test_vm_info.py
63+@@ -192,6 +192,11 @@
64+ self.make_dmi_info("sys_vendor", "Some other vendor")
65+ self.assertEqual("", 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(LandscapeTest):
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_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 string with the virtualization type if it's known, an empty string
87+@@ -25,7 +28,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+@@ -86,6 +89,7 @@
97+ ("nutanix", "kvm"),
98+ ("openstack", "kvm"),
99+ ("qemu", "kvm"),
100++ ("kvm", "kvm"),
101+ ("vmware", "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 0097168..68f4a9a 100644
106--- a/debian/patches/series
107+++ b/debian/patches/series
108@@ -13,3 +13,5 @@ release-upgrade-success.patch
109 post-upgrade-reboot.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..e42aa29
117--- /dev/null
118+++ b/debian/patches/stagger-launch-1788518.patch
119@@ -0,0 +1,219 @@
120+Description: Add option to stagger launch of broker plugins.
121+Author: Simon Poirier <simon.poirier@canonical.com>
122+Origin: backport, 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+--- a/example.conf
127++++ b/example.conf
128+@@ -50,6 +50,16 @@
129+ #
130+ #ssl_public_key
131+
132++# The ratio over which to spread landscape intervals. This is to mitigate
133++# the impact of restarting the host of multiple landscape-client instances.
134++# Values range from 0.0 to 1.0, from unstaggered to spreading over
135++# the full interval.
136++#
137++# Default value is 0.1, meaning jobs will start with up to 10% delay
138++#
139++# Example:
140++# stagger_launch = 0.5
141++
142+ # If set to True interrupt (SIGINT) signals will be ignored by the
143+ # landscape-client daemon.
144+ ignore_sigint = False
145+--- a/landscape/broker/client.py
146++++ b/landscape/broker/client.py
147+@@ -1,4 +1,4 @@
148+-from logging import info, exception
149++from logging import info, exception, debug
150+
151+ from twisted.internet.defer import maybeDeferred, succeed
152+
153+@@ -6,6 +6,8 @@
154+ from landscape.lib.twisted_util import gather_results
155+ from landscape.amp import remote
156+
157++import random
158++
159+
160+ class HandlerNotFoundError(Exception):
161+ """A handler for the given message type was not found."""
162+@@ -104,8 +106,18 @@
163+ if self.run_immediately:
164+ self.run()
165+ if self.run_interval is not None:
166+- self._loop = self.client.reactor.call_every(self.run_interval,
167+- self.run)
168++ delay = (random.random() * self.run_interval *
169++ self.client.config.stagger_launch)
170++ debug("delaying start of %s for %d seconds",
171++ format_object(self), delay)
172++ self._loop = self.client.reactor.call_later(
173++ delay, self._start_loop)
174++
175++ def _start_loop(self):
176++ """Launch the client loop."""
177++ self._loop = self.client.reactor.call_every(
178++ self.run_interval,
179++ self.run)
180+
181+
182+ class BrokerClient(object):
183+@@ -124,10 +136,11 @@
184+ """
185+ name = "client"
186+
187+- def __init__(self, reactor):
188++ def __init__(self, reactor, config):
189+ super(BrokerClient, self).__init__()
190+ self.reactor = reactor
191+ self.broker = None
192++ self.config = config
193+ self._registered_messages = {}
194+ self._plugins = []
195+ self._plugin_names = {}
196+--- a/landscape/broker/tests/helpers.py
197++++ b/landscape/broker/tests/helpers.py
198+@@ -206,7 +206,9 @@
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+--- a/landscape/broker/tests/test_client.py
210++++ b/landscape/broker/tests/test_client.py
211+@@ -153,6 +153,26 @@
212+ deferred.callback(123)
213+ self.assertEquals(runs, [True, True])
214+
215++ @mock.patch("random.random")
216++ def test_run_interval_staggered(self, mock_random):
217++ """
218++ If a plugin has a run method and staggered_launch is set,
219++ the launch gets delayed by a random factor.
220++ """
221++ mock_random.return_value = 1.0
222++ plugin = BrokerClientPlugin()
223++ plugin.run_interval = 60
224++ plugin.run = mock.Mock()
225++ self.client.config.stagger_launch = 0.5
226++ self.client.add(plugin)
227++ self.client_reactor.advance(30)
228++ self.assertEqual(0, plugin.run.call_count)
229++ self.client_reactor.advance(60)
230++ self.assertEqual(1, plugin.run.call_count)
231++ self.client_reactor.advance(60)
232++ self.assertEqual(2, plugin.run.call_count)
233++ self.assertEqual(1, mock_random.call_count)
234++
235+ def test_run_immediately(self):
236+ """
237+ If a plugin has a C{run} method and C{run_immediately} is C{True},
238+--- a/landscape/deployment.py
239++++ b/landscape/deployment.py
240+@@ -356,6 +356,7 @@
241+ - C{ping_url} (C{"http://landscape.canonical.com/ping"})
242+ - C{ssl_public_key}
243+ - C{ignore_sigint} (C{False})
244++ - C{stagger_launch} (C{0.1})
245+ """
246+ parser = super(Configuration, self).make_parser()
247+ parser.add_option("-q", "--quiet", default=False, action="store_true",
248+@@ -393,6 +394,10 @@
249+ metavar="INTERVAL",
250+ help="The number of seconds between flushes to disk "
251+ "for persistent data.")
252++ parser.add_option("--stagger-launch", metavar="STAGGER_RATIO",
253++ dest="stagger_launch", default=0.1, type=float,
254++ help="Ratio, between 0 and 1, by which to scatter "
255++ "various tasks of landscape.")
256+
257+ # Hidden options, used for load-testing to run in-process clones
258+ parser.add_option("--clones", default=0, type=int, help=SUPPRESS_HELP)
259+--- a/landscape/manager/manager.py
260++++ b/landscape/manager/manager.py
261+@@ -12,7 +12,7 @@
262+ name = "manager"
263+
264+ def __init__(self, reactor, config):
265+- super(Manager, self).__init__(reactor)
266++ super(Manager, self).__init__(reactor, config)
267+ self.reactor = reactor
268+ self.config = config
269+ self.store = ManagerStore(self.config.store_filename)
270+--- a/landscape/monitor/monitor.py
271++++ b/landscape/monitor/monitor.py
272+@@ -12,7 +12,7 @@
273+
274+ def __init__(self, reactor, config, persist, persist_filename=None,
275+ step_size=5 * 60):
276+- super(Monitor, self).__init__(reactor)
277++ super(Monitor, self).__init__(reactor, config)
278+ self.reactor = reactor
279+ self.config = config
280+ self.persist = persist
281+--- a/landscape/tests/helpers.py
282++++ b/landscape/tests/helpers.py
283+@@ -401,6 +401,7 @@
284+ persist_filename = test_case.makePersistFile()
285+ test_case.config = MonitorConfiguration()
286+ test_case.config.load(["-c", test_case.config_filename])
287++ test_case.config.stagger_launch = 0 # let's keep tests deterministic
288+ test_case.reactor = FakeReactor()
289+ test_case.monitor = Monitor(
290+ test_case.reactor, test_case.config,
291+--- a/landscape/tests/test_configuration.py
292++++ b/landscape/tests/test_configuration.py
293+@@ -790,6 +790,13 @@
294+ self.script.query_access_group()
295+ self.assertEqual(self.config.access_group, u"webservers")
296+
297++ @mock.patch("landscape.configuration.input")
298++ def test_stagger_defined_on_command_line(self, mock_input):
299++ self.assertEqual(self.config.stagger_launch, 0.1)
300++ self.config.load_command_line(["--stagger-launch", "0.5"])
301++ self.assertEqual(self.config.stagger_launch, 0.5)
302++ mock_input.assert_not_called()
303++
304+ def test_show_header(self):
305+ help_snippet = "This script will"
306+ script_mock = self.mocker.patch(self.script)
307+--- a/man/landscape-config.1
308++++ b/man/landscape-config.1
309+@@ -1,5 +1,5 @@
310+ .\"Text automatically generated by txt2man
311+-.TH landscape-config 1 "10 July 2014" "" ""
312++.TH landscape-config 1 "14 February 2019" "" ""
313+ .SH NAME
314+ \fBlandscape-config \fP- configure the Landscape management client
315+ \fB
316+@@ -139,6 +139,11 @@
317+ server.
318+ .TP
319+ .B
320++\fB--stagger-launch\fP=STAGGER_RATIO
321++Ratio, between 0 and 1, by which to scatter various
322++tasks of landscape.
323++.TP
324++.B
325+ \fB--import\fP=FILENAME_OR_URL
326+ Filename or URL to import configuration from.
327+ Imported \fIoptions\fP behave as if they were passed in
328+--- a/man/landscape-config.txt
329++++ b/man/landscape-config.txt
330+@@ -58,6 +58,8 @@
331+ EC2 or UEC. Read below for details.
332+ --tags=TAGS Comma separated list of tag names to be sent to the
333+ server.
334++ --stagger-launch=STAGGER_RATIO Ratio, between 0 and 1, by which to scatter various
335++ tasks of landscape.
336+ --import=FILENAME_OR_URL Filename or URL to import configuration from.
337+ Imported options behave as if they were passed in
338+ the command line, with precedence being given to

Subscribers

People subscribed via source and target branches