Skip to content

cloud-init does not respect declared MIME types in multipart archives #3764

@ubuntu-server-builder

Description

@ubuntu-server-builder

This bug was originally filed in Launchpad as LP: #1888822

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = 2020-08-25T19:31:59.685827+00:00
date_created = 2020-07-24T09:49:15.112105+00:00
date_fix_committed = 2020-08-25T19:31:59.685827+00:00
date_fix_released = 2020-08-25T19:31:59.685827+00:00
id = 1888822
importance = critical
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1888822
milestone = None
owner = rcvanvo
owner_name = Robert Van Voorhees
private = False
status = fix_released
submitter = rcvanvo
submitter_name = Robert Van Voorhees
tags = []
duplicates = []

Launchpad user Robert Van Voorhees(rcvanvo) wrote on 2020-07-24T09:49:15.112105+00:00

In #290 we landed a change to user-data processing which expanded the set of MIME types we would consider signifying "unknown content" to include many (if not all) of the MIME types we would normally expect to be used in user-data multipart archives[0].

This means that every part is now assigned its MIME type based on the first line of its content; the declared MIME types are ignored.

In the specific reported case, a "text/cloud-boothook" part started with #!, which is appropriate and correct, but was therefore detected as "text/x-shellscript" due to this bug.

[0] Specifically, it was expanded to include all the values in the dict at https://github.com/canonical/cloud-init/blob/master/cloudinit/handlers/__init__.py#L43-L54

[Original Report]

In the upstream Kubernetes project Cluster API, specifically the Cluster API AWS Provider, it will download a file securely from AWS Secrets Manager in the cloud-init script, save that file to a well known location, and then restart the cloud-init service through systemd. After the cloud-init script is restarted, it will resolve the secrets file (that had previously not been there) and execute its commands.

This worked fine on versions of cloud-init up until 19.4-33-gbb4131a2-0ubuntu118.04.1. Once upgrading to 20.2-45-g5f7825e2-0ubuntu118.04.1 the secrets file is never resolved again.

Some other information:

  • cloud-init is definitely successfully running twice based on systemd and cloud-init-output.
  • The /var/lib/cloud/instance/user-data.txt does show the reference to the well-known file at /etc/secret-userdata.txt
  • The "resolved" version of user-data at /var/lib/cloud/instance/user-data.txt.i does not include the resolved file. Deleting this file and then restarted cloud-init does not solve the problem, as the file resolves again without it.

Is there another command that is now required if you plan on restarting cloud-init for another execution where files are now present that were previously not?

  1. Cloud Provider: AWS
  2. Upstream issue: cloud-init v20.2-45-g5f7825e2-0ubuntu1~18.04.1 never runs /etc/secret-userdata.txt kubernetes-sigs/cluster-api-provider-aws#1839 Instructions to recreate can be found in that issue including 2 public AMIs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions