From b2f4dd30a935ef5803cfa5992f9887ddd5e96ff7 Mon Sep 17 00:00:00 2001 From: Kurt Garloff Date: Thu, 5 Mar 2020 10:40:58 +0100 Subject: [PATCH 1/5] tolerate more mime types for cc part of user-data. Some cloud environments pass multipart user-data as text/x-shellscript. (I have observed this from old heat on OTC.) We need to make sure that it is accepted by cloud-init as user-data. Note that more intelligent logic might pass it correctly as text/x-yaml which cloud-init should tolerate as well. Signed-off-by: Kurt Garloff --- cloudinit/user_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudinit/user_data.py b/cloudinit/user_data.py index 6f41b03a19b..416f5321c49 100644 --- a/cloudinit/user_data.py +++ b/cloudinit/user_data.py @@ -30,7 +30,7 @@ CONTENT_TYPE = 'Content-Type' # Various special content types that cause special actions -TYPE_NEEDED = ["text/plain", "text/x-not-multipart"] +TYPE_NEEDED = ["text/plain", "text/x-not-multipart", "text/x-shellscript", "text/x-yaml"] INCLUDE_TYPES = ['text/x-include-url', 'text/x-include-once-url'] ARCHIVE_TYPES = ["text/cloud-config-archive"] UNDEF_TYPE = "text/plain" From 1f476de19781a13fa93c6d4cd78b167a6b04d736 Mon Sep 17 00:00:00 2001 From: Kurt Garloff Date: Thu, 5 Mar 2020 11:17:51 +0100 Subject: [PATCH 2/5] Avoid violating pycodestyle violation. It insists on ancient narrow terminals, so adjust ... --- cloudinit/user_data.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloudinit/user_data.py b/cloudinit/user_data.py index 416f5321c49..34cec96ddcf 100644 --- a/cloudinit/user_data.py +++ b/cloudinit/user_data.py @@ -30,7 +30,8 @@ CONTENT_TYPE = 'Content-Type' # Various special content types that cause special actions -TYPE_NEEDED = ["text/plain", "text/x-not-multipart", "text/x-shellscript", "text/x-yaml"] +TYPE_NEEDED = ["text/plain", "text/x-not-multipart", + "text/x-shellscript", "text/x-yaml"] INCLUDE_TYPES = ['text/x-include-url', 'text/x-include-once-url'] ARCHIVE_TYPES = ["text/cloud-config-archive"] UNDEF_TYPE = "text/plain" From 70ddf9642b644eed42c3ee8c377c22eccc82e78a Mon Sep 17 00:00:00 2001 From: Kurt Garloff Date: Thu, 26 Mar 2020 22:29:37 +0000 Subject: [PATCH 3/5] Revert "Avoid violating pycodestyle violation." This reverts commit 1f476de19781a13fa93c6d4cd78b167a6b04d736. --- cloudinit/user_data.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cloudinit/user_data.py b/cloudinit/user_data.py index 34cec96ddcf..416f5321c49 100644 --- a/cloudinit/user_data.py +++ b/cloudinit/user_data.py @@ -30,8 +30,7 @@ CONTENT_TYPE = 'Content-Type' # Various special content types that cause special actions -TYPE_NEEDED = ["text/plain", "text/x-not-multipart", - "text/x-shellscript", "text/x-yaml"] +TYPE_NEEDED = ["text/plain", "text/x-not-multipart", "text/x-shellscript", "text/x-yaml"] INCLUDE_TYPES = ['text/x-include-url', 'text/x-include-once-url'] ARCHIVE_TYPES = ["text/cloud-config-archive"] UNDEF_TYPE = "text/plain" From 71686578c41ec00f85fb2c796dfcd1d3098694bc Mon Sep 17 00:00:00 2001 From: Kurt Garloff Date: Thu, 26 Mar 2020 22:29:41 +0000 Subject: [PATCH 4/5] Revert "tolerate more mime types for cc part of user-data." This reverts commit b2f4dd30a935ef5803cfa5992f9887ddd5e96ff7. --- cloudinit/user_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudinit/user_data.py b/cloudinit/user_data.py index 416f5321c49..6f41b03a19b 100644 --- a/cloudinit/user_data.py +++ b/cloudinit/user_data.py @@ -30,7 +30,7 @@ CONTENT_TYPE = 'Content-Type' # Various special content types that cause special actions -TYPE_NEEDED = ["text/plain", "text/x-not-multipart", "text/x-shellscript", "text/x-yaml"] +TYPE_NEEDED = ["text/plain", "text/x-not-multipart"] INCLUDE_TYPES = ['text/x-include-url', 'text/x-include-once-url'] ARCHIVE_TYPES = ["text/cloud-config-archive"] UNDEF_TYPE = "text/plain" From 35a6030573089dc9e360fe4fe6a618b216fb8cf7 Mon Sep 17 00:00:00 2001 From: Kurt Garloff Date: Fri, 27 Mar 2020 13:28:20 +0000 Subject: [PATCH 5/5] Fix cloud-init ignoring some mimetypes in user-data. This patch if from Ryan Harper (inspired by my bug report and a suggestion from Scott Moser) from the discussion on PR #234. cloud-init would not accept unexpected mime-types in multipart user-data for the cloud-config piece before; now it does. Problem was observed and reproduced with old heat on OTC and is now fixed. Signed-off-by: Kurt Garloff --- cloudinit/user_data.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cloudinit/user_data.py b/cloudinit/user_data.py index 6f41b03a19b..670dbee6960 100644 --- a/cloudinit/user_data.py +++ b/cloudinit/user_data.py @@ -25,6 +25,7 @@ NOT_MULTIPART_TYPE = handlers.NOT_MULTIPART_TYPE PART_FN_TPL = handlers.PART_FN_TPL OCTET_TYPE = handlers.OCTET_TYPE +INCLUDE_MAP = handlers.INCLUSION_TYPES_MAP # Saves typing errors CONTENT_TYPE = 'Content-Type' @@ -115,7 +116,8 @@ def find_ctype(payload): # Attempt to figure out the payloads content-type if not ctype_orig: ctype_orig = UNDEF_TYPE - if ctype_orig in TYPE_NEEDED: + if ctype_orig in TYPE_NEEDED or (ctype_orig in + INCLUDE_MAP.values()): ctype = find_ctype(payload) if ctype is None: ctype = ctype_orig