Merge ~silverdrake11/landscape-charm:hold_landscape_server into landscape-charm:main

Proposed by Kevin Nasto
Status: Merged
Merged at revision: 94663d85e6d3f2fa6b8abb28529548d7afc19aff
Proposed branch: ~silverdrake11/landscape-charm:hold_landscape_server
Merge into: landscape-charm:main
Diff against target: 76 lines (+12/-7)
2 files modified
lib/charms/operator_libs_linux/v0/apt.py (+4/-4)
src/charm.py (+8/-3)
Reviewer Review Type Date Requested Status
Mitch Burton Approve
Review via email: mp+460144@code.launchpad.net

Commit message

Holding package landscape-server unless upgrade action

To post a comment you must log in.
Revision history for this message
Kevin Nasto (silverdrake11) wrote (last edit ):

Manual testing instructions:

Update bundle.yaml landscape-server with 'landscape_ppa: ppa:landscape/self-hosted-23.03'. Note it must be under "options:"!
make build

ssh landscape-server/0
sudo apt-add-repository ppa:landscape/self-hosted-beta
sudo apt upgrade
Go to /about page and notice landscape server does not upgrade

juju run landscape-server/0 pause
juju run landscape-server/0 upgrade (landscape-server will upgrade)
juju run landscape-server/0 resume
Go to /about page and notice landscape server does upgrade

f7c631c... by Kevin Nasto

Slight changes. Also upgraded apt library

Revision history for this message
Kevin Nasto (silverdrake11) wrote :

Note this also includes an upgrade to the apt library, which was done by fetch-lib. Do not review this code

Revision history for this message
Mitch Burton (mitchburton) wrote :

Looks good. I haven't done a manual test, but I don't doubt the results of yours. Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/charms/operator_libs_linux/v0/apt.py b/lib/charms/operator_libs_linux/v0/apt.py
2index c3a2329..1400df7 100644
3--- a/lib/charms/operator_libs_linux/v0/apt.py
4+++ b/lib/charms/operator_libs_linux/v0/apt.py
5@@ -122,7 +122,7 @@ LIBAPI = 0
6
7 # Increment this PATCH version before using `charmcraft publish-lib` or reset
8 # to 0 if you are raising the major API version
9-LIBPATCH = 12
10+LIBPATCH = 13
11
12
13 VALID_SOURCE_TYPES = ("deb", "deb-src")
14@@ -250,10 +250,10 @@ class DebianPackage:
15 try:
16 env = os.environ.copy()
17 env["DEBIAN_FRONTEND"] = "noninteractive"
18- subprocess.run(_cmd, capture_output=True, check=True, env=env)
19+ subprocess.run(_cmd, capture_output=True, check=True, text=True, env=env)
20 except CalledProcessError as e:
21 raise PackageError(
22- "Could not {} package(s) [{}]: {}".format(command, [*package_names], e.output)
23+ "Could not {} package(s) [{}]: {}".format(command, [*package_names], e.stderr)
24 ) from None
25
26 def _add(self) -> None:
27@@ -476,7 +476,7 @@ class DebianPackage:
28 )
29 except CalledProcessError as e:
30 raise PackageError(
31- "Could not list packages in apt-cache: {}".format(e.output)
32+ "Could not list packages in apt-cache: {}".format(e.stderr)
33 ) from None
34
35 pkg_groups = output.strip().split("\n\n")
36diff --git a/src/charm.py b/src/charm.py
37index 3ef8671..569201f 100755
38--- a/src/charm.py
39+++ b/src/charm.py
40@@ -70,8 +70,9 @@ SCHEMA_SCRIPT = "/usr/bin/landscape-schema"
41 BOOTSTRAP_ACCOUNT_SCRIPT = "/opt/canonical/landscape/bootstrap-account"
42 HASH_ID_DATABASES = "/opt/canonical/landscape/hash-id-databases-ignore-maintenance"
43
44+LANDSCAPE_SERVER = "landscape-server"
45 LANDSCAPE_PACKAGES = (
46- "landscape-server",
47+ LANDSCAPE_SERVER,
48 "landscape-client",
49 "landscape-common",
50 )
51@@ -287,8 +288,8 @@ class LandscapeServerCharm(CharmBase):
52 # Add the Landscape Server PPA and install via apt.
53 check_call(["add-apt-repository", "-y", landscape_ppa])
54 # Explicitly ensure cache is up-to-date after adding the PPA.
55- apt.add_package(["landscape-server", "landscape-hashids"], update_cache=True)
56- check_call(["apt-mark", "hold", "landscape-hashids"])
57+ apt.add_package([LANDSCAPE_SERVER, "landscape-hashids"], update_cache=True)
58+ check_call(["apt-mark", "hold", "landscape-hashids", LANDSCAPE_SERVER])
59 except (PackageNotFoundError, PackageError, CalledProcessError) as exc:
60 logger.error("Failed to install packages")
61 raise exc # This will trigger juju's exponential retry
62@@ -1039,10 +1040,14 @@ command[check_{service}]=/usr/local/lib/nagios/plugins/check_systemd.py {service
63 for package in LANDSCAPE_PACKAGES:
64 try:
65 event.log(f"Upgrading {package}...")
66+ if package == LANDSCAPE_SERVER:
67+ check_call(["apt-mark", "unhold", LANDSCAPE_SERVER])
68 pkg = apt.DebianPackage.from_apt_cache(package)
69 pkg.ensure(state=apt.PackageState.Latest)
70 installed = apt.DebianPackage.from_installed_package(package)
71 event.log(f"Upgraded to {installed.version}...")
72+ if package == LANDSCAPE_SERVER:
73+ check_call(["apt-mark", "hold", LANDSCAPE_SERVER])
74 except PackageNotFoundError as e:
75 logger.error(
76 f"Could not upgrade package {package}. Reason: {e.message}"

Subscribers

People subscribed via source and target branches

to all changes: