canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
2.93k stars 874 forks source link

init rc script not working properly at first boot #3130

Closed ubuntu-server-builder closed 1 year ago

ubuntu-server-builder commented 1 year ago

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

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = 2018-06-17T04:17:31.164048+00:00
date_created = 2018-03-02T05:23:56.027018+00:00
date_fix_committed = None
date_fix_released = None
id = 1752789
importance = undecided
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1752789
milestone = None
owner = wnsgh611
owner_name = KIM JUNHO
private = False
status = expired
submitter = wnsgh611
submitter_name = KIM JUNHO
tags = []
duplicates = []

Launchpad user KIM JUNHO(wnsgh611) wrote on 2018-03-02T05:23:56.027018+00:00

Hi, I'm newbie on cloud-init. I used qemu-system-x86_64 using kvm and cloud-init for provisioning ubuntu-cloud-image. I want to file system mount using 9p file system. If I want to use it, I need to put my path on the qemu starting command like '-fsdev .. something like that' and in the virtual machine, I need to mount using 9p type file system using mount command. So, I choose using ubuntu run-level script which is writing script on the init.d and use update-rc.d command. When I tried to normal script file such as 'touch /blah/blah', it worked properly.

Also, it wrote successfully into file, and execute that script, it works (which means that it can attach 9p-filesystem, just it does not work on first time boot).

However, when I tried to attach 9p-file system. It does not working. When I reboot the instance, it successfully attched the file system. So, I reasonably consider that cloud-init cannot working properly before boot. Rest of this issue detail is the detail I follow the guideline.

Many thanks :)

  1. Tell us your cloud provider

-> Ubuntu 16.04 cloud xenial-amd64 img

  1. Any appropriate cloud-init configuration you can provide us

Content-Type: multipart/mixed; boundary="==BOUNDARY==" MIME-Version: 1.0

--==BOUNDARY== MIME-Version: 1.0 Content-Type: text/cloud-config; charset="us-ascii"

cloud-config

users:

runcmd:

merge_type: 'list(append)+dict(recurse_array,no_replace)+str()'

--==BOUNDARY==--

  1. Perform the following on the system and attach it to this bug:

Run: cloud-init collect

If your cloud-init does not have that sub command, then please collect: dmesg > dmesg.txt journalctl -o short-precise > journal.txt tar -cvf cloud-init.tar dmesg.txt journal.txt /var/log/cloud-init.log /var/log/cloud-init-output.log /run/cloud-init

  1. attach cloud-init.tar to this bug. If you feel that there may be sensitive data involved, consider re-creating on a new instance that has no sensitive data.

======== I attached as a file.

I masked some string for sensitive data. But, it does not matter for watch you log.

ubuntu-server-builder commented 1 year ago

Launchpad user KIM JUNHO(wnsgh611) wrote on 2018-03-02T05:23:56.027018+00:00

Launchpad attachments: I followed step 3 and 4

ubuntu-server-builder commented 1 year ago

Launchpad user Scott Moser(smoser) wrote on 2018-03-08T22:27:13.369863+00:00

Hi, Without looking much further I suspect you're right in that your attempts to insert the rc service do not work on the "current" boot.

You can run earlier in boot with 'bootcmd' rathre than 'runcmd', but I suspect even then your inserting of rc jobs will be too late.

I suggest just inserting the jobs as you are, and then "manually" starting them in a runcmd entry.

Please let me know if you think there is something that cloud-init could reasonably do here to support this issue, and then set the state back to New.

Scott

ubuntu-server-builder commented 1 year ago

Launchpad user KIM JUNHO(wnsgh611) wrote on 2018-04-17T12:55:35.204175+00:00

Hi,

I read your answer and understood that cloud-init does not support rc module in current version.

So, if there is a chance, how about supporting rc-script module in cloud-init? If run-level script formats are different from linux-distribution, it would be hard to implement, but most of them have similar format.

ubuntu-server-builder commented 1 year ago

Launchpad user Scott Moser(smoser) wrote on 2018-04-17T14:51:24.678550+00:00

while cloud-init is in a position that it could provide a layer of indirection between multiple init systems, we're not really interested in doing so at this point.

I wouldn't be opposed to accepting patches that implemented a way to insert sysvinit jobs and make sure they started (if the system was sysvinit).
That is not likely to make our teams development roadmap, but you're free to work on it and contribute. We do have a similar function for upstart jobs.

I suspect that what you are doing is close to working, and would proably "just work" on reboot.

So what I'm suggesting you do is add to your runcmd:

ubuntu-server-builder commented 1 year ago

Launchpad user Launchpad Janitor(janitor) wrote on 2018-06-17T04:17:31.018160+00:00

[Expired for cloud-init because there has been no activity for 60 days.]