Invalid write_files format doesn't make the cloud-init fail

Bug #1867933 reported by manuel
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Medium
Unassigned

Bug Description

If the cloud config file format is not correct (see example below), the write_files module fails, but the cloud-init status is done

Cloud-config file:

```
#cloud-config

write_files:
  - content: |
      line below is badly indented
ouch!

    path: /tmp/cloud-init-file.txt
```

Extract of cloud-init-output.log
```
2020-03-18 13:54:05,321 - util.py[WARNING]: Failed loading yaml blob. Invalid format at line 6 column 1: "while scanning a simple key
  in "<unicode string>", line 6, column 1:
    ouch!
    ^
could not found expected ':'
  in "<unicode string>", line 8, column 9:
        path: /tmp/cloud-init-file.txt
            ^"
2020-03-18 13:54:05,337 - util.py[WARNING]: Failed loading yaml blob. Invalid format at line 6 column 1: "while scanning a simple key
  in "<unicode string>", line 6, column 1:
    ouch!
    ^
could not found expected ':'
  in "<unicode string>", line 8, column 9:
        path: /tmp/cloud-init-file.txt
            ^"
2020-03-18 13:54:05,337 - util.py[WARNING]: Failed at merging in cloud config part from part-001
```

cloud-init status:
```
status: done
```

Scott Moser (smoser)
Changed in cloud-init:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Scott Moser (smoser) wrote :

reproduces with:

$ cat ud.yaml
#cloud-config
runcmd:
- "echo hi world | tee /run/runcmd.log"
 - "echo this is indented one space more, making bad yaml"

$ ud=$(cat ud.yaml)
$ lxc launch ubuntu-daily:bionic btest --config=user.user-data="$ud"

$ lxc exec btest -- cloud-init status --wait ; echo $?
status: done
0

$ lxc exec btest /bin/bash
root@btest:~# grep WARN /var/log/cloud-init.log
2020-03-18 15:31:29,490 - util.py[WARNING]: Failed loading yaml blob. Invalid format at line 2 column 1: "while parsing a block mapping
2020-03-18 15:31:29,499 - util.py[WARNING]: Failed loading yaml blob. Invalid format at line 2 column 1: "while parsing a block mapping
2020-03-18 15:31:29,499 - util.py[WARNING]: Failed at merging in cloud config part from part-001
root@btest:~# grep errors /run/cloud-init/result.json
  "errors": []
root@btest:~# grep errors /run/cloud-init/status.json
   "errors": [],
   "errors": [],
   "errors": [],
   "errors": [],
   "errors": [],

Revision history for this message
Scott Moser (smoser) wrote :

Just verified this is still present (focal)
# cloud-init --version
/usr/bin/cloud-init 20.2-45-g5f7825e2-0ubuntu1~20.04.1

Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Confirmed → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.