Merge ~orndorffgrant/ubuntu/+source/ubuntu-advantage-tools:upload-27.11.3-kinetic into ubuntu/+source/ubuntu-advantage-tools:ubuntu/devel
- Git
- lp:~orndorffgrant/ubuntu/+source/ubuntu-advantage-tools
- upload-27.11.3-kinetic
- Merge into ubuntu/devel
Proposed by
Grant Orndorff
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 35d791d5611a4d10674b8c0934daad67859c2ec1 | ||||||||
Proposed branch: | ~orndorffgrant/ubuntu/+source/ubuntu-advantage-tools:upload-27.11.3-kinetic | ||||||||
Merge into: | ubuntu/+source/ubuntu-advantage-tools:ubuntu/devel | ||||||||
Diff against target: |
1047 lines (+302/-105) 27 files modified
apt-hook/20apt-esm-hook.conf (+1/-1) apt-hook/json-hook.cc (+15/-5) debian/changelog (+13/-0) debian/ubuntu-advantage-tools.postinst (+32/-0) features/api_full_auto_attach.feature (+1/-1) features/apt_messages.feature (+88/-23) features/cloud_pro_clone.feature (+0/-1) features/daemon.feature (+3/-2) features/docker.feature (+3/-1) features/environment.py (+4/-4) features/ubuntu_pro.feature (+3/-0) features/unattached_commands.feature (+5/-6) integration-requirements.txt (+1/-1) uaclient/actions.py (+24/-16) uaclient/cli.py (+9/-0) uaclient/config.py (+12/-0) uaclient/defaults.py (+2/-2) uaclient/jobs/update_messaging.py (+17/-27) uaclient/messages.py (+0/-4) uaclient/system.py (+13/-0) uaclient/tests/test_actions.py (+36/-1) uaclient/tests/test_cli_config_set.py (+2/-1) uaclient/tests/test_cli_config_show.py (+1/-0) uaclient/tests/test_cli_config_unset.py (+1/-1) uaclient/tests/test_config.py (+4/-1) uaclient/tests/test_version.py (+5/-2) uaclient/version.py (+7/-5) |
||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robie Basak | ubuntu-sru | Approve | |
Paride Legovini (community) | Approve | ||
Canonical Server Reporter | Pending | ||
Review via email: mp+431701@code.launchpad.net |
Commit message
Description of the change
This is release 27.11.3 of ubuntu-
You can find the description of changes in the overall SRU bug here: https:/
To post a comment you must log in.
Revision history for this message
Robie Basak (racb) wrote : | # |
Revision history for this message
Grant Orndorff (orndorffgrant) wrote : | # |
Thanks racb!
I responded to the inline comments - I agree with them and have added bugs to our github to follow up with them in a future release.
Ack to the "apt news" status and thanks for flagging that formally on the bug. I agree that we can't move forward until that is fully resolved.
Revision history for this message
Paride Legovini (paride) wrote : | # |
Following-up to my previous review: the new changes LGTM. I'm proceeding with the uploads.
review:
Approve
Revision history for this message
Robie Basak (racb) wrote : | # |
"apt news" resolved by https:/
review:
Approve
(ubuntu-sru)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/apt-hook/20apt-esm-hook.conf b/apt-hook/20apt-esm-hook.conf | |||
2 | index 0cc6823..07c3362 100644 | |||
3 | --- a/apt-hook/20apt-esm-hook.conf | |||
4 | +++ b/apt-hook/20apt-esm-hook.conf | |||
5 | @@ -10,6 +10,6 @@ APT::Install::Pre-Invoke { | |||
6 | 10 | "[ ! -f /usr/lib/ubuntu-advantage/apt-esm-hook ] || /usr/lib/ubuntu-advantage/apt-esm-hook pre-invoke || true"; | 10 | "[ ! -f /usr/lib/ubuntu-advantage/apt-esm-hook ] || /usr/lib/ubuntu-advantage/apt-esm-hook pre-invoke || true"; |
7 | 11 | }; | 11 | }; |
8 | 12 | 12 | ||
10 | 13 | AptCli::Hooks::Upgrade { | 13 | binary::apt::AptCli::Hooks::Upgrade { |
11 | 14 | "[ ! -f /usr/lib/ubuntu-advantage/apt-esm-json-hook ] || /usr/lib/ubuntu-advantage/apt-esm-json-hook || true"; | 14 | "[ ! -f /usr/lib/ubuntu-advantage/apt-esm-json-hook ] || /usr/lib/ubuntu-advantage/apt-esm-json-hook || true"; |
12 | 15 | }; | 15 | }; |
13 | diff --git a/apt-hook/json-hook.cc b/apt-hook/json-hook.cc | |||
14 | index 0efaa81..16042f8 100644 | |||
15 | --- a/apt-hook/json-hook.cc | |||
16 | +++ b/apt-hook/json-hook.cc | |||
17 | @@ -257,23 +257,33 @@ int run() | |||
18 | 257 | 257 | ||
19 | 258 | json_object_put(hello_req.root_msg); | 258 | json_object_put(hello_req.root_msg); |
20 | 259 | 259 | ||
23 | 260 | jsonrpc_request stats_req; | 260 | jsonrpc_request hook_req; |
24 | 261 | success = read_jsonrpc_request(socket_in, stats_req); | 261 | success = read_jsonrpc_request(socket_in, hook_req); |
25 | 262 | if (!success) { | 262 | if (!success) { |
26 | 263 | std::cerr << "ua-hook: failed to read hook msg" << std::endl; | 263 | std::cerr << "ua-hook: failed to read hook msg" << std::endl; |
27 | 264 | return 0; | 264 | return 0; |
28 | 265 | } | 265 | } |
30 | 266 | if (stats_req.method == "org.debian.apt.hooks.install.statistics") { | 266 | if (hook_req.method == "org.debian.apt.hooks.install.statistics") { |
31 | 267 | security_package_counts counts; | 267 | security_package_counts counts; |
33 | 268 | success = count_security_packages_from_apt_stats_json(stats_req.params, counts); | 268 | success = count_security_packages_from_apt_stats_json(hook_req.params, counts); |
34 | 269 | if (success) { | 269 | if (success) { |
35 | 270 | std::string message = create_count_message(counts); | 270 | std::string message = create_count_message(counts); |
36 | 271 | if (message != "") { | 271 | if (message != "") { |
37 | 272 | std::cout << message << std::endl; | 272 | std::cout << message << std::endl; |
38 | 273 | } | 273 | } |
39 | 274 | } | 274 | } |
40 | 275 | } else if (hook_req.method == "org.debian.apt.hooks.install.pre-prompt") { | ||
41 | 276 | std::ifstream apt_news_flag_file("/var/lib/ubuntu-advantage/flags/show-apt-news"); | ||
42 | 277 | if (apt_news_flag_file.is_open()) { | ||
43 | 278 | std::cout << "#" << std::endl; | ||
44 | 279 | std::cout << "# News about significant security updates, features and services will" << std::endl; | ||
45 | 280 | std::cout << "# appear here to raise awareness and perhaps tease /r/Linux ;)" << std::endl; | ||
46 | 281 | std::cout << "# Use 'pro config set apt_news=false' to hide this and future APT news." << std::endl; | ||
47 | 282 | std::cout << "#" << std::endl; | ||
48 | 283 | apt_news_flag_file.close(); | ||
49 | 284 | } | ||
50 | 275 | } | 285 | } |
52 | 276 | json_object_put(stats_req.root_msg); | 286 | json_object_put(hook_req.root_msg); |
53 | 277 | 287 | ||
54 | 278 | jsonrpc_request bye_req; | 288 | jsonrpc_request bye_req; |
55 | 279 | success = read_jsonrpc_request(socket_in, bye_req); | 289 | success = read_jsonrpc_request(socket_in, bye_req); |
56 | diff --git a/debian/changelog b/debian/changelog | |||
57 | index a5acfc4..e0d5868 100644 | |||
58 | --- a/debian/changelog | |||
59 | +++ b/debian/changelog | |||
60 | @@ -1,3 +1,16 @@ | |||
61 | 1 | ubuntu-advantage-tools (27.11.3~22.10.1) kinetic; urgency=medium | ||
62 | 2 | |||
63 | 3 | * New upstream release 27.11.3: (LP: #1993006) | ||
64 | 4 | - d/postinst: remove the Ubuntu Pro beta apt message and set up the | ||
65 | 5 | configurable flag for "APT news" instead | ||
66 | 6 | - collect-logs: do not fail if a file cannot be read (LP: #1991858) | ||
67 | 7 | - config: add a flag to disable "APT news" (LP: 1992026) | ||
68 | 8 | - messaging: add announcement of "APT news" to apt output | ||
69 | 9 | - messaging: only show "APT news" when using apt binary (GH: #2288) | ||
70 | 10 | - version: use /run instead of /tmp for version file (GH: #2294) | ||
71 | 11 | |||
72 | 12 | -- Grant Orndorff <grant.orndorff@canonical.com> Fri, 14 Oct 2022 16:55:27 -0400 | ||
73 | 13 | |||
74 | 1 | ubuntu-advantage-tools (27.11.2~22.10.1) kinetic; urgency=medium | 14 | ubuntu-advantage-tools (27.11.2~22.10.1) kinetic; urgency=medium |
75 | 2 | 15 | ||
76 | 3 | * New upstream release 27.11.2: (LP: #1991173) | 16 | * New upstream release 27.11.2: (LP: #1991173) |
77 | diff --git a/debian/ubuntu-advantage-tools.postinst b/debian/ubuntu-advantage-tools.postinst | |||
78 | index 4a677fc..73b914b 100644 | |||
79 | --- a/debian/ubuntu-advantage-tools.postinst | |||
80 | +++ b/debian/ubuntu-advantage-tools.postinst | |||
81 | @@ -57,6 +57,13 @@ OLD_LICENSE_CHECK_MARKER_FILE="/var/lib/ubuntu-advantage/marker-license-check" | |||
82 | 57 | MACHINE_TOKEN_FILE="/var/lib/ubuntu-advantage/private/machine-token.json" | 57 | MACHINE_TOKEN_FILE="/var/lib/ubuntu-advantage/private/machine-token.json" |
83 | 58 | PUBLIC_MACHINE_TOKEN_FILE="/var/lib/ubuntu-advantage/machine-token.json" | 58 | PUBLIC_MACHINE_TOKEN_FILE="/var/lib/ubuntu-advantage/machine-token.json" |
84 | 59 | 59 | ||
85 | 60 | UA_MESSAGES_DIR="/var/lib/ubuntu-advantage/messages" | ||
86 | 61 | APT_ESM_MESSAGE_FILE="$UA_MESSAGES_DIR/apt-pre-invoke-esm-service-status" | ||
87 | 62 | ESM_APPS_APT_MSG_FILES="$UA_MESSAGES_DIR/apt-pre-invoke-no-packages-apps.tmpl $UA_MESSAGES_DIR/apt-pre-invoke-no-packages-apps $UA_MESSAGES_DIR/apt-pre-invoke-packages-apps.tmpl $UA_MESSAGES_DIR/apt-pre-invoke-packages-apps" | ||
88 | 63 | UA_FLAGS_DIR="/var/lib/ubuntu-advantage/flags" | ||
89 | 64 | APT_NEWS_FLAG_FILE="$UA_FLAGS_DIR/show-apt-news" | ||
90 | 65 | |||
91 | 66 | TMP_CANDIDATE_CACHE_PATH="/tmp/ubuntu-advantage/candidate-version" | ||
92 | 60 | 67 | ||
93 | 61 | # Rename apt config files for ua services removing ubuntu release names | 68 | # Rename apt config files for ua services removing ubuntu release names |
94 | 62 | redact_ubuntu_release_from_ua_apt_filenames() { | 69 | redact_ubuntu_release_from_ua_apt_filenames() { |
95 | @@ -384,6 +391,29 @@ machine_token_file.write(content=content) | |||
96 | 384 | " | 391 | " |
97 | 385 | } | 392 | } |
98 | 386 | 393 | ||
99 | 394 | migrate_ubuntu_pro_beta_banner() { | ||
100 | 395 | PREVIOUS_PKG_VER=$1 | ||
101 | 396 | # This only shipped in 27.11.2~ | ||
102 | 397 | if dpkg --compare-versions "$PREVIOUS_PKG_VER" ge "27.11.2~" \ | ||
103 | 398 | && dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "27.11.3~"; then | ||
104 | 399 | # if the banner was present, remove it and add the new flag file which is configurable | ||
105 | 400 | if [ -f $APT_ESM_MESSAGE_FILE ]; then | ||
106 | 401 | if cat $APT_ESM_MESSAGE_FILE | grep -q "Try Ubuntu Pro beta"; then | ||
107 | 402 | rm -f $APT_ESM_MESSAGE_FILE | ||
108 | 403 | rm -f $ESM_APPS_APT_MSG_FILES | ||
109 | 404 | mkdir -p $UA_FLAGS_DIR | ||
110 | 405 | touch $APT_NEWS_FLAG_FILE | ||
111 | 406 | fi | ||
112 | 407 | fi | ||
113 | 408 | fi | ||
114 | 409 | } | ||
115 | 410 | |||
116 | 411 | cleanup_candidate_version_stamp_permissions() { | ||
117 | 412 | if [ -f $TMP_CANDIDATE_CACHE_PATH ]; then | ||
118 | 413 | rm -f $TMP_CANDIDATE_CACHE_PATH | ||
119 | 414 | fi | ||
120 | 415 | } | ||
121 | 416 | |||
122 | 387 | case "$1" in | 417 | case "$1" in |
123 | 388 | configure) | 418 | configure) |
124 | 389 | PREVIOUS_PKG_VER=$2 | 419 | PREVIOUS_PKG_VER=$2 |
125 | @@ -462,6 +492,8 @@ case "$1" in | |||
126 | 462 | if [ -f $MACHINE_TOKEN_FILE ] && [ ! -f $PUBLIC_MACHINE_TOKEN_FILE ]; then | 492 | if [ -f $MACHINE_TOKEN_FILE ] && [ ! -f $PUBLIC_MACHINE_TOKEN_FILE ]; then |
127 | 463 | create_public_machine_token_file | 493 | create_public_machine_token_file |
128 | 464 | fi | 494 | fi |
129 | 495 | migrate_ubuntu_pro_beta_banner $PREVIOUS_PKG_VER | ||
130 | 496 | cleanup_candidate_version_stamp_permissions | ||
131 | 465 | ;; | 497 | ;; |
132 | 466 | esac | 498 | esac |
133 | 467 | 499 | ||
134 | diff --git a/features/api_full_auto_attach.feature b/features/api_full_auto_attach.feature | |||
135 | index 240e06f..c65fca5 100644 | |||
136 | --- a/features/api_full_auto_attach.feature | |||
137 | +++ b/features/api_full_auto_attach.feature | |||
138 | @@ -27,7 +27,7 @@ Feature: Full Auto-Attach Endpoint | |||
139 | 27 | """ | 27 | """ |
140 | 28 | Then stdout matches regexp: | 28 | Then stdout matches regexp: |
141 | 29 | """ | 29 | """ |
143 | 30 | livepatch +yes +disabled +Canonical Livepatch service | 30 | livepatch +yes +(disabled|n/a) +Canonical Livepatch service |
144 | 31 | """ | 31 | """ |
145 | 32 | Examples: | 32 | Examples: |
146 | 33 | | release | | 33 | | release | |
147 | diff --git a/features/apt_messages.feature b/features/apt_messages.feature | |||
148 | index 27d67cb..b03524f 100644 | |||
149 | --- a/features/apt_messages.feature | |||
150 | +++ b/features/apt_messages.feature | |||
151 | @@ -9,7 +9,7 @@ Feature: APT Messages | |||
152 | 9 | When I run `apt-get upgrade -y` with sudo | 9 | When I run `apt-get upgrade -y` with sudo |
153 | 10 | 10 | ||
154 | 11 | When I run `apt-get install -y --allow-downgrades <standard-pkg>` with sudo | 11 | When I run `apt-get install -y --allow-downgrades <standard-pkg>` with sudo |
156 | 12 | When I run `apt-get upgrade -y` with sudo | 12 | When I run `apt upgrade -y` with sudo |
157 | 13 | Then stdout matches regexp: | 13 | Then stdout matches regexp: |
158 | 14 | """ | 14 | """ |
159 | 15 | 2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. | 15 | 2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
160 | @@ -18,7 +18,7 @@ Feature: APT Messages | |||
161 | 18 | """ | 18 | """ |
162 | 19 | 19 | ||
163 | 20 | When I run `apt-get install -y --allow-downgrades <infra-pkg>` with sudo | 20 | When I run `apt-get install -y --allow-downgrades <infra-pkg>` with sudo |
165 | 21 | When I run `apt-get upgrade -y` with sudo | 21 | When I run `apt upgrade -y` with sudo |
166 | 22 | Then stdout matches regexp: | 22 | Then stdout matches regexp: |
167 | 23 | """ | 23 | """ |
168 | 24 | 2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. | 24 | 2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
169 | @@ -27,7 +27,7 @@ Feature: APT Messages | |||
170 | 27 | """ | 27 | """ |
171 | 28 | 28 | ||
172 | 29 | When I run `apt-get install -y --allow-downgrades <apps-pkg>` with sudo | 29 | When I run `apt-get install -y --allow-downgrades <apps-pkg>` with sudo |
174 | 30 | When I run `apt-get upgrade -y` with sudo | 30 | When I run `apt upgrade -y` with sudo |
175 | 31 | Then stdout matches regexp: | 31 | Then stdout matches regexp: |
176 | 32 | """ | 32 | """ |
177 | 33 | 1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. | 33 | 1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
178 | @@ -37,7 +37,7 @@ Feature: APT Messages | |||
179 | 37 | 37 | ||
180 | 38 | When I run `apt-get install -y --allow-downgrades <standard-pkg>` with sudo | 38 | When I run `apt-get install -y --allow-downgrades <standard-pkg>` with sudo |
181 | 39 | When I run `apt-get install -y --allow-downgrades <infra-pkg>` with sudo | 39 | When I run `apt-get install -y --allow-downgrades <infra-pkg>` with sudo |
183 | 40 | When I run `apt-get upgrade -y` with sudo | 40 | When I run `apt upgrade -y` with sudo |
184 | 41 | Then stdout matches regexp: | 41 | Then stdout matches regexp: |
185 | 42 | """ | 42 | """ |
186 | 43 | 4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. | 43 | 4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
187 | @@ -47,7 +47,7 @@ Feature: APT Messages | |||
188 | 47 | 47 | ||
189 | 48 | When I run `apt-get install -y --allow-downgrades <standard-pkg>` with sudo | 48 | When I run `apt-get install -y --allow-downgrades <standard-pkg>` with sudo |
190 | 49 | When I run `apt-get install -y --allow-downgrades <apps-pkg>` with sudo | 49 | When I run `apt-get install -y --allow-downgrades <apps-pkg>` with sudo |
192 | 50 | When I run `apt-get upgrade -y` with sudo | 50 | When I run `apt upgrade -y` with sudo |
193 | 51 | Then stdout matches regexp: | 51 | Then stdout matches regexp: |
194 | 52 | """ | 52 | """ |
195 | 53 | 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. | 53 | 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
196 | @@ -57,7 +57,7 @@ Feature: APT Messages | |||
197 | 57 | 57 | ||
198 | 58 | When I run `apt-get install -y --allow-downgrades <infra-pkg>` with sudo | 58 | When I run `apt-get install -y --allow-downgrades <infra-pkg>` with sudo |
199 | 59 | When I run `apt-get install -y --allow-downgrades <apps-pkg>` with sudo | 59 | When I run `apt-get install -y --allow-downgrades <apps-pkg>` with sudo |
201 | 60 | When I run `apt-get upgrade -y` with sudo | 60 | When I run `apt upgrade -y` with sudo |
202 | 61 | Then stdout matches regexp: | 61 | Then stdout matches regexp: |
203 | 62 | """ | 62 | """ |
204 | 63 | 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. | 63 | 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
205 | @@ -68,7 +68,7 @@ Feature: APT Messages | |||
206 | 68 | When I run `apt-get install -y --allow-downgrades <standard-pkg>` with sudo | 68 | When I run `apt-get install -y --allow-downgrades <standard-pkg>` with sudo |
207 | 69 | When I run `apt-get install -y --allow-downgrades <infra-pkg>` with sudo | 69 | When I run `apt-get install -y --allow-downgrades <infra-pkg>` with sudo |
208 | 70 | When I run `apt-get install -y --allow-downgrades <apps-pkg>` with sudo | 70 | When I run `apt-get install -y --allow-downgrades <apps-pkg>` with sudo |
210 | 71 | When I run `apt-get upgrade -y` with sudo | 71 | When I run `apt upgrade -y` with sudo |
211 | 72 | Then stdout matches regexp: | 72 | Then stdout matches regexp: |
212 | 73 | """ | 73 | """ |
213 | 74 | 5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. | 74 | 5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
214 | @@ -76,7 +76,7 @@ Feature: APT Messages | |||
215 | 76 | 76 | ||
216 | 77 | """ | 77 | """ |
217 | 78 | 78 | ||
219 | 79 | When I run `apt-get upgrade -y` with sudo | 79 | When I run `apt upgrade -y` with sudo |
220 | 80 | Then stdout matches regexp: | 80 | Then stdout matches regexp: |
221 | 81 | """ | 81 | """ |
222 | 82 | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. | 82 | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
223 | @@ -106,37 +106,52 @@ Feature: APT Messages | |||
224 | 106 | When I run `apt-get -y upgrade` with sudo | 106 | When I run `apt-get -y upgrade` with sudo |
225 | 107 | When I run `apt-get -y autoremove` with sudo | 107 | When I run `apt-get -y autoremove` with sudo |
226 | 108 | When I run `pro refresh messages` with sudo | 108 | When I run `pro refresh messages` with sudo |
228 | 109 | When I run `apt-get upgrade` with sudo | 109 | When I run `apt upgrade` with sudo |
229 | 110 | Then stdout matches regexp: | 110 | Then stdout matches regexp: |
230 | 111 | """ | 111 | """ |
231 | 112 | Reading package lists... | 112 | Reading package lists... |
232 | 113 | Building dependency tree... | 113 | Building dependency tree... |
233 | 114 | Reading state information... | 114 | Reading state information... |
234 | 115 | Calculating upgrade... | 115 | Calculating upgrade... |
235 | 116 | # | ||
236 | 117 | # News about significant security updates, features and services will | ||
237 | 118 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
238 | 119 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
239 | 120 | # | ||
240 | 116 | The following security updates require Ubuntu Pro with 'esm-infra' enabled: | 121 | The following security updates require Ubuntu Pro with 'esm-infra' enabled: |
241 | 117 | .* | 122 | .* |
242 | 118 | Learn more about Ubuntu Pro for 16\.04 at https:\/\/ubuntu\.com\/16-04 | 123 | Learn more about Ubuntu Pro for 16\.04 at https:\/\/ubuntu\.com\/16-04 |
243 | 119 | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded\. | 124 | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded\. |
244 | 120 | """ | 125 | """ |
245 | 121 | When I attach `contract_token` with sudo | 126 | When I attach `contract_token` with sudo |
247 | 122 | When I run `apt-get upgrade --dry-run` with sudo | 127 | When I run `apt upgrade --dry-run` with sudo |
248 | 123 | Then stdout matches regexp: | 128 | Then stdout matches regexp: |
249 | 124 | """ | 129 | """ |
250 | 125 | Reading package lists... | 130 | Reading package lists... |
251 | 126 | Building dependency tree... | 131 | Building dependency tree... |
252 | 127 | Reading state information... | 132 | Reading state information... |
253 | 128 | Calculating upgrade... | 133 | Calculating upgrade... |
254 | 134 | # | ||
255 | 135 | # News about significant security updates, features and services will | ||
256 | 136 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
257 | 137 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
258 | 138 | # | ||
259 | 129 | The following packages will be upgraded: | 139 | The following packages will be upgraded: |
260 | 130 | """ | 140 | """ |
261 | 131 | When I update contract to use `effectiveTo` as `days=+2` | 141 | When I update contract to use `effectiveTo` as `days=+2` |
262 | 132 | When I run `pro refresh messages` with sudo | 142 | When I run `pro refresh messages` with sudo |
264 | 133 | When I run `apt-get upgrade --dry-run` with sudo | 143 | When I run `apt upgrade --dry-run` with sudo |
265 | 134 | Then stdout matches regexp: | 144 | Then stdout matches regexp: |
266 | 135 | """ | 145 | """ |
267 | 136 | Reading package lists... | 146 | Reading package lists... |
268 | 137 | Building dependency tree... | 147 | Building dependency tree... |
269 | 138 | Reading state information... | 148 | Reading state information... |
270 | 139 | Calculating upgrade... | 149 | Calculating upgrade... |
271 | 150 | # | ||
272 | 151 | # News about significant security updates, features and services will | ||
273 | 152 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
274 | 153 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
275 | 154 | # | ||
276 | 140 | 155 | ||
277 | 141 | CAUTION: Your Ubuntu Pro subscription will expire in 2 days. | 156 | CAUTION: Your Ubuntu Pro subscription will expire in 2 days. |
278 | 142 | Renew your subscription at https:\/\/ubuntu.com\/pro to ensure continued security | 157 | Renew your subscription at https:\/\/ubuntu.com\/pro to ensure continued security |
279 | @@ -146,13 +161,18 @@ Feature: APT Messages | |||
280 | 146 | """ | 161 | """ |
281 | 147 | When I update contract to use `effectiveTo` as `days=-3` | 162 | When I update contract to use `effectiveTo` as `days=-3` |
282 | 148 | When I run `pro refresh messages` with sudo | 163 | When I run `pro refresh messages` with sudo |
284 | 149 | When I run `apt-get upgrade --dry-run` with sudo | 164 | When I run `apt upgrade --dry-run` with sudo |
285 | 150 | Then stdout matches regexp: | 165 | Then stdout matches regexp: |
286 | 151 | """ | 166 | """ |
287 | 152 | Reading package lists... | 167 | Reading package lists... |
288 | 153 | Building dependency tree... | 168 | Building dependency tree... |
289 | 154 | Reading state information... | 169 | Reading state information... |
290 | 155 | Calculating upgrade... | 170 | Calculating upgrade... |
291 | 171 | # | ||
292 | 172 | # News about significant security updates, features and services will | ||
293 | 173 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
294 | 174 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
295 | 175 | # | ||
296 | 156 | 176 | ||
297 | 157 | CAUTION: Your Ubuntu Pro subscription expired on \d+ \w+ \d+. | 177 | CAUTION: Your Ubuntu Pro subscription expired on \d+ \w+ \d+. |
298 | 158 | Renew your subscription at https:\/\/ubuntu.com\/pro to ensure continued security | 178 | Renew your subscription at https:\/\/ubuntu.com\/pro to ensure continued security |
299 | @@ -163,13 +183,18 @@ Feature: APT Messages | |||
300 | 163 | """ | 183 | """ |
301 | 164 | When I update contract to use `effectiveTo` as `days=-20` | 184 | When I update contract to use `effectiveTo` as `days=-20` |
302 | 165 | When I run `pro refresh messages` with sudo | 185 | When I run `pro refresh messages` with sudo |
304 | 166 | When I run `apt-get upgrade --dry-run` with sudo | 186 | When I run `apt upgrade --dry-run` with sudo |
305 | 167 | Then stdout matches regexp: | 187 | Then stdout matches regexp: |
306 | 168 | """ | 188 | """ |
307 | 169 | Reading package lists... | 189 | Reading package lists... |
308 | 170 | Building dependency tree... | 190 | Building dependency tree... |
309 | 171 | Reading state information... | 191 | Reading state information... |
310 | 172 | Calculating upgrade... | 192 | Calculating upgrade... |
311 | 193 | # | ||
312 | 194 | # News about significant security updates, features and services will | ||
313 | 195 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
314 | 196 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
315 | 197 | # | ||
316 | 173 | 198 | ||
317 | 174 | \*Your Ubuntu Pro subscription has EXPIRED\* | 199 | \*Your Ubuntu Pro subscription has EXPIRED\* |
318 | 175 | The following security updates require Ubuntu Pro with 'esm-infra' enabled: | 200 | The following security updates require Ubuntu Pro with 'esm-infra' enabled: |
319 | @@ -179,13 +204,18 @@ Feature: APT Messages | |||
320 | 179 | The following packages will be upgraded: | 204 | The following packages will be upgraded: |
321 | 180 | """ | 205 | """ |
322 | 181 | When I run `apt-get upgrade -y` with sudo | 206 | When I run `apt-get upgrade -y` with sudo |
324 | 182 | When I run `apt-get upgrade` with sudo | 207 | When I run `apt upgrade` with sudo |
325 | 183 | Then stdout matches regexp: | 208 | Then stdout matches regexp: |
326 | 184 | """ | 209 | """ |
327 | 185 | Reading package lists... | 210 | Reading package lists... |
328 | 186 | Building dependency tree... | 211 | Building dependency tree... |
329 | 187 | Reading state information... | 212 | Reading state information... |
330 | 188 | Calculating upgrade... | 213 | Calculating upgrade... |
331 | 214 | # | ||
332 | 215 | # News about significant security updates, features and services will | ||
333 | 216 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
334 | 217 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
335 | 218 | # | ||
336 | 189 | 219 | ||
337 | 190 | \*Your Ubuntu Pro subscription has EXPIRED\* | 220 | \*Your Ubuntu Pro subscription has EXPIRED\* |
338 | 191 | Renew your service at https:\/\/ubuntu.com\/pro | 221 | Renew your service at https:\/\/ubuntu.com\/pro |
339 | @@ -194,13 +224,18 @@ Feature: APT Messages | |||
340 | 194 | """ | 224 | """ |
341 | 195 | When I run `pro detach --assume-yes` with sudo | 225 | When I run `pro detach --assume-yes` with sudo |
342 | 196 | When I run `pro refresh messages` with sudo | 226 | When I run `pro refresh messages` with sudo |
344 | 197 | When I run `apt-get upgrade` with sudo | 227 | When I run `apt upgrade` with sudo |
345 | 198 | Then stdout matches regexp: | 228 | Then stdout matches regexp: |
346 | 199 | """ | 229 | """ |
347 | 200 | Reading package lists... | 230 | Reading package lists... |
348 | 201 | Building dependency tree... | 231 | Building dependency tree... |
349 | 202 | Reading state information... | 232 | Reading state information... |
350 | 203 | Calculating upgrade... | 233 | Calculating upgrade... |
351 | 234 | # | ||
352 | 235 | # News about significant security updates, features and services will | ||
353 | 236 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
354 | 237 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
355 | 238 | # | ||
356 | 204 | Receive additional future security updates with Ubuntu Pro. | 239 | Receive additional future security updates with Ubuntu Pro. |
357 | 205 | Learn more about Ubuntu Pro for 16\.04 at https:\/\/ubuntu\.com\/16-04 | 240 | Learn more about Ubuntu Pro for 16\.04 at https:\/\/ubuntu\.com\/16-04 |
358 | 206 | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded\. | 241 | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded\. |
359 | @@ -218,31 +253,48 @@ Feature: APT Messages | |||
360 | 218 | When I run `apt-get -y autoremove` with sudo | 253 | When I run `apt-get -y autoremove` with sudo |
361 | 219 | When I run `apt-get install hello` with sudo | 254 | When I run `apt-get install hello` with sudo |
362 | 220 | When I run `pro refresh messages` with sudo | 255 | When I run `pro refresh messages` with sudo |
364 | 221 | When I run `apt-get upgrade` with sudo | 256 | When I run `apt upgrade` with sudo |
365 | 222 | Then I will see the following on stdout: | 257 | Then I will see the following on stdout: |
366 | 223 | """ | 258 | """ |
367 | 224 | Reading package lists... | 259 | Reading package lists... |
368 | 225 | Building dependency tree... | 260 | Building dependency tree... |
369 | 226 | Reading state information... | 261 | Reading state information... |
370 | 227 | Calculating upgrade... | 262 | Calculating upgrade... |
373 | 228 | Try Ubuntu Pro beta with a free personal subscription on up to 5 machines. | 263 | # |
374 | 229 | Learn more at https://ubuntu.com/pro | 264 | # News about significant security updates, features and services will |
375 | 265 | # appear here to raise awareness and perhaps tease /r/Linux ;) | ||
376 | 266 | # Use 'pro config set apt_news=false' to hide this and future APT news. | ||
377 | 267 | # | ||
378 | 230 | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. | 268 | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. |
379 | 231 | """ | 269 | """ |
380 | 270 | When I run `apt-get upgrade` with sudo | ||
381 | 271 | Then stdout does not match regexp: | ||
382 | 272 | """ | ||
383 | 273 | # | ||
384 | 274 | # News about significant security updates, features and services will | ||
385 | 275 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
386 | 276 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
387 | 277 | # | ||
388 | 278 | """ | ||
389 | 232 | When I attach `contract_token` with sudo | 279 | When I attach `contract_token` with sudo |
391 | 233 | When I run `apt-get upgrade --dry-run` with sudo | 280 | When I run `apt upgrade --dry-run` with sudo |
392 | 234 | Then stdout matches regexp: | 281 | Then stdout matches regexp: |
393 | 235 | """ | 282 | """ |
394 | 236 | Reading package lists... | 283 | Reading package lists... |
395 | 237 | Building dependency tree... | 284 | Building dependency tree... |
396 | 238 | Reading state information... | 285 | Reading state information... |
397 | 239 | Calculating upgrade... | 286 | Calculating upgrade... |
398 | 287 | # | ||
399 | 288 | # News about significant security updates, features and services will | ||
400 | 289 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
401 | 290 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
402 | 291 | # | ||
403 | 240 | The following packages will be upgraded: | 292 | The following packages will be upgraded: |
404 | 241 | hello | 293 | hello |
405 | 242 | """ | 294 | """ |
406 | 243 | # When I update contract to use `effectiveTo` as `days=-20` | 295 | # When I update contract to use `effectiveTo` as `days=-20` |
407 | 244 | # When I run `pro refresh messages` with sudo | 296 | # When I run `pro refresh messages` with sudo |
409 | 245 | # When I run `apt-get upgrade --dry-run` with sudo | 297 | # When I run `apt upgrade --dry-run` with sudo |
410 | 246 | # Then stdout matches regexp: | 298 | # Then stdout matches regexp: |
411 | 247 | # """ | 299 | # """ |
412 | 248 | # Reading package lists... | 300 | # Reading package lists... |
413 | @@ -260,17 +312,30 @@ Feature: APT Messages | |||
414 | 260 | When I run `apt-get upgrade -y` with sudo | 312 | When I run `apt-get upgrade -y` with sudo |
415 | 261 | When I run `pro detach --assume-yes` with sudo | 313 | When I run `pro detach --assume-yes` with sudo |
416 | 262 | When I run `pro refresh messages` with sudo | 314 | When I run `pro refresh messages` with sudo |
418 | 263 | When I run `apt-get upgrade` with sudo | 315 | When I run `apt upgrade` with sudo |
419 | 264 | Then stdout matches regexp: | 316 | Then stdout matches regexp: |
420 | 265 | """ | 317 | """ |
421 | 266 | Reading package lists... | 318 | Reading package lists... |
422 | 267 | Building dependency tree... | 319 | Building dependency tree... |
423 | 268 | Reading state information... | 320 | Reading state information... |
424 | 269 | Calculating upgrade... | 321 | Calculating upgrade... |
427 | 270 | Try Ubuntu Pro beta with a free personal subscription on up to 5 machines. | 322 | # |
428 | 271 | Learn more at https:\/\/ubuntu.com\/pro | 323 | # News about significant security updates, features and services will |
429 | 324 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
430 | 325 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
431 | 326 | # | ||
432 | 272 | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded\. | 327 | 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded\. |
433 | 273 | """ | 328 | """ |
434 | 329 | When I run `pro config set apt_news=false` with sudo | ||
435 | 330 | And I run `apt upgrade` with sudo | ||
436 | 331 | Then stdout does not match regexp: | ||
437 | 332 | """ | ||
438 | 333 | # | ||
439 | 334 | # News about significant security updates, features and services will | ||
440 | 335 | # appear here to raise awareness and perhaps tease /r/Linux ;\) | ||
441 | 336 | # Use 'pro config set apt_news=false' to hide this and future APT news\. | ||
442 | 337 | # | ||
443 | 338 | """ | ||
444 | 274 | Examples: ubuntu release | 339 | Examples: ubuntu release |
445 | 275 | | release | | 340 | | release | |
446 | 276 | | focal | | 341 | | focal | |
447 | diff --git a/features/cloud_pro_clone.feature b/features/cloud_pro_clone.feature | |||
448 | index f08bff0..48aa17a 100644 | |||
449 | --- a/features/cloud_pro_clone.feature | |||
450 | +++ b/features/cloud_pro_clone.feature | |||
451 | @@ -2,7 +2,6 @@ Feature: Creating golden images based on Cloud Ubuntu Pro instances | |||
452 | 2 | 2 | ||
453 | 3 | @series.lts | 3 | @series.lts |
454 | 4 | @uses.config.machine_type.aws.pro | 4 | @uses.config.machine_type.aws.pro |
455 | 5 | @uses.config.machine_type.azure.pro | ||
456 | 6 | @uses.config.machine_type.gcp.pro | 5 | @uses.config.machine_type.gcp.pro |
457 | 7 | Scenario Outline: Create a Pro fips-updates image and launch | 6 | Scenario Outline: Create a Pro fips-updates image and launch |
458 | 8 | Given a `<release>` machine with ubuntu-advantage-tools installed | 7 | Given a `<release>` machine with ubuntu-advantage-tools installed |
459 | diff --git a/features/daemon.feature b/features/daemon.feature | |||
460 | index 593c86d..0b33c37 100644 | |||
461 | --- a/features/daemon.feature | |||
462 | +++ b/features/daemon.feature | |||
463 | @@ -104,9 +104,10 @@ Feature: Pro Upgrade Daemon only runs in environments where necessary | |||
464 | 104 | """ | 104 | """ |
465 | 105 | Active: active \(running\) | 105 | Active: active \(running\) |
466 | 106 | """ | 106 | """ |
468 | 107 | Then on `xenial`, systemd status output says memory usage is less than `14` MB | 107 | # TODO find out what caused memory to go up, try to lower it again |
469 | 108 | Then on `xenial`, systemd status output says memory usage is less than `15` MB | ||
470 | 108 | Then on `bionic`, systemd status output says memory usage is less than `13` MB | 109 | Then on `bionic`, systemd status output says memory usage is less than `13` MB |
472 | 109 | Then on `focal`, systemd status output says memory usage is less than `11` MB | 110 | Then on `focal`, systemd status output says memory usage is less than `12` MB |
473 | 110 | Then on `jammy`, systemd status output says memory usage is less than `12` MB | 111 | Then on `jammy`, systemd status output says memory usage is less than `12` MB |
474 | 111 | 112 | ||
475 | 112 | When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo | 113 | When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo |
476 | diff --git a/features/docker.feature b/features/docker.feature | |||
477 | index e4ac590..2e82266 100644 | |||
478 | --- a/features/docker.feature | |||
479 | +++ b/features/docker.feature | |||
480 | @@ -19,7 +19,9 @@ Feature: Build docker images with pro services | |||
481 | 19 | apt-get update \ | 19 | apt-get update \ |
482 | 20 | && apt-get install --no-install-recommends -y ubuntu-advantage-tools ca-certificates \ | 20 | && apt-get install --no-install-recommends -y ubuntu-advantage-tools ca-certificates \ |
483 | 21 | 21 | ||
485 | 22 | && dpkg -i /ua.deb \ | 22 | && ((dpkg -i /ua.deb || true)) \ |
486 | 23 | |||
487 | 24 | && apt-get install -f \ | ||
488 | 23 | 25 | ||
489 | 24 | && pro attach --attach-config /run/secrets/ua-attach-config \ | 26 | && pro attach --attach-config /run/secrets/ua-attach-config \ |
490 | 25 | 27 | ||
491 | diff --git a/features/environment.py b/features/environment.py | |||
492 | index 39013d0..bfe0042 100644 | |||
493 | --- a/features/environment.py | |||
494 | +++ b/features/environment.py | |||
495 | @@ -23,10 +23,6 @@ DEFAULT_UA_PPA_KEYID = "6E34E7116C0BC933" | |||
496 | 23 | 23 | ||
497 | 24 | USERDATA_BLOCK_AUTO_ATTACH_IMG = """\ | 24 | USERDATA_BLOCK_AUTO_ATTACH_IMG = """\ |
498 | 25 | #cloud-config | 25 | #cloud-config |
499 | 26 | [bootcmd, once]: | ||
500 | 27 | - cp /usr/bin/ua /usr/bin/ua.orig | ||
501 | 28 | - 'echo "#!/bin/sh\ndate >> /root/ua-calls\n" > /usr/bin/ua' | ||
502 | 29 | - chmod 755 /usr/bin/ua | ||
503 | 30 | """ | 26 | """ |
504 | 31 | 27 | ||
505 | 32 | # we can't use write_files because it will clash with the | 28 | # we can't use write_files because it will clash with the |
506 | @@ -40,8 +36,10 @@ runcmd: | |||
507 | 40 | USERDATA_RUNCMD_ENABLE_PROPOSED = """ | 36 | USERDATA_RUNCMD_ENABLE_PROPOSED = """ |
508 | 41 | runcmd: | 37 | runcmd: |
509 | 42 | - printf \"deb http://archive.ubuntu.com/ubuntu/ {series}-proposed main\" > /etc/apt/sources.list.d/uaclient-proposed.list | 38 | - printf \"deb http://archive.ubuntu.com/ubuntu/ {series}-proposed main\" > /etc/apt/sources.list.d/uaclient-proposed.list |
510 | 39 | - printf \"deb http://archive.ubuntu.com/ubuntu/ {series}-proposed universe\" > /etc/apt/sources.list.d/uaclient-proposed-universe.list | ||
511 | 43 | - "printf \\"Package: *\\nPin: release a={series}-proposed\\nPin-Priority: 400\\n\\" > /etc/apt/preferences.d/lower-proposed" | 40 | - "printf \\"Package: *\\nPin: release a={series}-proposed\\nPin-Priority: 400\\n\\" > /etc/apt/preferences.d/lower-proposed" |
512 | 44 | - "printf \\"Package: ubuntu-advantage-tools\\nPin: release a={series}-proposed\\nPin-Priority: 1001\\n\\" > /etc/apt/preferences.d/uaclient-proposed" | 41 | - "printf \\"Package: ubuntu-advantage-tools\\nPin: release a={series}-proposed\\nPin-Priority: 1001\\n\\" > /etc/apt/preferences.d/uaclient-proposed" |
513 | 42 | - "printf \\"Package: ubuntu-advantage-pro\\nPin: release a={series}-proposed\\nPin-Priority: 1001\\n\\" > /etc/apt/preferences.d/uaclientpro-proposed" | ||
514 | 45 | """ # noqa: E501 | 43 | """ # noqa: E501 |
515 | 46 | 44 | ||
516 | 47 | USERDATA_APT_SOURCE_PPA = """\ | 45 | USERDATA_APT_SOURCE_PPA = """\ |
517 | @@ -333,6 +331,8 @@ class UAClientBehaveConfig: | |||
518 | 333 | def before_all(context: Context) -> None: | 331 | def before_all(context: Context) -> None: |
519 | 334 | """behave will invoke this before anything else happens.""" | 332 | """behave will invoke this before anything else happens.""" |
520 | 335 | context.config.setup_logging() | 333 | context.config.setup_logging() |
521 | 334 | logging.getLogger("botocore").setLevel(logging.INFO) | ||
522 | 335 | logging.getLogger("boto3").setLevel(logging.INFO) | ||
523 | 336 | userdata = context.config.userdata | 336 | userdata = context.config.userdata |
524 | 337 | if userdata: | 337 | if userdata: |
525 | 338 | logging.debug("Userdata key / value pairs:") | 338 | logging.debug("Userdata key / value pairs:") |
526 | diff --git a/features/ubuntu_pro.feature b/features/ubuntu_pro.feature | |||
527 | index f23dcde..c373a95 100644 | |||
528 | --- a/features/ubuntu_pro.feature | |||
529 | +++ b/features/ubuntu_pro.feature | |||
530 | @@ -23,6 +23,7 @@ Feature: Command behaviour when auto-attached in an ubuntu PRO image | |||
531 | 23 | """ | 23 | """ |
532 | 24 | And I verify `/var/log/squid/access.log` is empty on `proxy` machine | 24 | And I verify `/var/log/squid/access.log` is empty on `proxy` machine |
533 | 25 | When I run `pro auto-attach` with sudo | 25 | When I run `pro auto-attach` with sudo |
534 | 26 | When I run `pro status --all` with sudo | ||
535 | 26 | Then stdout matches regexp: | 27 | Then stdout matches regexp: |
536 | 27 | """ | 28 | """ |
537 | 28 | SERVICE +ENTITLED STATUS DESCRIPTION | 29 | SERVICE +ENTITLED STATUS DESCRIPTION |
538 | @@ -94,6 +95,7 @@ Feature: Command behaviour when auto-attached in an ubuntu PRO image | |||
539 | 94 | """ | 95 | """ |
540 | 95 | And I verify `/var/log/squid/access.log` is empty on `proxy` machine | 96 | And I verify `/var/log/squid/access.log` is empty on `proxy` machine |
541 | 96 | When I run `pro auto-attach` with sudo | 97 | When I run `pro auto-attach` with sudo |
542 | 98 | When I run `pro status --all` with sudo | ||
543 | 97 | Then stdout matches regexp: | 99 | Then stdout matches regexp: |
544 | 98 | """ | 100 | """ |
545 | 99 | SERVICE +ENTITLED STATUS DESCRIPTION | 101 | SERVICE +ENTITLED STATUS DESCRIPTION |
546 | @@ -165,6 +167,7 @@ Feature: Command behaviour when auto-attached in an ubuntu PRO image | |||
547 | 165 | """ | 167 | """ |
548 | 166 | And I verify `/var/log/squid/access.log` is empty on `proxy` machine | 168 | And I verify `/var/log/squid/access.log` is empty on `proxy` machine |
549 | 167 | When I run `pro auto-attach` with sudo | 169 | When I run `pro auto-attach` with sudo |
550 | 170 | When I run `pro status --all` with sudo | ||
551 | 168 | Then stdout matches regexp: | 171 | Then stdout matches regexp: |
552 | 169 | """ | 172 | """ |
553 | 170 | SERVICE +ENTITLED STATUS DESCRIPTION | 173 | SERVICE +ENTITLED STATUS DESCRIPTION |
554 | diff --git a/features/unattached_commands.feature b/features/unattached_commands.feature | |||
555 | index 5f27952..d358c29 100644 | |||
556 | --- a/features/unattached_commands.feature | |||
557 | +++ b/features/unattached_commands.feature | |||
558 | @@ -231,19 +231,18 @@ Feature: Command behaviour when unattached | |||
559 | 231 | Given a `<release>` machine with ubuntu-advantage-tools installed | 231 | Given a `<release>` machine with ubuntu-advantage-tools installed |
560 | 232 | # Make sure we have a fresh, just rebooted, environment | 232 | # Make sure we have a fresh, just rebooted, environment |
561 | 233 | When I reboot the machine | 233 | When I reboot the machine |
564 | 234 | Then I verify that no files exist matching `/tmp/ubuntu-advantage/candidate-version` | 234 | Then I verify that no files exist matching `/run/ubuntu-advantage/candidate-version` |
565 | 235 | When I run `pro status` as non-root | 235 | When I run `pro status` with sudo |
566 | 236 | Then I will see the following on stderr | 236 | Then I will see the following on stderr |
567 | 237 | """ | 237 | """ |
568 | 238 | """ | 238 | """ |
570 | 239 | And I verify that files exist matching `/tmp/ubuntu-advantage/candidate-version` | 239 | And I verify that files exist matching `/run/ubuntu-advantage/candidate-version` |
571 | 240 | # We forge a candidate to see results | 240 | # We forge a candidate to see results |
574 | 241 | When I delete the file `/tmp/ubuntu-advantage/candidate-version` | 241 | When I delete the file `/run/ubuntu-advantage/candidate-version` |
575 | 242 | And I create the file `/tmp/ubuntu-advantage/candidate-version` with the following | 242 | And I create the file `/run/ubuntu-advantage/candidate-version` with the following |
576 | 243 | """ | 243 | """ |
577 | 244 | 99.9.9 | 244 | 99.9.9 |
578 | 245 | """ | 245 | """ |
579 | 246 | And I run `chmod 777 /tmp/ubuntu-advantage/candidate-version` with sudo | ||
580 | 247 | And I run `pro status` as non-root | 246 | And I run `pro status` as non-root |
581 | 248 | Then stderr matches regexp: | 247 | Then stderr matches regexp: |
582 | 249 | """ | 248 | """ |
583 | diff --git a/integration-requirements.txt b/integration-requirements.txt | |||
584 | index 9eaf14f..de2698d 100644 | |||
585 | --- a/integration-requirements.txt | |||
586 | +++ b/integration-requirements.txt | |||
587 | @@ -2,7 +2,7 @@ | |||
588 | 2 | behave | 2 | behave |
589 | 3 | jsonschema | 3 | jsonschema |
590 | 4 | PyHamcrest | 4 | PyHamcrest |
592 | 5 | pycloudlib @ git+https://github.com/canonical/pycloudlib.git@25cca01b24d111e00e91a86eb1021b88592e069e | 5 | pycloudlib @ git+https://github.com/canonical/pycloudlib.git@e7c4a42eb98a914b084b253c3f96c960de42e8fa |
593 | 6 | toml==0.10 | 6 | toml==0.10 |
594 | 7 | 7 | ||
595 | 8 | 8 | ||
596 | diff --git a/uaclient/actions.py b/uaclient/actions.py | |||
597 | index 9b1af00..3f602e8 100644 | |||
598 | --- a/uaclient/actions.py | |||
599 | +++ b/uaclient/actions.py | |||
600 | @@ -160,6 +160,23 @@ def _write_command_output_to_file( | |||
601 | 160 | system.write_file(filename, out) | 160 | system.write_file(filename, out) |
602 | 161 | 161 | ||
603 | 162 | 162 | ||
604 | 163 | def _get_state_files(cfg: config.UAConfig): | ||
605 | 164 | # include cfg log files here because they could be set to non default | ||
606 | 165 | return [ | ||
607 | 166 | cfg.cfg_path or DEFAULT_CONFIG_FILE, | ||
608 | 167 | cfg.log_file, | ||
609 | 168 | cfg.timer_log_file, | ||
610 | 169 | cfg.daemon_log_file, | ||
611 | 170 | cfg.data_path("jobs-status"), | ||
612 | 171 | CLOUD_BUILD_INFO, | ||
613 | 172 | *( | ||
614 | 173 | entitlement.repo_list_file_tmpl.format(name=entitlement.name) | ||
615 | 174 | for entitlement in entitlements.ENTITLEMENT_CLASSES | ||
616 | 175 | if issubclass(entitlement, entitlements.repo.RepoEntitlement) | ||
617 | 176 | ), | ||
618 | 177 | ] | ||
619 | 178 | |||
620 | 179 | |||
621 | 163 | def collect_logs(cfg: config.UAConfig, output_dir: str): | 180 | def collect_logs(cfg: config.UAConfig, output_dir: str): |
622 | 164 | """ | 181 | """ |
623 | 165 | Write all relevant Ubuntu Pro logs to the specified directory | 182 | Write all relevant Ubuntu Pro logs to the specified directory |
624 | @@ -199,28 +216,19 @@ def collect_logs(cfg: config.UAConfig, output_dir: str): | |||
625 | 199 | return_codes=[0, 3], | 216 | return_codes=[0, 3], |
626 | 200 | ) | 217 | ) |
627 | 201 | 218 | ||
642 | 202 | # include cfg log files here because they could be set to non default | 219 | state_files = _get_state_files(cfg) |
629 | 203 | state_files = [ | ||
630 | 204 | cfg.cfg_path or DEFAULT_CONFIG_FILE, | ||
631 | 205 | cfg.log_file, | ||
632 | 206 | cfg.timer_log_file, | ||
633 | 207 | cfg.daemon_log_file, | ||
634 | 208 | cfg.data_path("jobs-status"), | ||
635 | 209 | CLOUD_BUILD_INFO, | ||
636 | 210 | *( | ||
637 | 211 | entitlement.repo_list_file_tmpl.format(name=entitlement.name) | ||
638 | 212 | for entitlement in entitlements.ENTITLEMENT_CLASSES | ||
639 | 213 | if issubclass(entitlement, entitlements.repo.RepoEntitlement) | ||
640 | 214 | ), | ||
641 | 215 | ] | ||
643 | 216 | 220 | ||
644 | 217 | # also get default logrotated log files | 221 | # also get default logrotated log files |
645 | 218 | for f in state_files + glob.glob(DEFAULT_LOG_PREFIX + "*"): | 222 | for f in state_files + glob.glob(DEFAULT_LOG_PREFIX + "*"): |
646 | 219 | if os.path.isfile(f): | 223 | if os.path.isfile(f): |
647 | 220 | try: | 224 | try: |
648 | 221 | content = system.load_file(f) | 225 | content = system.load_file(f) |
651 | 222 | except PermissionError as e: | 226 | except Exception as e: |
652 | 223 | logging.warning(e) | 227 | # If we fail to load that file for any reason we will |
653 | 228 | # not break the command, we will instead warn the user | ||
654 | 229 | # about the issue and try to process the other files | ||
655 | 230 | logging.warning("Failed to load file: %s\n%s", f, str(e)) | ||
656 | 231 | continue | ||
657 | 224 | content = util.redact_sensitive_logs(content) | 232 | content = util.redact_sensitive_logs(content) |
658 | 225 | if os.getuid() == 0: | 233 | if os.getuid() == 0: |
659 | 226 | # if root, overwrite the original with redacted content | 234 | # if root, overwrite the original with redacted content |
660 | diff --git a/uaclient/cli.py b/uaclient/cli.py | |||
661 | index 3473414..55f8bec 100644 | |||
662 | --- a/uaclient/cli.py | |||
663 | +++ b/uaclient/cli.py | |||
664 | @@ -49,7 +49,9 @@ from uaclient.entitlements.entitlement_status import ( | |||
665 | 49 | CanEnableFailureReason, | 49 | CanEnableFailureReason, |
666 | 50 | ) | 50 | ) |
667 | 51 | from uaclient.jobs.update_messaging import ( | 51 | from uaclient.jobs.update_messaging import ( |
668 | 52 | clear_apt_news_flag, | ||
669 | 52 | refresh_motd, | 53 | refresh_motd, |
670 | 54 | set_apt_news_flag, | ||
671 | 53 | update_apt_and_motd_messages, | 55 | update_apt_and_motd_messages, |
672 | 54 | ) | 56 | ) |
673 | 55 | 57 | ||
674 | @@ -1022,6 +1024,13 @@ def action_config_set(args, *, cfg, **kwargs): | |||
675 | 1022 | "<value> for interval must be a positive integer." | 1024 | "<value> for interval must be a positive integer." |
676 | 1023 | ).format(set_key, set_value) | 1025 | ).format(set_key, set_value) |
677 | 1024 | ) | 1026 | ) |
678 | 1027 | elif set_key == "apt_news": | ||
679 | 1028 | set_value = set_value.lower() == "true" | ||
680 | 1029 | if set_value: | ||
681 | 1030 | set_apt_news_flag(cfg) | ||
682 | 1031 | else: | ||
683 | 1032 | clear_apt_news_flag(cfg) | ||
684 | 1033 | |||
685 | 1025 | setattr(cfg, set_key, set_value) | 1034 | setattr(cfg, set_key, set_value) |
686 | 1026 | 1035 | ||
687 | 1027 | 1036 | ||
688 | diff --git a/uaclient/config.py b/uaclient/config.py | |||
689 | index 2b43d55..bb7bb06 100644 | |||
690 | --- a/uaclient/config.py | |||
691 | +++ b/uaclient/config.py | |||
692 | @@ -49,6 +49,7 @@ UA_CONFIGURABLE_KEYS = ( | |||
693 | 49 | "update_messaging_timer", | 49 | "update_messaging_timer", |
694 | 50 | "update_status_timer", | 50 | "update_status_timer", |
695 | 51 | "metering_timer", | 51 | "metering_timer", |
696 | 52 | "apt_news", | ||
697 | 52 | ) | 53 | ) |
698 | 53 | 54 | ||
699 | 54 | # Basic schema validation top-level keys for parse_config handling | 55 | # Basic schema validation top-level keys for parse_config handling |
700 | @@ -304,6 +305,17 @@ class UAConfig: | |||
701 | 304 | self.cfg["ua_config"]["polling_error_retry_delay"] = value | 305 | self.cfg["ua_config"]["polling_error_retry_delay"] = value |
702 | 305 | self.write_cfg() | 306 | self.write_cfg() |
703 | 306 | 307 | ||
704 | 308 | @property | ||
705 | 309 | def apt_news(self) -> bool: | ||
706 | 310 | return self.cfg.get("ua_config", {}).get("apt_news", True) | ||
707 | 311 | |||
708 | 312 | @apt_news.setter | ||
709 | 313 | def apt_news(self, value: bool): | ||
710 | 314 | if "ua_config" not in self.cfg: | ||
711 | 315 | self.cfg["ua_config"] = {} | ||
712 | 316 | self.cfg["ua_config"]["apt_news"] = value | ||
713 | 317 | self.write_cfg() | ||
714 | 318 | |||
715 | 307 | def check_lock_info(self) -> Tuple[int, str]: | 319 | def check_lock_info(self) -> Tuple[int, str]: |
716 | 308 | """Return lock info if config lock file is present the lock is active. | 320 | """Return lock info if config lock file is present the lock is active. |
717 | 309 | 321 | ||
718 | diff --git a/uaclient/defaults.py b/uaclient/defaults.py | |||
719 | index a2fa11f..7ffb140 100644 | |||
720 | --- a/uaclient/defaults.py | |||
721 | +++ b/uaclient/defaults.py | |||
722 | @@ -6,14 +6,14 @@ any of our dependencies installed. | |||
723 | 6 | """ | 6 | """ |
724 | 7 | 7 | ||
725 | 8 | UAC_ETC_PATH = "/etc/ubuntu-advantage/" | 8 | UAC_ETC_PATH = "/etc/ubuntu-advantage/" |
727 | 9 | UAC_TMP_PATH = "/tmp/ubuntu-advantage/" | 9 | UAC_RUN_PATH = "/run/ubuntu-advantage/" |
728 | 10 | DEFAULT_DATA_DIR = "/var/lib/ubuntu-advantage" | 10 | DEFAULT_DATA_DIR = "/var/lib/ubuntu-advantage" |
729 | 11 | MACHINE_TOKEN_FILE = "machine-token.json" | 11 | MACHINE_TOKEN_FILE = "machine-token.json" |
730 | 12 | PRIVATE_SUBDIR = "/private" | 12 | PRIVATE_SUBDIR = "/private" |
731 | 13 | DEFAULT_PRIVATE_MACHINE_TOKEN_PATH = ( | 13 | DEFAULT_PRIVATE_MACHINE_TOKEN_PATH = ( |
732 | 14 | DEFAULT_DATA_DIR + PRIVATE_SUBDIR + "/" + MACHINE_TOKEN_FILE | 14 | DEFAULT_DATA_DIR + PRIVATE_SUBDIR + "/" + MACHINE_TOKEN_FILE |
733 | 15 | ) | 15 | ) |
735 | 16 | CANDIDATE_CACHE_PATH = UAC_TMP_PATH + "candidate-version" | 16 | CANDIDATE_CACHE_PATH = UAC_RUN_PATH + "candidate-version" |
736 | 17 | DEFAULT_CONFIG_FILE = UAC_ETC_PATH + "uaclient.conf" | 17 | DEFAULT_CONFIG_FILE = UAC_ETC_PATH + "uaclient.conf" |
737 | 18 | DEFAULT_HELP_FILE = UAC_ETC_PATH + "help_data.yaml" | 18 | DEFAULT_HELP_FILE = UAC_ETC_PATH + "help_data.yaml" |
738 | 19 | DEFAULT_UPGRADE_CONTRACT_FLAG_FILE = UAC_ETC_PATH + "request-update-contract" | 19 | DEFAULT_UPGRADE_CONTRACT_FLAG_FILE = UAC_ETC_PATH + "request-update-contract" |
739 | diff --git a/uaclient/jobs/update_messaging.py b/uaclient/jobs/update_messaging.py | |||
740 | index 4a3893f..41a027b 100644 | |||
741 | --- a/uaclient/jobs/update_messaging.py | |||
742 | +++ b/uaclient/jobs/update_messaging.py | |||
743 | @@ -28,7 +28,6 @@ from uaclient.messages import ( | |||
744 | 28 | CONTRACT_EXPIRED_MOTD_SOON_TMPL, | 28 | CONTRACT_EXPIRED_MOTD_SOON_TMPL, |
745 | 29 | DISABLED_APT_NO_PKGS_TMPL, | 29 | DISABLED_APT_NO_PKGS_TMPL, |
746 | 30 | DISABLED_APT_PKGS_TMPL, | 30 | DISABLED_APT_PKGS_TMPL, |
747 | 31 | TRY_UBUNTU_PRO_BETA, | ||
748 | 32 | ) | 31 | ) |
749 | 33 | 32 | ||
750 | 34 | XENIAL_ESM_URL = "https://ubuntu.com/16-04" | 33 | XENIAL_ESM_URL = "https://ubuntu.com/16-04" |
751 | @@ -68,6 +67,17 @@ UPDATE_NOTIFIER_MOTD_SCRIPT = ( | |||
752 | 68 | ) | 67 | ) |
753 | 69 | 68 | ||
754 | 70 | 69 | ||
755 | 70 | def set_apt_news_flag(cfg: config.UAConfig): | ||
756 | 71 | if system.is_current_series_lts(): | ||
757 | 72 | system.create_file( | ||
758 | 73 | os.path.join(cfg.data_dir, "flags", "show-apt-news") | ||
759 | 74 | ) | ||
760 | 75 | |||
761 | 76 | |||
762 | 77 | def clear_apt_news_flag(cfg: config.UAConfig): | ||
763 | 78 | system.remove_file(os.path.join(cfg.data_dir, "flags", "show-apt-news")) | ||
764 | 79 | |||
765 | 80 | |||
766 | 71 | def get_contract_expiry_status( | 81 | def get_contract_expiry_status( |
767 | 72 | cfg: config.UAConfig, | 82 | cfg: config.UAConfig, |
768 | 73 | ) -> Tuple[ContractExpiryStatus, int]: | 83 | ) -> Tuple[ContractExpiryStatus, int]: |
769 | @@ -311,32 +321,6 @@ def write_apt_and_motd_templates(cfg: config.UAConfig, series: str) -> None: | |||
770 | 311 | ], | 321 | ], |
771 | 312 | ) | 322 | ) |
772 | 313 | 323 | ||
773 | 314 | if ( | ||
774 | 315 | system.is_current_series_lts() | ||
775 | 316 | and not system.is_active_esm(series) | ||
776 | 317 | and not cfg.is_attached | ||
777 | 318 | ): | ||
778 | 319 | _write_template_or_remove( | ||
779 | 320 | TRY_UBUNTU_PRO_BETA, os.path.join(msg_dir, apps_no_pkg_file) | ||
780 | 321 | ) | ||
781 | 322 | _write_template_or_remove( | ||
782 | 323 | TRY_UBUNTU_PRO_BETA, os.path.join(msg_dir, apps_pkg_file) | ||
783 | 324 | ) | ||
784 | 325 | _write_template_or_remove("", os.path.join(msg_dir, infra_no_pkg_file)) | ||
785 | 326 | _write_template_or_remove("", os.path.join(msg_dir, infra_pkg_file)) | ||
786 | 327 | _write_template_or_remove( | ||
787 | 328 | "", os.path.join(msg_dir, motd_apps_no_pkg_file) | ||
788 | 329 | ) | ||
789 | 330 | _write_template_or_remove( | ||
790 | 331 | "", os.path.join(msg_dir, motd_apps_pkg_file) | ||
791 | 332 | ) | ||
792 | 333 | _write_template_or_remove( | ||
793 | 334 | "", os.path.join(msg_dir, motd_infra_no_pkg_file) | ||
794 | 335 | ) | ||
795 | 336 | _write_template_or_remove( | ||
796 | 337 | "", os.path.join(msg_dir, motd_infra_pkg_file) | ||
797 | 338 | ) | ||
798 | 339 | |||
799 | 340 | 324 | ||
800 | 341 | def write_esm_announcement_message(cfg: config.UAConfig, series: str) -> None: | 325 | def write_esm_announcement_message(cfg: config.UAConfig, series: str) -> None: |
801 | 342 | """Write human-readable messages if ESM is offered on this LTS release. | 326 | """Write human-readable messages if ESM is offered on this LTS release. |
802 | @@ -396,6 +380,12 @@ def update_apt_and_motd_messages(cfg: config.UAConfig) -> bool: | |||
803 | 396 | 380 | ||
804 | 397 | # Announce ESM availabilty on active ESM LTS releases | 381 | # Announce ESM availabilty on active ESM LTS releases |
805 | 398 | # write_esm_announcement_message(cfg, series) | 382 | # write_esm_announcement_message(cfg, series) |
806 | 383 | |||
807 | 384 | if cfg.apt_news: | ||
808 | 385 | set_apt_news_flag(cfg) | ||
809 | 386 | else: | ||
810 | 387 | clear_apt_news_flag(cfg) | ||
811 | 388 | |||
812 | 399 | write_apt_and_motd_templates(cfg, series) | 389 | write_apt_and_motd_templates(cfg, series) |
813 | 400 | # Now that we've setup/cleanedup templates render them with apt-hook | 390 | # Now that we've setup/cleanedup templates render them with apt-hook |
814 | 401 | system.subp( | 391 | system.subp( |
815 | diff --git a/uaclient/messages.py b/uaclient/messages.py | |||
816 | index 95f1605..e3061be 100644 | |||
817 | --- a/uaclient/messages.py | |||
818 | +++ b/uaclient/messages.py | |||
819 | @@ -1034,7 +1034,3 @@ Package names in {bold}bold{end_bold} currently have an available update | |||
820 | 1034 | with '{{service}}' enabled""".format( | 1034 | with '{{service}}' enabled""".format( |
821 | 1035 | bold=TxtColor.BOLD, end_bold=TxtColor.ENDC | 1035 | bold=TxtColor.BOLD, end_bold=TxtColor.ENDC |
822 | 1036 | ) | 1036 | ) |
823 | 1037 | |||
824 | 1038 | TRY_UBUNTU_PRO_BETA = """\ | ||
825 | 1039 | Try Ubuntu Pro beta with a free personal subscription on up to 5 machines. | ||
826 | 1040 | Learn more at https://ubuntu.com/pro""" | ||
827 | diff --git a/uaclient/system.py b/uaclient/system.py | |||
828 | index ef48d0c..3983e84 100644 | |||
829 | --- a/uaclient/system.py | |||
830 | +++ b/uaclient/system.py | |||
831 | @@ -1,6 +1,7 @@ | |||
832 | 1 | import datetime | 1 | import datetime |
833 | 2 | import logging | 2 | import logging |
834 | 3 | import os | 3 | import os |
835 | 4 | import pathlib | ||
836 | 4 | import re | 5 | import re |
837 | 5 | import subprocess | 6 | import subprocess |
838 | 6 | import time | 7 | import time |
839 | @@ -205,6 +206,11 @@ def is_active_esm(series: str) -> bool: | |||
840 | 205 | 206 | ||
841 | 206 | 207 | ||
842 | 207 | @lru_cache(maxsize=None) | 208 | @lru_cache(maxsize=None) |
843 | 209 | def is_current_series_active_esm() -> bool: | ||
844 | 210 | return is_active_esm(get_platform_info()["series"]) | ||
845 | 211 | |||
846 | 212 | |||
847 | 213 | @lru_cache(maxsize=None) | ||
848 | 208 | def is_container(run_path: str = "/run") -> bool: | 214 | def is_container(run_path: str = "/run") -> bool: |
849 | 209 | """Checks to see if this code running in a container of some sort""" | 215 | """Checks to see if this code running in a container of some sort""" |
850 | 210 | 216 | ||
851 | @@ -350,6 +356,13 @@ def load_file(filename: str, decode: bool = True) -> str: | |||
852 | 350 | return content.decode("utf-8") | 356 | return content.decode("utf-8") |
853 | 351 | 357 | ||
854 | 352 | 358 | ||
855 | 359 | def create_file(filename: str, mode: int = 0o644) -> None: | ||
856 | 360 | logging.debug("Creating file: %s", filename) | ||
857 | 361 | os.makedirs(os.path.dirname(filename), exist_ok=True) | ||
858 | 362 | pathlib.Path(filename).touch() | ||
859 | 363 | os.chmod(filename, mode) | ||
860 | 364 | |||
861 | 365 | |||
862 | 353 | def write_file(filename: str, content: str, mode: int = 0o644) -> None: | 366 | def write_file(filename: str, content: str, mode: int = 0o644) -> None: |
863 | 354 | """Write content to the provided filename encoding it if necessary. | 367 | """Write content to the provided filename encoding it if necessary. |
864 | 355 | 368 | ||
865 | diff --git a/uaclient/tests/test_actions.py b/uaclient/tests/test_actions.py | |||
866 | index 6f77d7f..12c05f1 100644 | |||
867 | --- a/uaclient/tests/test_actions.py | |||
868 | +++ b/uaclient/tests/test_actions.py | |||
869 | @@ -1,8 +1,10 @@ | |||
870 | 1 | import logging | ||
871 | 2 | |||
872 | 1 | import mock | 3 | import mock |
873 | 2 | import pytest | 4 | import pytest |
874 | 3 | 5 | ||
875 | 4 | from uaclient import exceptions, messages | 6 | from uaclient import exceptions, messages |
877 | 5 | from uaclient.actions import attach_with_token, auto_attach | 7 | from uaclient.actions import attach_with_token, auto_attach, collect_logs |
878 | 6 | from uaclient.exceptions import ContractAPIError, NonAutoAttachImageError | 8 | from uaclient.exceptions import ContractAPIError, NonAutoAttachImageError |
879 | 7 | from uaclient.tests.test_cli_auto_attach import fake_instance_factory | 9 | from uaclient.tests.test_cli_auto_attach import fake_instance_factory |
880 | 8 | 10 | ||
881 | @@ -141,3 +143,36 @@ class TestAutoAttach: | |||
882 | 141 | auto_attach(cfg, fake_instance_factory()) | 143 | auto_attach(cfg, fake_instance_factory()) |
883 | 142 | 144 | ||
884 | 143 | assert unexpected_error == excinfo.value | 145 | assert unexpected_error == excinfo.value |
885 | 146 | |||
886 | 147 | |||
887 | 148 | @mock.patch("uaclient.actions._write_command_output_to_file") | ||
888 | 149 | class TestCollectLogs: | ||
889 | 150 | @pytest.mark.parametrize("caplog_text", [logging.WARNING], indirect=True) | ||
890 | 151 | @mock.patch("os.getuid") | ||
891 | 152 | @mock.patch("uaclient.system.write_file") | ||
892 | 153 | @mock.patch("uaclient.system.load_file") | ||
893 | 154 | @mock.patch("uaclient.actions._get_state_files") | ||
894 | 155 | @mock.patch("glob.glob") | ||
895 | 156 | def test_collect_logs_invalid_file( | ||
896 | 157 | self, | ||
897 | 158 | m_glob, | ||
898 | 159 | m_get_state_files, | ||
899 | 160 | m_load_file, | ||
900 | 161 | m_write_file, | ||
901 | 162 | m_getuid, | ||
902 | 163 | m_write_cmd, | ||
903 | 164 | caplog_text, | ||
904 | 165 | ): | ||
905 | 166 | m_get_state_files.return_value = ["a", "b"] | ||
906 | 167 | m_load_file.side_effect = [UnicodeError("test"), "test"] | ||
907 | 168 | m_getuid.return_value = 1 | ||
908 | 169 | m_glob.return_value = [] | ||
909 | 170 | |||
910 | 171 | with mock.patch("os.path.isfile", return_value=True): | ||
911 | 172 | collect_logs(cfg=mock.MagicMock(), output_dir="test") | ||
912 | 173 | |||
913 | 174 | assert 2 == m_load_file.call_count | ||
914 | 175 | assert [mock.call("a"), mock.call("b")] == m_load_file.call_args_list | ||
915 | 176 | assert 1 == m_write_file.call_count | ||
916 | 177 | assert [mock.call("test/b", "test")] == m_write_file.call_args_list | ||
917 | 178 | assert "Failed to load file: a\n" in caplog_text() | ||
918 | diff --git a/uaclient/tests/test_cli_config_set.py b/uaclient/tests/test_cli_config_set.py | |||
919 | index 66aaf82..d8a7c49 100644 | |||
920 | --- a/uaclient/tests/test_cli_config_set.py | |||
921 | +++ b/uaclient/tests/test_cli_config_set.py | |||
922 | @@ -16,7 +16,8 @@ positional arguments: | |||
923 | 16 | must be one of: http_proxy, https_proxy, apt_http_proxy, | 16 | must be one of: http_proxy, https_proxy, apt_http_proxy, |
924 | 17 | apt_https_proxy, ua_apt_http_proxy, ua_apt_https_proxy, | 17 | apt_https_proxy, ua_apt_http_proxy, ua_apt_https_proxy, |
925 | 18 | global_apt_http_proxy, global_apt_https_proxy, | 18 | global_apt_http_proxy, global_apt_https_proxy, |
927 | 19 | update_messaging_timer, update_status_timer, metering_timer | 19 | update_messaging_timer, update_status_timer, metering_timer, |
928 | 20 | apt_news | ||
929 | 20 | 21 | ||
930 | 21 | Flags: | 22 | Flags: |
931 | 22 | -h, --help show this help message and exit | 23 | -h, --help show this help message and exit |
932 | diff --git a/uaclient/tests/test_cli_config_show.py b/uaclient/tests/test_cli_config_show.py | |||
933 | index d4582fd..ebf760c 100644 | |||
934 | --- a/uaclient/tests/test_cli_config_show.py | |||
935 | +++ b/uaclient/tests/test_cli_config_show.py | |||
936 | @@ -117,6 +117,7 @@ global_apt_https_proxy http://global_apt_https_proxy | |||
937 | 117 | update_messaging_timer None | 117 | update_messaging_timer None |
938 | 118 | update_status_timer None | 118 | update_status_timer None |
939 | 119 | metering_timer None | 119 | metering_timer None |
940 | 120 | apt_news True | ||
941 | 120 | """ | 121 | """ |
942 | 121 | == out | 122 | == out |
943 | 122 | ) | 123 | ) |
944 | diff --git a/uaclient/tests/test_cli_config_unset.py b/uaclient/tests/test_cli_config_unset.py | |||
945 | index 115bc86..42c3625 100644 | |||
946 | --- a/uaclient/tests/test_cli_config_unset.py | |||
947 | +++ b/uaclient/tests/test_cli_config_unset.py | |||
948 | @@ -15,7 +15,7 @@ positional arguments: | |||
949 | 15 | http_proxy, https_proxy, apt_http_proxy, apt_https_proxy, | 15 | http_proxy, https_proxy, apt_http_proxy, apt_https_proxy, |
950 | 16 | ua_apt_http_proxy, ua_apt_https_proxy, global_apt_http_proxy, | 16 | ua_apt_http_proxy, ua_apt_https_proxy, global_apt_http_proxy, |
951 | 17 | global_apt_https_proxy, update_messaging_timer, | 17 | global_apt_https_proxy, update_messaging_timer, |
953 | 18 | update_status_timer, metering_timer | 18 | update_status_timer, metering_timer, apt_news |
954 | 19 | 19 | ||
955 | 20 | Flags: | 20 | Flags: |
956 | 21 | -h, --help show this help message and exit | 21 | -h, --help show this help message and exit |
957 | diff --git a/uaclient/tests/test_config.py b/uaclient/tests/test_config.py | |||
958 | index bd8a49e..d3b493c 100644 | |||
959 | --- a/uaclient/tests/test_config.py | |||
960 | +++ b/uaclient/tests/test_config.py | |||
961 | @@ -295,6 +295,7 @@ UA_CFG_DICT = { | |||
962 | 295 | "ua_config": { | 295 | "ua_config": { |
963 | 296 | "apt_http_proxy": None, | 296 | "apt_http_proxy": None, |
964 | 297 | "apt_https_proxy": None, | 297 | "apt_https_proxy": None, |
965 | 298 | "apt_news": True, | ||
966 | 298 | "global_apt_http_proxy": None, | 299 | "global_apt_http_proxy": None, |
967 | 299 | "global_apt_https_proxy": None, | 300 | "global_apt_https_proxy": None, |
968 | 300 | "ua_apt_http_proxy": None, | 301 | "ua_apt_http_proxy": None, |
969 | @@ -316,7 +317,9 @@ class TestUAConfigKeys: | |||
970 | 316 | ): | 317 | ): |
971 | 317 | """Getters and settings are available fo UA_CONFIGURABLE_KEYS.""" | 318 | """Getters and settings are available fo UA_CONFIGURABLE_KEYS.""" |
972 | 318 | cfg = FakeConfig() | 319 | cfg = FakeConfig() |
974 | 319 | assert None is getattr(cfg, attr_name, None) | 320 | assert UA_CFG_DICT["ua_config"][attr_name] == getattr( |
975 | 321 | cfg, attr_name, None | ||
976 | 322 | ) | ||
977 | 320 | cfg_non_members = ("apt_http_proxy", "apt_https_proxy") | 323 | cfg_non_members = ("apt_http_proxy", "apt_https_proxy") |
978 | 321 | if attr_name not in cfg_non_members: | 324 | if attr_name not in cfg_non_members: |
979 | 322 | setattr(cfg, attr_name, attr_name + "value") | 325 | setattr(cfg, attr_name, attr_name + "value") |
980 | diff --git a/uaclient/tests/test_version.py b/uaclient/tests/test_version.py | |||
981 | index f6fd890..369dbbb 100644 | |||
982 | --- a/uaclient/tests/test_version.py | |||
983 | +++ b/uaclient/tests/test_version.py | |||
984 | @@ -59,9 +59,12 @@ class TestGetLastKnownCandidate: | |||
985 | 59 | m_open.side_effect = OSError() | 59 | m_open.side_effect = OSError() |
986 | 60 | assert None is get_last_known_candidate() | 60 | assert None is get_last_known_candidate() |
987 | 61 | 61 | ||
988 | 62 | @mock.patch("os.makedirs") | ||
989 | 62 | @mock.patch("uaclient.version.get_apt_cache_policy_for_package") | 63 | @mock.patch("uaclient.version.get_apt_cache_policy_for_package") |
990 | 63 | @mock.patch("os.path.exists", return_value=False) | 64 | @mock.patch("os.path.exists", return_value=False) |
992 | 64 | def test_create_cache_before_returning(self, _m_exists, m_policy): | 65 | def test_create_cache_before_returning( |
993 | 66 | self, _m_exists, m_policy, _m_makedirs | ||
994 | 67 | ): | ||
995 | 65 | m_policy.return_value = """ | 68 | m_policy.return_value = """ |
996 | 66 | Installed: 1.1.2 | 69 | Installed: 1.1.2 |
997 | 67 | Candidate: 1.2.3 | 70 | Candidate: 1.2.3 |
998 | @@ -83,7 +86,7 @@ class TestGetLastKnownCandidate: | |||
999 | 83 | Version table: | 86 | Version table: |
1000 | 84 | """ | 87 | """ |
1001 | 85 | m_open.side_effect = OSError() | 88 | m_open.side_effect = OSError() |
1003 | 86 | assert None is get_last_known_candidate() | 89 | assert "1.2.3" == get_last_known_candidate() |
1004 | 87 | 90 | ||
1005 | 88 | 91 | ||
1006 | 89 | class TestCheckForNewVersion: | 92 | class TestCheckForNewVersion: |
1007 | diff --git a/uaclient/version.py b/uaclient/version.py | |||
1008 | index 54776f6..6232b30 100644 | |||
1009 | --- a/uaclient/version.py | |||
1010 | +++ b/uaclient/version.py | |||
1011 | @@ -14,11 +14,11 @@ from uaclient.apt import ( | |||
1012 | 14 | get_apt_cache_policy_for_package, | 14 | get_apt_cache_policy_for_package, |
1013 | 15 | get_apt_cache_time, | 15 | get_apt_cache_time, |
1014 | 16 | ) | 16 | ) |
1016 | 17 | from uaclient.defaults import CANDIDATE_CACHE_PATH, UAC_TMP_PATH | 17 | from uaclient.defaults import CANDIDATE_CACHE_PATH, UAC_RUN_PATH |
1017 | 18 | from uaclient.exceptions import ProcessExecutionError | 18 | from uaclient.exceptions import ProcessExecutionError |
1018 | 19 | from uaclient.system import subp | 19 | from uaclient.system import subp |
1019 | 20 | 20 | ||
1021 | 21 | __VERSION__ = "27.11.2" | 21 | __VERSION__ = "27.11.3" |
1022 | 22 | PACKAGED_VERSION = "@@PACKAGED_VERSION@@" | 22 | PACKAGED_VERSION = "@@PACKAGED_VERSION@@" |
1023 | 23 | 23 | ||
1024 | 24 | CANDIDATE_REGEX = r"Candidate: (?P<candidate>.*?)\n" | 24 | CANDIDATE_REGEX = r"Candidate: (?P<candidate>.*?)\n" |
1025 | @@ -56,17 +56,19 @@ def get_last_known_candidate() -> Optional[str]: | |||
1026 | 56 | not os.path.exists(CANDIDATE_CACHE_PATH) | 56 | not os.path.exists(CANDIDATE_CACHE_PATH) |
1027 | 57 | or os.stat(CANDIDATE_CACHE_PATH).st_mtime < last_apt_cache_update | 57 | or os.stat(CANDIDATE_CACHE_PATH).st_mtime < last_apt_cache_update |
1028 | 58 | ): | 58 | ): |
1029 | 59 | candidate_version = None | ||
1030 | 59 | try: | 60 | try: |
1031 | 60 | policy = get_apt_cache_policy_for_package("ubuntu-advantage-tools") | 61 | policy = get_apt_cache_policy_for_package("ubuntu-advantage-tools") |
1032 | 61 | match = re.search(CANDIDATE_REGEX, policy) | 62 | match = re.search(CANDIDATE_REGEX, policy) |
1033 | 62 | if match: | 63 | if match: |
1034 | 63 | candidate_version = match.group("candidate") | 64 | candidate_version = match.group("candidate") |
1036 | 64 | os.makedirs(UAC_TMP_PATH, exist_ok=True) | 65 | os.makedirs(UAC_RUN_PATH, exist_ok=True) |
1037 | 65 | with open(CANDIDATE_CACHE_PATH, "w") as f: | 66 | with open(CANDIDATE_CACHE_PATH, "w") as f: |
1038 | 66 | f.write(candidate_version) | 67 | f.write(candidate_version) |
1040 | 67 | os.chmod(CANDIDATE_CACHE_PATH, 0o777) | 68 | return candidate_version |
1041 | 68 | except Exception: | 69 | except Exception: |
1043 | 69 | pass | 70 | if candidate_version is not None: |
1044 | 71 | return candidate_version | ||
1045 | 70 | 72 | ||
1046 | 71 | try: | 73 | try: |
1047 | 72 | with open(CANDIDATE_CACHE_PATH, "r") as f: | 74 | with open(CANDIDATE_CACHE_PATH, "r") as f: |
SRU review.
I flagged the entire "apt news" concept as needing leadership approval in https:/ /bugs.launchpad .net/ubuntu/ +source/ ubuntu- advantage- tools/+ bug/1992026/ comments/ 17, and I don't think I should accept this into proposed until that is resolved.
Apart from that this looks fine from an SRU perspective, from a quick review to look for significant changes that would impact the system and/or existing users (I've not reviewed every line). I made a couple of comments inline, but I don't think we need to block on them.