summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorBrett Holman <bpholman5@gmail.com>2021-10-07 14:08:13 -0600
committerGitHub <noreply@github.com>2021-10-07 15:08:13 -0500
commit725a7f7f19eb39b472e1f24b447fc9a596bf1748 (patch)
tree0fdb2a30b27a7ad06c13b24e8403f6f267d18f5b /cloudinit/config
parentfd595774f64f22384ec9229bde176df5cb2fd4c6 (diff)
downloadvyos-cloud-init-725a7f7f19eb39b472e1f24b447fc9a596bf1748.tar.gz
vyos-cloud-init-725a7f7f19eb39b472e1f24b447fc9a596bf1748.zip
Allow comments in runcmd and report failed commands correctly (#1049)
Allow comments in runcmd and report failed commands correctly A `runcmd` script may fail to parse properly, but does not mark `runcmd` as failed when that occurs. Additionally `shellify()` fails to correctly parse scripts that contain a comment line. Rectify both issues and add unit tests to verify correct behavior. LP: #1853146
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_runcmd.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/cloudinit/config/cc_runcmd.py b/cloudinit/config/cc_runcmd.py
index 1f75d6c5..15960c7d 100644
--- a/cloudinit/config/cc_runcmd.py
+++ b/cloudinit/config/cc_runcmd.py
@@ -65,7 +65,8 @@ schema = {
'items': {
'oneOf': [
{'type': 'array', 'items': {'type': 'string'}},
- {'type': 'string'}]
+ {'type': 'string'},
+ {'type': 'null'}]
},
'additionalItems': False, # Reject items of non-string non-list
'additionalProperties': False,
@@ -90,7 +91,7 @@ def handle(name, cfg, cloud, log, _args):
try:
content = util.shellify(cmd)
util.write_file(out_fn, content, 0o700)
- except Exception:
- util.logexc(log, "Failed to shellify %s into file %s", cmd, out_fn)
+ except Exception as e:
+ raise type(e)('Failed to shellify {} into file {}'.format(cmd, out_fn))
# vi: ts=4 expandtab