Merge ~paelzer/ubuntu/+source/landscape-client:lp-1893716-reduce-login-overhead-JAMMY into ubuntu/+source/landscape-client:ubuntu/jammy-devel

Proposed by Christian Ehrhardt 
Status: Merged
Merge reported by: Christian Ehrhardt 
Merged at revision: 77318e87a8f52a23c9e271e17cec05f98e4cba54
Proposed branch: ~paelzer/ubuntu/+source/landscape-client:lp-1893716-reduce-login-overhead-JAMMY
Merge into: ubuntu/+source/landscape-client:ubuntu/jammy-devel
Diff against target: 86 lines (+45/-15)
3 files modified
debian/changelog (+12/-0)
debian/landscape-common.postrm (+6/-0)
debian/landscape-sysinfo.wrapper (+27/-15)
Reviewer Review Type Date Requested Status
Simon Poirier (community) Approve
Canonical Server packageset reviewers Pending
Canonical Server Pending
git-ubuntu import Pending
Review via email: mp+417914@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Added Simon for landscape POV ack.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

See the ongoing discussion in https://github.com/CanonicalLtd/landscape-client/pull/109
I'll refresh this PR and the PPA once this settled.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

PPA and Branch updated to the interim state of the upstream discussion.

77318e8... by Christian Ehrhardt 

changelog: avoid too frequent expensive operations (LP: #1893716)

Signed-off-by: Christian Ehrhardt <email address hidden>

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

+1 thanks for that change.

review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thanks.
Merged upstream in https://github.com/CanonicalLtd/landscape-client/pull/109

Uploading to Jammy

Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading landscape-client_19.12-0ubuntu13.dsc: done.
  Uploading landscape-client_19.12-0ubuntu13.debian.tar.xz: done.
  Uploading landscape-client_19.12-0ubuntu13_source.buildinfo: done.
  Uploading landscape-client_19.12-0ubuntu13_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 2217fe8..fcf9dca 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,15 @@
6+landscape-client (19.12-0ubuntu13) jammy; urgency=medium
7+
8+ * d/landscape-sysinfo.wrapper, d/landscape-common.postrm: avoid too
9+ frequent expensive operations (LP: #1893716)
10+ - use a cache file and refresh it only once per minute
11+ - use a single printf to format output
12+ - if the former info was useful and we'd replace it with "sorry, load to
13+ high" skip that update
14+ - remove the cache file on purge
15+
16+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Wed, 30 Mar 2022 12:32:38 +0200
17+
18 landscape-client (19.12-0ubuntu12) jammy; urgency=medium
19
20 * d/p/lp1903776-release-upgrade.patch (LP: #1903776)
21diff --git a/debian/landscape-common.postrm b/debian/landscape-common.postrm
22index bad36ca..6b5f8ab 100644
23--- a/debian/landscape-common.postrm
24+++ b/debian/landscape-common.postrm
25@@ -41,6 +41,12 @@ case "$1" in
26
27 LOG_DIR=/var/log/landscape
28 rm -f "${LOG_DIR}/sysinfo.log"*
29+
30+ #########################################
31+ # from landscape-common
32+
33+ CACHE_FILE="/var/lib/landscape/landscape-sysinfo.cache"
34+ rm -f "${CACHE_FILE}"
35 ;;
36
37 remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
38diff --git a/debian/landscape-sysinfo.wrapper b/debian/landscape-sysinfo.wrapper
39index e0ae2f3..54f139d 100644
40--- a/debian/landscape-sysinfo.wrapper
41+++ b/debian/landscape-sysinfo.wrapper
42@@ -1,17 +1,29 @@
43 #!/bin/sh
44-# pam_motd does not carry the environment
45-[ -f /etc/default/locale ] && . /etc/default/locale
46-export LANG
47-cores=$(grep -c ^processor /proc/cpuinfo 2>/dev/null)
48-[ "$cores" -eq "0" ] && cores=1
49-threshold="${cores:-1}.0"
50-if [ $(echo "`cut -f1 -d ' ' /proc/loadavg` < $threshold" | bc) -eq 1 ]; then
51- echo
52- echo -n " System information as of "
53- /bin/date
54- echo
55- /usr/bin/landscape-sysinfo
56-else
57- echo
58- echo " System information disabled due to load higher than $threshold"
59+
60+# don't try refresh this more than once per minute
61+# Due to cpu consumption and login delays (LP: #1893716)
62+stamp="/var/lib/landscape/landscape-sysinfo.cache"
63+NEED_UPDATE="FALSE"
64+[ -z "$(find "$stamp" -newermt 'now-1 minutes' 2> /dev/null)" ] && NEED_UPDATE="TRUE"
65+
66+if [ "$NEED_UPDATE" = "TRUE" ]; then
67+ # pam_motd does not carry the environment
68+ [ -f /etc/default/locale ] && . /etc/default/locale
69+ export LANG
70+ cores=$(grep -c ^processor /proc/cpuinfo 2>/dev/null)
71+ [ "$cores" -eq "0" ] && cores=1
72+ threshold="${cores:-1}.0"
73+ if [ $(echo "`cut -f1 -d ' ' /proc/loadavg` < $threshold" | bc) -eq 1 ]; then
74+ printf "\n System information as of %s\n\n%s\n" \
75+ "$(/bin/date)" \
76+ "$(/usr/bin/landscape-sysinfo)" \
77+ > "$stamp"
78+ else
79+ # do not replace a formerly good result due to load
80+ if ! grep -q "System information as of" $stamp 2> /dev/null; then
81+ printf "\n System information disabled due to load higher than %s\n" "$threshold" > "$stamp"
82+ fi
83+ fi
84 fi
85+
86+[ ! -r "$stamp" ] || cat "$stamp"

Subscribers

People subscribed via source and target branches