Merge ~lamoura/ubuntu/+source/ubuntu-advantage-tools:upload-29.1-mantic into ubuntu/+source/ubuntu-advantage-tools:ubuntu/devel

Proposed by Lucas Albuquerque Medeiros de Moura
Status: Merged
Merged at revision: 68ae060f416186f0b82edc22a12693a40c1a1668
Proposed branch: ~lamoura/ubuntu/+source/ubuntu-advantage-tools:upload-29.1-mantic
Merge into: ubuntu/+source/ubuntu-advantage-tools:ubuntu/devel
Diff against target: 195 lines (+71/-17)
7 files modified
debian/changelog (+6/-0)
features/anbox.feature (+32/-2)
features/attached_status.feature (+2/-1)
uaclient/entitlements/anbox.py (+22/-13)
uaclient/entitlements/entitlement_status.py (+1/-0)
uaclient/messages.py (+7/-0)
uaclient/version.py (+1/-1)
Reviewer Review Type Date Requested Status
Sergio Durigan Junior (community) Approve
Canonical Server Reporter Pending
Review via email: mp+448939@code.launchpad.net

Description of the change

Add feature that allows the Anbox service to be enabled on a container.
This is the only feature that is being added on top of release 29

To post a comment you must log in.
Revision history for this message
Lucas Albuquerque Medeiros de Moura (lamoura) wrote :
Download full text (15.4 KiB)

Mantic:
  - Source ubuntu-advantage-tools/29.1~rc1: Published
    + amd64: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=amd64&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging♻️
    + arm64: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=arm64&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging♻️
    + armhf: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=armhf&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging♻️
    + ppcel64: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=ppcel64&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging♻️
    + riscv64: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=riscv64&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging♻️
    + s390x: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=s390x&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging♻️
    + amd64: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=amd64&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging💍
    + arm64: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=arm64&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging💍
    + armhf: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=armhf&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging💍
    + ppcel64: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=ppcel64&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging💍
    + riscv64: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=riscv64&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging💍
    + s390x: https://autopkgtest.ubuntu.com/request.cgi?release=mantic&package=ubuntu-advantage-tools&arch=s390x&trigger=ubuntu-advantage-tools%2F29.1~rc1&ppa=ua-client%2Fstaging💍

Lunar:
  - Source ubuntu-advantage-tools/29.1~23.04~rc1: Published
    + amd64: https://autopkgtest.ubuntu.com/request.cgi?release=lunar&package=ubuntu-advantage-tools&arch=amd64&trigger=ubuntu-advantage-tools%2F29.1~23.04~rc1&ppa=ua-client%2Fstaging♻️
    + arm64: https://autopkgtest.ubuntu.com/request.cgi?release=lunar&package=ubuntu-advantage-tools&arch=arm64&trigger=ubuntu-advantage-tools%2F29.1~23.04~rc1&ppa=ua-client%2Fstaging♻️
    + armhf: https://autopkgtest.ubuntu.com/request.cgi?release=lunar&package=ubunt...

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks, Lucas.

dep8 results look fine.

Everything else LGTM; the changes are simple and don't affect the Debian packaging.

Uploaded:

$ dput ubuntu-advantage-tools_29.1_source.changes
Trying to upload package to ubuntu
Checking signature on .changes
gpg: /home/sergio/work/ubuntu-advantage-tools/ubuntu-advantage-tools_29.1_source.changes: Valid signature from 106DA1C8C3CBBF14
Checking signature on .dsc
gpg: /home/sergio/work/ubuntu-advantage-tools/ubuntu-advantage-tools_29.1.dsc: Valid signature from 106DA1C8C3CBBF14
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading ubuntu-advantage-tools_29.1.dsc: done.
  Uploading ubuntu-advantage-tools_29.1.tar.xz: done.
  Uploading ubuntu-advantage-tools_29.1_source.buildinfo: done.
  Uploading ubuntu-advantage-tools_29.1_source.changes: done.
Successfully uploaded packages.

review: Approve

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 26f78a9..6d7a651 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,9 @@
6+ubuntu-advantage-tools (29.1) mantic; urgency=medium
7+
8+ * anbox: allow enabling service on container using the --access-only flag
9+
10+ -- Lucas Moura <lucas.moura@canonical.com> Thu, 10 Aug 2023 11:08:46 -0300
11+
12 ubuntu-advantage-tools (29) mantic; urgency=medium
13
14 * d/control:
15diff --git a/features/anbox.feature b/features/anbox.feature
16index 4f50faa..424b575 100644
17--- a/features/anbox.feature
18+++ b/features/anbox.feature
19@@ -6,16 +6,46 @@ Feature: Enable anbox on Ubuntu
20 Scenario Outline: Enable Anbox cloud service in a container
21 Given a `<release>` machine with ubuntu-advantage-tools installed
22 When I attach `contract_token` with sudo and options `--no-auto-enable`
23+ When I run `pro status` as non-root
24+ Then stdout matches regexp:
25+ """
26+ anbox-cloud +yes +disabled
27+ """
28 Then I verify that running `pro enable anbox-cloud` `as non-root` exits `1`
29 And I will see the following on stderr:
30 """
31 This command must be run as root (try using sudo).
32 """
33- Then I verify that running `pro enable anbox-cloud` `with sudo` exits `1`
34+ When I verify that running `pro enable anbox-cloud` `with sudo` exits `1`
35+ Then I will see the following on stdout:
36+ """
37+ One moment, checking your subscription first
38+ It is only possible to enable Anbox Cloud on a container using
39+ the --access-only flag.
40+ """
41+ When I run `pro enable anbox-cloud --access-only` with sudo
42 Then I will see the following on stdout:
43 """
44 One moment, checking your subscription first
45- Cannot install Anbox Cloud on a container.
46+ Updating package lists
47+ Skipping installing packages
48+ Anbox Cloud access enabled
49+ """
50+ When I run `pro status` as non-root
51+ Then stdout matches regexp:
52+ """
53+ anbox-cloud +yes +enabled
54+ """
55+ When I run `apt-cache policy` with sudo
56+ Then apt-cache policy for the following url has permission `500`
57+ """
58+ https://archive.anbox-cloud.io/stable <release>/main amd64 Packages
59+ """
60+ When I run `pro disable anbox-cloud` with sudo
61+ And I run `pro status` as non-root
62+ Then stdout matches regexp:
63+ """
64+ anbox-cloud +yes +disabled
65 """
66
67 Examples: ubuntu release
68diff --git a/features/attached_status.feature b/features/attached_status.feature
69index 682e229..b59f0bd 100644
70--- a/features/attached_status.feature
71+++ b/features/attached_status.feature
72@@ -182,6 +182,7 @@ Feature: Attached status
73 Then stdout matches regexp:
74 """
75 SERVICE +ENTITLED +STATUS +DESCRIPTION
76+ anbox-cloud +yes +disabled +.*
77 esm-apps +yes +enabled +Expanded Security Maintenance for Applications
78 esm-infra +yes +enabled +Expanded Security Maintenance for Infrastructure
79 usg +yes +disabled +Security compliance and audit tools
80@@ -194,7 +195,7 @@ Feature: Attached status
81 Then stdout matches regexp:
82 """
83 SERVICE +ENTITLED +STATUS +DESCRIPTION
84- anbox-cloud +yes +n/a +.*
85+ anbox-cloud +yes +disabled +.*
86 cc-eal +yes +n/a +Common Criteria EAL2 Provisioning Packages
87 esm-apps +yes +enabled +Expanded Security Maintenance for Applications
88 esm-infra +yes +enabled +Expanded Security Maintenance for Infrastructure
89diff --git a/uaclient/entitlements/anbox.py b/uaclient/entitlements/anbox.py
90index 33e94ab..37a2b73 100644
91--- a/uaclient/entitlements/anbox.py
92+++ b/uaclient/entitlements/anbox.py
93@@ -1,12 +1,16 @@
94 from typing import Any, Dict, Optional, Tuple
95
96 from uaclient import contract, event_logger, messages, system
97+from uaclient.entitlements.entitlement_status import (
98+ CanEnableFailure,
99+ CanEnableFailureReason,
100+)
101 from uaclient.entitlements.repo import RepoEntitlement
102 from uaclient.files.state_files import (
103 AnboxCloudData,
104 anbox_cloud_credentials_file,
105 )
106-from uaclient.types import MessagingOperationsDict, StaticAffordance
107+from uaclient.types import MessagingOperationsDict
108
109 event = event_logger.get_event_logger()
110
111@@ -22,24 +26,29 @@ class AnboxEntitlement(RepoEntitlement):
112 supports_access_only = True
113
114 @property
115- def static_affordances(self) -> Tuple[StaticAffordance, ...]:
116- return (
117- (
118- messages.SERVICE_ERROR_INSTALL_ON_CONTAINER.format(
119- title=self.title
120- ),
121- lambda: system.is_container(),
122- False,
123- ),
124- )
125-
126- @property
127 def messaging(self) -> MessagingOperationsDict:
128 if not self.access_only:
129 return {"post_enable": [messages.ANBOX_RUN_INIT_CMD.msg]}
130 else:
131 return {}
132
133+ def can_enable(self) -> Tuple[bool, Optional[CanEnableFailure]]:
134+ ret, reason = super().can_enable()
135+
136+ if not ret:
137+ return ret, reason
138+
139+ if system.is_container() and not self.access_only:
140+ return (
141+ False,
142+ CanEnableFailure(
143+ CanEnableFailureReason.ONLY_ACCESS_ONLY_SUPPORTED,
144+ messages.ANBOX_FAIL_TO_ENABLE_ON_CONTAINER,
145+ ),
146+ )
147+
148+ return True, None
149+
150 def _perform_enable(self, silent: bool = False) -> bool:
151 ret = super()._perform_enable(silent=silent)
152
153diff --git a/uaclient/entitlements/entitlement_status.py b/uaclient/entitlements/entitlement_status.py
154index baa123f..af8bb5f 100644
155--- a/uaclient/entitlements/entitlement_status.py
156+++ b/uaclient/entitlements/entitlement_status.py
157@@ -96,6 +96,7 @@ class CanEnableFailureReason(enum.Enum):
158 INCOMPATIBLE_SERVICE = object()
159 INACTIVE_REQUIRED_SERVICES = object()
160 ACCESS_ONLY_NOT_SUPPORTED = object()
161+ ONLY_ACCESS_ONLY_SUPPORTED = object()
162
163
164 class CanEnableFailure:
165diff --git a/uaclient/messages.py b/uaclient/messages.py
166index 976c2a9..4fd06d8 100644
167--- a/uaclient/messages.py
168+++ b/uaclient/messages.py
169@@ -1384,6 +1384,13 @@ For more information, see https://anbox-cloud.io/docs/tut/installing-appliance
170 """,
171 )
172
173+ANBOX_FAIL_TO_ENABLE_ON_CONTAINER = NamedMessage(
174+ "anbox-fail-to-enable-on-container",
175+ """\
176+It is only possible to enable Anbox Cloud on a container using
177+the --access-only flag.""",
178+)
179+
180 INSTALLING_PACKAGES = "Installing {}"
181 UNINSTALLING_PACKAGES = "Uninstalling {}"
182 UNINSTALLING_PACKAGES_FAILED = "Failure when uninstalling {}"
183diff --git a/uaclient/version.py b/uaclient/version.py
184index 9fdbc8d..b8e1f94 100644
185--- a/uaclient/version.py
186+++ b/uaclient/version.py
187@@ -15,7 +15,7 @@ from uaclient.defaults import CANDIDATE_CACHE_PATH, UAC_RUN_PATH
188 from uaclient.exceptions import ProcessExecutionError
189 from uaclient.system import subp
190
191-__VERSION__ = "29"
192+__VERSION__ = "29.1"
193 PACKAGED_VERSION = "@@PACKAGED_VERSION@@"
194
195 CANDIDATE_REGEX = r"Candidate: (?P<candidate>.*?)\n"

Subscribers

People subscribed via source and target branches

to status/vote changes: