Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid runcmd script format makes it ignored without marking cloud init as failed #3498

Closed
ubuntu-server-builder opened this issue May 12, 2023 · 2 comments
Labels
launchpad Migrated from Launchpad

Comments

@ubuntu-server-builder
Copy link
Collaborator

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

Launchpad details
affected_projects = []
assignee = holmanb
assignee_name = Brett Holman
date_closed = 2021-11-02T19:54:14.283020+00:00
date_created = 2019-11-19T12:42:40.250969+00:00
date_fix_committed = 2021-10-07T20:12:46.459572+00:00
date_fix_released = 2021-11-02T19:54:14.283020+00:00
id = 1853146
importance = medium
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1853146
milestone = None
owner = boillodmanuel
owner_name = manuel
private = False
status = fix_released
submitter = boillodmanuel
submitter_name = manuel
tags = []
duplicates = []

Launchpad user manuel(boillodmanuel) wrote on 2019-11-19T12:42:40.250969+00:00

Info :

  • cloud-init version /usr/bin/cloud-init 19.2-36-g059d049c-0ubuntu2~16.04.1

Issue:

If user-data script contains a malformed runcmd script, cloud-init fails to parse it but do not mark cloud-init as failed.

Example:

runcmd:
- echo "begin runcmd"
- # empty
- echo "end"

The second line is empty, and causes the following warning in /var/log/cloud-init.log:

2019-11-19 12:39:10,124 - helpers.py[DEBUG]: Running config-runcmd using lock (<FileLock using file '/var/lib/cloud/instances/0B44BE6F-81FA-FF44-AB96-A0D9AB8B7171/sem/config_runcmd'>)
2019-11-19 12:39:10,124 - schema.py[DEBUG]: Ignoring schema validation. python-jsonschema is not present
2019-11-19 12:39:10,124 - util.py[WARNING]: Failed to shellify ['echo "begin runcmd"', None, 'echo "end"'] into file /var/lib/cloud/instances/0B44BE6F-81FA-FF44-AB96-A0D9AB8B7171/scripts/runcmd
2019-11-19 12:39:10,124 - util.py[DEBUG]: Failed to shellify ['echo "begin runcmd"', None, 'echo "end"'] into file /var/lib/cloud/instances/0B44BE6F-81FA-FF44-AB96-A0D9AB8B7171/scripts/runcmd
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_runcmd.py", line 91, in handle
    content = util.shellify(cmd)
  File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 2117, in shellify
    "Got: %s" % (type_utils.obj_name(args), args))
TypeError: Unable to shellify type 'NoneType'. Expected list, string, tuple. Got: None
2019-11-19 12:39:10,154 - handlers.py[DEBUG]: finish: modules-config/config-runcmd: SUCCESS: config-runcmd ran successfully

There is no error log in /var/log/cloud-init-output.log

But cloud-init status is "done"

I expect the status to be "error"

@ubuntu-server-builder ubuntu-server-builder added the launchpad Migrated from Launchpad label May 12, 2023
@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Ryan Harper(raharper) wrote on 2019-11-20T21:58:36.505217+00:00

Thanks for filing the bug.

As it turns out, this results in a null entry in the list, which cloud-init fails to "shellify" when rendering this list of commands to a shell script. This results in not writing any of the commands which is why you don't see an failure in the module status.

That's clearly a bug; so we'll need to make a change so that
we handle null or other entries where shellify fails as errors and log them.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user James Falcon(falcojr) wrote on 2021-11-02T19:54:15.122296+00:00

This bug is believed to be fixed in cloud-init in version 21.4. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
launchpad Migrated from Launchpad
Projects
None yet
Development

No branches or pull requests

1 participant