Closed ubuntu-server-builder closed 1 year ago
Launchpad user Paride Legovini(paride) wrote on 2021-02-05T13:47:41.883894+00:00
Hello Andrew and thanks for this bug report. It is not easy for us to debug on the moving target like the latest git commit. Could you please git checkout 20.4.1
and try again? That's the git tag of the latest released version of cloud-init, which was extensively tested before being released. Hopefully it's new enough to ship the feature/bugfix you're missing from 20.2.
If the problem still happens with 20.4.1, could you please try to git checkout 20.2
and try to reproduce the problem there? If you still hit the failure then I'd suspect there's a local configuration/setup issue, as you reported the Debian packaged version of cloud-init 20.2 works fine.
If you can confirm this really looks like a bug in 20.4.1, please run
cloud-init collect-logs
right after hitting the issue, and attach the resulting tarball to this bug report, we'll try to understand what's happening there.
Waiting for you reply I'm setting the status of this bug report to Incomplete; please set it back to New after commenting back and we'll look at it again. Thanks!
Launchpad user Andrew Bogott(andrewbogott) wrote on 2021-02-08T03:19:45.311881+00:00
I am able to reproduce the issue on 20.4.1. I get good runs in 20.2.
A bisect shows:
root@cloudinit:/home/labtestandrew/cloud-init# git bisect good ef041fd822a2cf3a4022525e942ce988b1f95180 is the first bad commit commit ef041fd822a2cf3a4022525e942ce988b1f95180 Author: Ryan Harper ryan.harper@canonical.com Date: Fri Aug 14 12:51:54 2020 -0500
user-data: only verify mime-types for TYPE_NEEDED and x-shellscript (#511)
Commit d00126c167fc06d913d99cfc184bf3402cb8cf53 regressed cloud-init
handling in multipart MIME user-data. Specifically, cloud-init would
examine the payload of the MIME part to determine what the content
type and subsequently which handler to use. This meant that user-data
which had shellscript payloads (starts with #!) were always handled
as shellscripts, rather than their declared MIME type and affected
when the payload was handled.
One failing scenario was a MIME part with text/cloud-boothook type
declared and a shellscript payload. This was run at shellscript
processing time rather than boothook time resulting in an change in
behavior from previous cloud-init releases.
To continue to support known scenarios where clouds have specifed
a MIME type of text/x-shellscript but provided a payload of something
other than shellscripts, we're changing the lookup logic to check for
the TYPES_NEEDED (text/plain, text/x-not-multipart) and only
text/x-shellscript.
It is safe to check text/x-shellscript parts as all shellscripts must
include the #! marker and will be detected as text/x-shellscript types.
If the content is missing the #! marker, it will not be excuted. If
the content is detected as something cloud-init supports, such as
#cloud-config the appropriate cloud-init handler will be used.
This change will fix hanldling for parts which were shellscripts but
ran with the wrong handler due to ignoring of the provided mime-type.
LP: #1888822
Launchpad user Andrew Bogott(andrewbogott) wrote on 2021-02-08T03:20:58.816409+00:00
collect-logs fails in my current setup; I can investigate that further when I get a chance.
Note that https://bugs.launchpad.net/cloud-init/+bug/1795933 seems to be a duplicate of this issue, suggesting that the problem is present in released versions :(
Launchpad user Dan Watkins(oddbloke) wrote on 2021-02-09T15:04:35.475315+00:00
collect-logs failing suggests to me that you may have a misconfigured system, rather than this being a cloud-init bug per se. Can you manually paste cloud-init.log from an affected system (and/or the collect-logs issue you're seeing)?
(https://bugs.launchpad.net/cloud-init/+bug/1795933 was filed in 2018, well before any of the referenced commits, and is in reference to an older version of Jinja, 2.2.1. The oldest version in Debian, in oldoldstable, is 2.7.3, so I suspect this is a separate issue.)
Launchpad user Andrew Bogott(andrewbogott) wrote on 2021-02-12T01:10:46.571817+00:00
Thanks for your comments, all! A colleague and I worked on this some yesterday and I think I understand what's happening now.
The change in behavior relates to the interaction between mime-types and the #headings for a given part. In my particular use, the section looks like this:
--XXXXboundary text
MIME-Version: 1.0
Content-Type: text/cloud-config; charset="us-ascii"
## template: jinja
#cloud-config
Prior to ef041fd822a2cf3a4022525e942ce988b1f95180, that section was scanned by find_ctype() and identified as a jinja2 template. After that patch, the call to find_ctype() is bypassed and, hence, the jinja2 template rendering is skipped.
If I change this block to Content-Type: text/plain or to text/jinja2, the jinja is rendered as expected.
It would almost certainly be harmless to add text/cloud-config as one of the types that gets passed to find_ctype() but it might not be worth the change since I doubt you have a lot of users out there using the same weird combination of types and tags that I was using. If you want to close this as 'invalid' I won't object.
Thanks again!
Launchpad user Andrew Bogott(andrewbogott) wrote on 2021-03-24T19:59:39.074295+00:00
Update: I've now learned that text/plain and text/jinja2 don't work in the version of cloud-init shipped with Debian Stretch (7.9.2). So in order to have a config work in both old and new versions we need to support text/cloud-config. I will submit a patch for that shortly.
Launchpad user Launchpad Janitor(janitor) wrote on 2021-05-24T04:17:23.862720+00:00
[Expired for cloud-init because there has been no activity for 60 days.]
This bug was originally filed in Launchpad as LP: #1914641
Launchpad details
Launchpad user Andrew Bogott(andrewbogott) wrote on 2021-02-04T18:15:47.506838+00:00
I use jinja templating for vendor data; it works with my .deb packaged version of cloud-init, 20.2-2~deb10u1
Testing with the latest git checkout, I see a json parser chocking on curly braces. That suggests that it's skipping the jinja rendering step, or trying to run it after json parsing, which won't work.
Here is the top part of my vendor data:
And here are the errors: