[Bug 1829788] Re: backtrace on attach: KeyError: 'effectiveTo'
Andreas Hasenack
andreas at canonical.com
Mon May 20 19:50:34 UTC 2019
** Description changed:
+ [Impact]
+ Due to a server-side change, an expected key is no longer being sent to the client during an attach operation. This causes the client to backtrace with a KeyError exception:
+
Traceback (most recent call last):
- File "/usr/bin/ua", line 11, in
+ File "/usr/bin/ua", line 11, in
load_entry_point('ubuntu-advantage-tools==19.2', 'console_scripts', 'ubuntu-advantage')()
File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 371, in main
return args.action(args, cfg)
File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 241, in action_attach
action_status(args=None, cfg=cfg)
File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 295, in action_status
contractInfo['effectiveTo'], '%Y-%m-%dT%H:%M:%SZ')
KeyError: 'effectiveTo'
+
+ The client should default to a "no expiration" value in this case.
+ Upstream already handles this, but the fix is missing for disco and
+ eoan.
+
+ [Test Case]
+ Run "sudo ua attach":
+ $ sudo ua attach
+ Email: andreas at canonical.com
+ Password:
+ Second-factor auth: nnnnnn
+ This machine is now attached to 'andreas.hasenack at canonical.com'.
+
+ Traceback (most recent call last):
+ File "/usr/bin/ua", line 11, in <module>
+ load_entry_point('ubuntu-advantage-tools==19.2', 'console_scripts', 'ubuntu-advantage')()
+ File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 373, in main
+ return args.action(args, cfg)
+ File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 241, in action_attach
+ action_status(args=None, cfg=cfg)
+ File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 311, in action_status
+ contract_expiry=expiry.date(),
+ AttributeError: 'str' object has no attribute 'date'
+
+ With the fixed package, you should see "n/a" for the "Valid until" header and it should not crash:
+ Email: andreas at canonical.com
+ Password:
+ Second-factor auth: pppppp
+ This machine is now attached to 'andreas.hasenack at canonical.com'.
+
+ Account: andreas.hasenack at canonical.com
+ Subscription: andreas.hasenack at canonical.com
+ Valid until: n/a
+ Technical support level: not included
+ ...
+
+
+ [Regression Potential]
+ The fix is just setting a "n/a" text value to the expiration date in the case one isn't provided, and that is exactly the expected outcome, and what the (already heavily modified) upstream code does.
+ No existing tests were affected by the change, which means it's not covered. Upstream has already changed a lot, and includes a test for this.
+ Finally, the UA offerings are currently not available for non-LTS releases, so there is nothing to regress here. A crash is a bad bug, though, so we do want to get it fixed.
+
+ [Other Info]
+ None at this time.
** Description changed:
- [Impact]
+ [Impact]
Due to a server-side change, an expected key is no longer being sent to the client during an attach operation. This causes the client to backtrace with a KeyError exception:
Traceback (most recent call last):
File "/usr/bin/ua", line 11, in
load_entry_point('ubuntu-advantage-tools==19.2', 'console_scripts', 'ubuntu-advantage')()
File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 371, in main
return args.action(args, cfg)
File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 241, in action_attach
action_status(args=None, cfg=cfg)
File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 295, in action_status
contractInfo['effectiveTo'], '%Y-%m-%dT%H:%M:%SZ')
KeyError: 'effectiveTo'
The client should default to a "no expiration" value in this case.
Upstream already handles this, but the fix is missing for disco and
eoan.
[Test Case]
Run "sudo ua attach":
$ sudo ua attach
Email: andreas at canonical.com
- Password:
+ Password:
Second-factor auth: nnnnnn
This machine is now attached to 'andreas.hasenack at canonical.com'.
Traceback (most recent call last):
- File "/usr/bin/ua", line 11, in <module>
- load_entry_point('ubuntu-advantage-tools==19.2', 'console_scripts', 'ubuntu-advantage')()
- File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 373, in main
- return args.action(args, cfg)
- File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 241, in action_attach
- action_status(args=None, cfg=cfg)
- File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 311, in action_status
- contract_expiry=expiry.date(),
+ File "/usr/bin/ua", line 11, in <module>
+ load_entry_point('ubuntu-advantage-tools==19.2', 'console_scripts', 'ubuntu-advantage')()
+ File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 373, in main
+ return args.action(args, cfg)
+ File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 241, in action_attach
+ action_status(args=None, cfg=cfg)
+ File "/usr/lib/python3/dist-packages/uaclient/cli.py", line 311, in action_status
+ contract_expiry=expiry.date(),
AttributeError: 'str' object has no attribute 'date'
With the fixed package, you should see "n/a" for the "Valid until" header and it should not crash:
Email: andreas at canonical.com
- Password:
+ Password:
Second-factor auth: pppppp
This machine is now attached to 'andreas.hasenack at canonical.com'.
Account: andreas.hasenack at canonical.com
Subscription: andreas.hasenack at canonical.com
Valid until: n/a
Technical support level: not included
...
+ [Regression Potential]
+ The fix is just setting a "n/a" text value to the expiration date in the case one isn't provided, and that is exactly the expected outcome, and what the (already heavily modified) upstream code does.
- [Regression Potential]
- The fix is just setting a "n/a" text value to the expiration date in the case one isn't provided, and that is exactly the expected outcome, and what the (already heavily modified) upstream code does.
- No existing tests were affected by the change, which means it's not covered. Upstream has already changed a lot, and includes a test for this.
- Finally, the UA offerings are currently not available for non-LTS releases, so there is nothing to regress here. A crash is a bad bug, though, so we do want to get it fixed.
+ No existing tests were affected by the change, which means it's not
+ covered.
+
+ Finally, the UA offerings are currently not available for non-LTS
+ releases, so there is nothing to regress here. A crash is a bad bug,
+ though, so we do want to get it fixed.
[Other Info]
None at this time.
--
You received this bug notification because you are a member of Ubuntu
Server, which is subscribed to ubuntu-advantage-tools in Ubuntu.
https://bugs.launchpad.net/bugs/1829788
Title:
backtrace on attach: KeyError: 'effectiveTo'
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-advantage-script/+bug/1829788/+subscriptions
More information about the Ubuntu-server-bugs
mailing list