yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #89114
[Bug 1977952] Re: In 22.2 cloud-init fails when phone-home module does not have "tries" parameter
This bug was fixed in the package cloud-init - 22.2-0ubuntu1~20.04.2
---------------
cloud-init (22.2-0ubuntu1~20.04.2) focal; urgency=medium
* cherry-pick a2e62738: Fix cc_phone_home requiring 'tries' (#1500)
(LP: #1977952)
-- James Falcon <james.falcon@xxxxxxxxxxxxx> Thu, 09 Jun 2022 16:53:07
-0500
** Changed in: cloud-init (Ubuntu Bionic)
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1977952
Title:
In 22.2 cloud-init fails when phone-home module does not have "tries"
parameter
Status in cloud-init:
Fix Committed
Status in cloud-init package in Ubuntu:
Fix Committed
Status in cloud-init source package in Bionic:
Fix Released
Status in cloud-init source package in Focal:
Fix Released
Status in cloud-init source package in Impish:
Fix Released
Status in cloud-init source package in Jammy:
Fix Released
Bug description:
=== Begin SRU Template ===
[Impact]
The cloud-init "phone home" module contains an optional "tries" parameter. In release 22.2, this was accidentally changed to become mandatory. Any previously working cloud-config that didn't contain the "tries" parameter will now cause the module exit with exception. This happened because an overly broad exception handler for converting the 'tries' string to an int was changed to only raise on ValueError. However, if None (or any other non-string) is passed, a TypeError is raised, and this needs to be caught as well.
[Test Case]
1. Launch an Ubuntu instance on any cloud-init supported platform with the following userdata:
#cloud-config
phone_home:
url: http://192.168.1.1
post: all
2. By inspecting /var/log/cloud-init.log, ensure the phone home module attempts to make a web request, with the following log:
url_helper.py[DEBUG]: [0/10] open 'http://192.168.1.1' with {'url': 'http://192.168.1.1', 'allow_redirects': True, 'method': 'POST', 'headers': {'User-Agent': 'Cloud-Init/22.2'}} configuration
[Regression Potential]
The parsing exceptions being caught should now be broad enough to handle any configuration we receive, but if not, we would still exit the module with exception.
[Other Info]
Github PR: https://github.com/canonical/cloud-init/pull/1500
=== End SRU Template ===
Initial bug:
Hi!
We have some user-data files where we use the phone-home module of cloud-init.
So far we did not use it's "tries" parameter and everything worked.
However now in version 22.2 there was a change which causes cloud-init to fail.
https://github.com/canonical/cloud-init/compare/22.1...22.2#diff-a4aa83fbb946ba1ea7cf6c8dd5965cd62631dc9cb48d4baa50adddbfef06b82cL108
In our case this change in the exception handling throws a TypeError,
instead of the ValueError that is excepted:
File "/usr/lib/python3/dist-packages/cloudinit/config/cc_phone_home.py", line 132, in handle
tries = int(tries) # type: ignore
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
While we can add the "tries" parameter (and after that everything works just like before),
this exception should be handled properly.
Also according to guidelines:
1. Tell us your cloud provider
None
2. Any appropriate cloud-init configuration you can provide us
phone-home module
3. Perform the following on the system and attach it to this bug:
no logs are necessary
Best regards:
Zsolt
To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1977952/+subscriptions
References