Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubuntu-advantage: determine on error if token was invalid #1342

Merged
merged 1 commit into from Jul 6, 2022

Conversation

ogayot
Copy link
Member

@ogayot ogayot commented Jul 6, 2022

In case of error, u-a-c exits with status 1. When the contract token supplied is invalid, it is also considered an error ; which previously made us unable to make the distinction between:

  • an invalid token
  • a more generic error such as network error or service unavailable error

Thanks to an update in u-a-c, we can now determine if the token was invalid, by parsing the standard output of the process, even when it exits with status 1.

The output is expected to be a JSON object that includes an array of errors where each error has a specific error code.

The error code for an invalid token is attach-invalid-token ; which we now look for in the output to determine if the contract token was invalid.

@ogayot ogayot requested a review from dbungert July 6, 2022 09:11
@ogayot ogayot force-pushed the u-a-c-distinguish-error-invalid branch from 750d43a to eca0bc4 Compare July 6, 2022 09:16
@ogayot
Copy link
Member Author

ogayot commented Jul 6, 2022

CC: @lucasmoura who implemented this update in u-a-c in the first place.

Copy link

@lucasmoura lucasmoura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Marking @renanrodrigo as well since he has more knowledge about the --simulate-with-token work

In case of error, u-a-c exits with status 1. When the contract token
supplied is invalid, it is also considered an error ; which previously
made us unable to make the distinction between:
 * an invalid token
 * a more generic error such as network error or service unavailable error

Thanks to an update in u-a-c, we can now determine if the token was
invalid, by parsing the standard output of the process, even when it
exits with status 1.

The output is expected to be a JSON object that includes an array of
errors where each error has a specific error code.

The error code for an invalid token is attach-invalid-token ; which we
now look for in the output to determine if the contract token was
invalid.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
@ogayot ogayot force-pushed the u-a-c-distinguish-error-invalid branch from eca0bc4 to 9d6bbf2 Compare July 6, 2022 14:42
@ogayot ogayot merged commit 746e559 into canonical:main Jul 6, 2022
@ogayot ogayot deleted the u-a-c-distinguish-error-invalid branch July 6, 2022 15:04
@renanrodrigo
Copy link
Member

As long as you are using the ua status command, this works.
We are implementing the simulate as part of the API transition (changing the command to use ua api), and the main change is that there will be a more coherent error code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants