From ab4dd74d770929ae5890c50362fdfc86985865ff Mon Sep 17 00:00:00 2001 From: Renan Rodrigo Date: Thu, 14 Mar 2024 08:37:10 -0300 Subject: [PATCH] auto-attach: make error message clearer When a machine tries to auto-attach and the contract server returns an error, print hints on what could have happened together with the error details. Signed-off-by: Renan Rodrigo --- debian/po/pt_BR.po | 105 +++++++++++++++++----------------- debian/po/ubuntu-pro.pot | 105 +++++++++++++++++----------------- features/ubuntu_pro.feature | 3 +- uaclient/messages/__init__.py | 8 ++- 4 files changed, 115 insertions(+), 106 deletions(-) diff --git a/debian/po/pt_BR.po b/debian/po/pt_BR.po index 0a61d6bb96..a72340539e 100644 --- a/debian/po/pt_BR.po +++ b/debian/po/pt_BR.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-18 12:55-0700\n" +"POT-Creation-Date: 2024-03-21 13:58-0300\n" "PO-Revision-Date: 2023-09-25 12:29-0400\n" "Last-Translator: Lucas Moura \n" "Language-Team: Brazilian Portuguese for interval must be a positive integer." @@ -3292,17 +3293,17 @@ msgstr "" "Não foi possível associar {key} a {value}: precisa ser um inteiro " "positivo." -#: ../../uaclient/messages/__init__.py:2378 +#: ../../uaclient/messages/__init__.py:2384 #, python-brace-format msgid "Invalid url in config. {key}: {value}" msgstr "url inválida no arquivo de configuração. {key}: {value}" -#: ../../uaclient/messages/__init__.py:2383 +#: ../../uaclient/messages/__init__.py:2389 #, python-brace-format msgid "Could not find yaml file: {filepath}" msgstr "Não foi possível encontrar o arquivo yaml: {filepath}" -#: ../../uaclient/messages/__init__.py:2389 +#: ../../uaclient/messages/__init__.py:2395 msgid "" "Error: Setting global apt proxy and pro scoped apt proxy\n" "at the same time is unsupported.\n" @@ -3313,27 +3314,27 @@ msgstr "" "pro de apt ao mesmo tempo não é suportado.\n" "Cancelando o processo de configuração.\n" -#: ../../uaclient/messages/__init__.py:2399 +#: ../../uaclient/messages/__init__.py:2405 msgid "Can't load the distro-info database." msgstr "Não foi possível carregar o banco de dados do distro-info." -#: ../../uaclient/messages/__init__.py:2404 +#: ../../uaclient/messages/__init__.py:2410 #, python-brace-format msgid "Can't find series {series} in the distro-info database." msgstr "" "Não foi possível encontrar a série {series} na banco de dados do distro-info." -#: ../../uaclient/messages/__init__.py:2409 +#: ../../uaclient/messages/__init__.py:2415 #, python-brace-format msgid "Error: Cannot use {option1} together with {option2}." msgstr "Erro: não é possível usar {option1} junto com {option2}" -#: ../../uaclient/messages/__init__.py:2413 +#: ../../uaclient/messages/__init__.py:2419 #, python-brace-format msgid "No help available for '{name}'" msgstr "Ajuda não disponível para '{name}'" -#: ../../uaclient/messages/__init__.py:2419 +#: ../../uaclient/messages/__init__.py:2425 #, python-brace-format msgid "" "Error: issue \"{issue}\" is not recognized.\n" @@ -3342,39 +3343,39 @@ msgstr "" "Erro: problema de segurnça \"{issue}\" não foi reconhecido.\n" "Use: \"pro fix CVE-yyyy-nnnn\" ou \"pro fix USN-nnnn\"" -#: ../../uaclient/messages/__init__.py:2425 +#: ../../uaclient/messages/__init__.py:2431 #, python-brace-format msgid "{arg} must be one of: {choices}" msgstr "{arg} precisa ser um de: {choices}" -#: ../../uaclient/messages/__init__.py:2430 +#: ../../uaclient/messages/__init__.py:2436 #, python-brace-format msgid "Empty value provided for {arg}." msgstr "" -#: ../../uaclient/messages/__init__.py:2435 +#: ../../uaclient/messages/__init__.py:2441 #, python-brace-format msgid "Expected {expected} but found: {actual}" msgstr "Esperava {expected} mas encontrou: {actual}" -#: ../../uaclient/messages/__init__.py:2439 +#: ../../uaclient/messages/__init__.py:2445 msgid "Unable to process uaclient.conf" msgstr "Falha ao processar uaclient.conf" -#: ../../uaclient/messages/__init__.py:2444 +#: ../../uaclient/messages/__init__.py:2450 msgid "Unable to refresh your subscription" msgstr "Falha ao atualizar sua assinatura" -#: ../../uaclient/messages/__init__.py:2449 +#: ../../uaclient/messages/__init__.py:2455 msgid "Unable to update Ubuntu Pro related APT and MOTD messages." msgstr "" "Falha ao atualizar as mensagens de APT e MOTD relacioandas ao Ubuntu Pro" -#: ../../uaclient/messages/__init__.py:2455 +#: ../../uaclient/messages/__init__.py:2461 msgid "json formatted response requires --assume-yes flag." msgstr "resposta formatada em json necessita do paramêtro --assume-yes" -#: ../../uaclient/messages/__init__.py:2463 +#: ../../uaclient/messages/__init__.py:2469 msgid "" "Do not pass the TOKEN arg if you are using --attach-config.\n" "Include the token in the attach-config file instead.\n" @@ -3384,50 +3385,50 @@ msgstr "" "Ao invés disso, inclua o token no arquivo de attach-config.\n" " " -#: ../../uaclient/messages/__init__.py:2472 +#: ../../uaclient/messages/__init__.py:2478 msgid "Cannot provide both --args and --data at the same time" msgstr "Não é possível usar --args e --data ao mesmo tempo" -#: ../../uaclient/messages/__init__.py:2478 +#: ../../uaclient/messages/__init__.py:2484 #, python-brace-format msgid "Unable to perform: {lock_request}.\n" msgstr "Falha ao executar: {lock_request}.\n" -#: ../../uaclient/messages/__init__.py:2487 +#: ../../uaclient/messages/__init__.py:2493 msgid "This command must be run as root (try using sudo)." msgstr "Esse comando precisa ser executado como root (tente usando sudo)." -#: ../../uaclient/messages/__init__.py:2492 +#: ../../uaclient/messages/__init__.py:2498 #, python-brace-format msgid "Metadata for {issue} is invalid. Error: {error_msg}." msgstr "Metadados para {issue} não são válidos. Erro: {error_msg}." -#: ../../uaclient/messages/__init__.py:2499 +#: ../../uaclient/messages/__init__.py:2505 #, python-brace-format msgid "Error: {issue_id} not found." msgstr "Erro: {issue_id} não encontrada." -#: ../../uaclient/messages/__init__.py:2503 +#: ../../uaclient/messages/__init__.py:2509 #, python-brace-format msgid "GPG key '{keyfile}' not found." msgstr "chave GPG '{keyfile}' não foi encontrada" -#: ../../uaclient/messages/__init__.py:2508 +#: ../../uaclient/messages/__init__.py:2514 #, python-brace-format msgid "'{endpoint}' is not a valid endpoint" msgstr "'{endpoint}' não é um endpoint válido" -#: ../../uaclient/messages/__init__.py:2513 +#: ../../uaclient/messages/__init__.py:2519 #, python-brace-format msgid "Missing argument '{arg}' for endpoint {endpoint}" msgstr "'{arg}' está faltando para endpoint {endpoint}" -#: ../../uaclient/messages/__init__.py:2518 +#: ../../uaclient/messages/__init__.py:2524 #, python-brace-format msgid "{endpoint} accepts no arguments" msgstr "{endpoint} não aceita paramêtros" -#: ../../uaclient/messages/__init__.py:2523 +#: ../../uaclient/messages/__init__.py:2529 #, python-brace-format msgid "" "Error parsing API json data parameter:\n" @@ -3436,32 +3437,32 @@ msgstr "" "Error ao analisar paramêtro data para API json:\n" "{data}" -#: ../../uaclient/messages/__init__.py:2528 +#: ../../uaclient/messages/__init__.py:2534 #, python-brace-format msgid "'{arg}' is not formatted as 'key=value'" msgstr "'{arg}' não está formatado como 'chave=valor'" -#: ../../uaclient/messages/__init__.py:2533 +#: ../../uaclient/messages/__init__.py:2539 #, python-brace-format msgid "Unable to determine version: {error_msg}" msgstr "Não foi possível determinar a versão: {error_msg}" -#: ../../uaclient/messages/__init__.py:2538 +#: ../../uaclient/messages/__init__.py:2544 msgid "features.disable_auto_attach set in config" msgstr "features.disable_auto_attach definida na configuração" -#: ../../uaclient/messages/__init__.py:2543 +#: ../../uaclient/messages/__init__.py:2549 #, python-brace-format msgid "Unable to determine unattended-upgrades status: {error_msg}" msgstr "" "Não foi possível determinar o status do unattended-upgrades: {error_msg}" -#: ../../uaclient/messages/__init__.py:2549 +#: ../../uaclient/messages/__init__.py:2555 #, python-brace-format msgid "Expected value with type {expected_type} but got type: {got_type}" msgstr "Esperava valor com tipo {expected_type}, mas recebeu tipo {got_type}" -#: ../../uaclient/messages/__init__.py:2555 +#: ../../uaclient/messages/__init__.py:2561 #, python-brace-format msgid "" "Got value with incorrect type at index {index}:\n" @@ -3470,7 +3471,7 @@ msgstr "" "Valor com tipo incorreto na posição {index}:\n" "{nested_msg}" -#: ../../uaclient/messages/__init__.py:2561 +#: ../../uaclient/messages/__init__.py:2567 #, python-brace-format msgid "" "Got value with incorrect type for field \"{key}\":\n" @@ -3479,19 +3480,19 @@ msgstr "" "Valor com tipo incorreto para o campo \"{key}\":\n" "{nested_msg}" -#: ../../uaclient/messages/__init__.py:2568 +#: ../../uaclient/messages/__init__.py:2574 #, python-brace-format msgid "Value provided was not found in {enum_class}'s allowed: value: {values}" msgstr "" "Valor fornecido não está presente nos valores permitidos de {enum_class}: " "{values}" -#: ../../uaclient/messages/__init__.py:2579 +#: ../../uaclient/messages/__init__.py:2585 #, python-brace-format msgid "Error updating ESM services cache: {error}" msgstr "" -#: ../../uaclient/messages/__init__.py:2585 +#: ../../uaclient/messages/__init__.py:2591 #, python-brace-format msgid "" "There is a problem with the resource directives provided by {url}\n" diff --git a/debian/po/ubuntu-pro.pot b/debian/po/ubuntu-pro.pot index ddc4dd7bdc..75554fc12f 100644 --- a/debian/po/ubuntu-pro.pot +++ b/debian/po/ubuntu-pro.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-03-18 12:55-0700\n" +"POT-Creation-Date: 2024-03-21 13:58-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2851,21 +2851,22 @@ msgstr "" msgid "Could not determine contract delta service type {orig} {new}" msgstr "" -#: ../../uaclient/messages/__init__.py:2268 +#: ../../uaclient/messages/__init__.py:2270 #, python-brace-format msgid "" -"Error on Pro Image:\n" +"Failed to identify this image as a valid Ubuntu Pro image.\n" +"Details:\n" "{error_msg}" msgstr "" -#: ../../uaclient/messages/__init__.py:2274 +#: ../../uaclient/messages/__init__.py:2280 #, python-brace-format msgid "" "An error occurred while talking the the cloud metadata service: {code} - " "{body}" msgstr "" -#: ../../uaclient/messages/__init__.py:2281 +#: ../../uaclient/messages/__init__.py:2287 #, python-brace-format msgid "" "Failed to attach machine\n" @@ -2873,41 +2874,41 @@ msgid "" "For more information, see {url}" msgstr "" -#: ../../uaclient/messages/__init__.py:2291 +#: ../../uaclient/messages/__init__.py:2297 #, python-brace-format msgid "No valid AWS IMDS endpoint discovered at addresses: {addresses}" msgstr "" -#: ../../uaclient/messages/__init__.py:2298 +#: ../../uaclient/messages/__init__.py:2304 msgid "Unable to determine cloud platform." msgstr "" -#: ../../uaclient/messages/__init__.py:2306 +#: ../../uaclient/messages/__init__.py:2312 #, python-brace-format msgid "" "Auto-attach image support is not available on this image\n" "See: {url}" msgstr "" -#: ../../uaclient/messages/__init__.py:2315 +#: ../../uaclient/messages/__init__.py:2321 #, python-brace-format msgid "" "Auto-attach image support is not available on {{cloud_type}}\n" "See: {url}" msgstr "" -#: ../../uaclient/messages/__init__.py:2323 +#: ../../uaclient/messages/__init__.py:2329 #, python-brace-format msgid "{file_name} is not valid {file_format}" msgstr "" -#: ../../uaclient/messages/__init__.py:2329 +#: ../../uaclient/messages/__init__.py:2335 #, python-brace-format msgid "" "Could not parse /etc/os-release VERSION: {orig_ver} (modified to {mod_ver})" msgstr "" -#: ../../uaclient/messages/__init__.py:2337 +#: ../../uaclient/messages/__init__.py:2343 #, python-brace-format msgid "" "Could not extract series information from /etc/os-release.\n" @@ -2915,7 +2916,7 @@ msgid "" "and the VERSION_CODENAME information is not present" msgstr "" -#: ../../uaclient/messages/__init__.py:2347 +#: ../../uaclient/messages/__init__.py:2353 #, python-brace-format msgid "" "There is a corrupted lock file in the system. To continue, please remove it\n" @@ -2924,204 +2925,204 @@ msgid "" "$ sudo rm {lock_file_path}" msgstr "" -#: ../../uaclient/messages/__init__.py:2356 +#: ../../uaclient/messages/__init__.py:2362 #, python-brace-format msgid "{source} returned invalid json: {out}" msgstr "" -#: ../../uaclient/messages/__init__.py:2362 +#: ../../uaclient/messages/__init__.py:2368 #, python-brace-format msgid "" "Invalid value for {path_to_value} in /etc/ubuntu-advantage/uaclient.conf. " "Expected {expected_value}, found {value}." msgstr "" -#: ../../uaclient/messages/__init__.py:2371 +#: ../../uaclient/messages/__init__.py:2377 #, python-brace-format msgid "" "Cannot set {key} to {value}: for interval must be a positive integer." msgstr "" -#: ../../uaclient/messages/__init__.py:2378 +#: ../../uaclient/messages/__init__.py:2384 #, python-brace-format msgid "Invalid url in config. {key}: {value}" msgstr "" -#: ../../uaclient/messages/__init__.py:2383 +#: ../../uaclient/messages/__init__.py:2389 #, python-brace-format msgid "Could not find yaml file: {filepath}" msgstr "" -#: ../../uaclient/messages/__init__.py:2389 +#: ../../uaclient/messages/__init__.py:2395 msgid "" "Error: Setting global apt proxy and pro scoped apt proxy\n" "at the same time is unsupported.\n" "Cancelling config process operation.\n" msgstr "" -#: ../../uaclient/messages/__init__.py:2399 +#: ../../uaclient/messages/__init__.py:2405 msgid "Can't load the distro-info database." msgstr "" -#: ../../uaclient/messages/__init__.py:2404 +#: ../../uaclient/messages/__init__.py:2410 #, python-brace-format msgid "Can't find series {series} in the distro-info database." msgstr "" -#: ../../uaclient/messages/__init__.py:2409 +#: ../../uaclient/messages/__init__.py:2415 #, python-brace-format msgid "Error: Cannot use {option1} together with {option2}." msgstr "" -#: ../../uaclient/messages/__init__.py:2413 +#: ../../uaclient/messages/__init__.py:2419 #, python-brace-format msgid "No help available for '{name}'" msgstr "" -#: ../../uaclient/messages/__init__.py:2419 +#: ../../uaclient/messages/__init__.py:2425 #, python-brace-format msgid "" "Error: issue \"{issue}\" is not recognized.\n" "Usage: \"pro fix CVE-yyyy-nnnn\" or \"pro fix USN-nnnn\"" msgstr "" -#: ../../uaclient/messages/__init__.py:2425 +#: ../../uaclient/messages/__init__.py:2431 #, python-brace-format msgid "{arg} must be one of: {choices}" msgstr "" -#: ../../uaclient/messages/__init__.py:2430 +#: ../../uaclient/messages/__init__.py:2436 #, python-brace-format msgid "Empty value provided for {arg}." msgstr "" -#: ../../uaclient/messages/__init__.py:2435 +#: ../../uaclient/messages/__init__.py:2441 #, python-brace-format msgid "Expected {expected} but found: {actual}" msgstr "" -#: ../../uaclient/messages/__init__.py:2439 +#: ../../uaclient/messages/__init__.py:2445 msgid "Unable to process uaclient.conf" msgstr "" -#: ../../uaclient/messages/__init__.py:2444 +#: ../../uaclient/messages/__init__.py:2450 msgid "Unable to refresh your subscription" msgstr "" -#: ../../uaclient/messages/__init__.py:2449 +#: ../../uaclient/messages/__init__.py:2455 msgid "Unable to update Ubuntu Pro related APT and MOTD messages." msgstr "" -#: ../../uaclient/messages/__init__.py:2455 +#: ../../uaclient/messages/__init__.py:2461 msgid "json formatted response requires --assume-yes flag." msgstr "" -#: ../../uaclient/messages/__init__.py:2463 +#: ../../uaclient/messages/__init__.py:2469 msgid "" "Do not pass the TOKEN arg if you are using --attach-config.\n" "Include the token in the attach-config file instead.\n" " " msgstr "" -#: ../../uaclient/messages/__init__.py:2472 +#: ../../uaclient/messages/__init__.py:2478 msgid "Cannot provide both --args and --data at the same time" msgstr "" -#: ../../uaclient/messages/__init__.py:2478 +#: ../../uaclient/messages/__init__.py:2484 #, python-brace-format msgid "Unable to perform: {lock_request}.\n" msgstr "" -#: ../../uaclient/messages/__init__.py:2487 +#: ../../uaclient/messages/__init__.py:2493 msgid "This command must be run as root (try using sudo)." msgstr "" -#: ../../uaclient/messages/__init__.py:2492 +#: ../../uaclient/messages/__init__.py:2498 #, python-brace-format msgid "Metadata for {issue} is invalid. Error: {error_msg}." msgstr "" -#: ../../uaclient/messages/__init__.py:2499 +#: ../../uaclient/messages/__init__.py:2505 #, python-brace-format msgid "Error: {issue_id} not found." msgstr "" -#: ../../uaclient/messages/__init__.py:2503 +#: ../../uaclient/messages/__init__.py:2509 #, python-brace-format msgid "GPG key '{keyfile}' not found." msgstr "" -#: ../../uaclient/messages/__init__.py:2508 +#: ../../uaclient/messages/__init__.py:2514 #, python-brace-format msgid "'{endpoint}' is not a valid endpoint" msgstr "" -#: ../../uaclient/messages/__init__.py:2513 +#: ../../uaclient/messages/__init__.py:2519 #, python-brace-format msgid "Missing argument '{arg}' for endpoint {endpoint}" msgstr "" -#: ../../uaclient/messages/__init__.py:2518 +#: ../../uaclient/messages/__init__.py:2524 #, python-brace-format msgid "{endpoint} accepts no arguments" msgstr "" -#: ../../uaclient/messages/__init__.py:2523 +#: ../../uaclient/messages/__init__.py:2529 #, python-brace-format msgid "" "Error parsing API json data parameter:\n" "{data}" msgstr "" -#: ../../uaclient/messages/__init__.py:2528 +#: ../../uaclient/messages/__init__.py:2534 #, python-brace-format msgid "'{arg}' is not formatted as 'key=value'" msgstr "" -#: ../../uaclient/messages/__init__.py:2533 +#: ../../uaclient/messages/__init__.py:2539 #, python-brace-format msgid "Unable to determine version: {error_msg}" msgstr "" -#: ../../uaclient/messages/__init__.py:2538 +#: ../../uaclient/messages/__init__.py:2544 msgid "features.disable_auto_attach set in config" msgstr "" -#: ../../uaclient/messages/__init__.py:2543 +#: ../../uaclient/messages/__init__.py:2549 #, python-brace-format msgid "Unable to determine unattended-upgrades status: {error_msg}" msgstr "" -#: ../../uaclient/messages/__init__.py:2549 +#: ../../uaclient/messages/__init__.py:2555 #, python-brace-format msgid "Expected value with type {expected_type} but got type: {got_type}" msgstr "" -#: ../../uaclient/messages/__init__.py:2555 +#: ../../uaclient/messages/__init__.py:2561 #, python-brace-format msgid "" "Got value with incorrect type at index {index}:\n" "{nested_msg}" msgstr "" -#: ../../uaclient/messages/__init__.py:2561 +#: ../../uaclient/messages/__init__.py:2567 #, python-brace-format msgid "" "Got value with incorrect type for field \"{key}\":\n" "{nested_msg}" msgstr "" -#: ../../uaclient/messages/__init__.py:2568 +#: ../../uaclient/messages/__init__.py:2574 #, python-brace-format msgid "Value provided was not found in {enum_class}'s allowed: value: {values}" msgstr "" -#: ../../uaclient/messages/__init__.py:2579 +#: ../../uaclient/messages/__init__.py:2585 #, python-brace-format msgid "Error updating ESM services cache: {error}" msgstr "" -#: ../../uaclient/messages/__init__.py:2585 +#: ../../uaclient/messages/__init__.py:2591 #, python-brace-format msgid "" "There is a problem with the resource directives provided by {url}\n" diff --git a/features/ubuntu_pro.feature b/features/ubuntu_pro.feature index 30c869c6df..c5f9639711 100644 --- a/features/ubuntu_pro.feature +++ b/features/ubuntu_pro.feature @@ -254,7 +254,8 @@ Feature: Command behaviour when auto-attached in an ubuntu PRO image When I verify that running `pro auto-attach` `with sudo` exits `1` Then stderr matches regexp: """ - Error on Pro Image: + Failed to identify this image as a valid Ubuntu Pro image. + Details: missing instance information """ diff --git a/uaclient/messages/__init__.py b/uaclient/messages/__init__.py index bb1ac4f29d..6742b8e682 100644 --- a/uaclient/messages/__init__.py +++ b/uaclient/messages/__init__.py @@ -2265,7 +2265,13 @@ def __repr__(self): ) E_INVALID_PRO_IMAGE = FormattedNamedMessage( - name="invalid-pro-image", msg=t.gettext("Error on Pro Image:\n{error_msg}") + name="invalid-pro-image", + msg=t.gettext( + """\ +Failed to identify this image as a valid Ubuntu Pro image. +Details: +{error_msg}""" + ), ) E_CLOUD_METADATA_ERROR = FormattedNamedMessage(