rancher / os

Tiny Linux distro that runs the entire OS as Docker containers
https://rancher.com/docs/os/v1.x/en/
Apache License 2.0
6.45k stars 659 forks source link

use configdrive #2932

Open axi92 opened 4 years ago

axi92 commented 4 years ago

RancherOS Version: 1.5.4 Where are you running RancherOS? baremetal

I have 2 usb sticks. The first with the rancher os iso and another with the cloud config file system that looks like this: openstack/latest/user_data https://coreos.com/os/docs/latest/cloud-config-locations.html with the content:

#cloud-config
rancher:
write_files:
  - path: /etc/rc.local
    permissions: "0755"
    owner: root
    content: |
      #!/bin/bash
      wait-for-docker
      if ! blkid | grep -q "RANCHER_STATE"; then
        echo "I am working!"
      fi

The config drive stick is formatet with: mkfs.vfat -n config-2 -I /dev/sdc

Edit: I got this line in my boot log: https://github.com/rancher/os/blob/master/pkg/init/cloudinit/cloudinit.go#L49 and blkid does not show my usb drive.

Am I right that rancher os should automatically mount the config-2 drive because of this https://github.com/rancher/os/blob/master/os-config.tpl.yml#L86 ?

My target is to setup a baremetal machine without any display or keyboard just with 2 usb sticks one iso and the second the config.

Edit2: when I use blkid i just see the local disk where i already installed rancheros with the label "RANCHER_STATE" but I am not using that one, I booted from sdc label"RancherOS" what only will show after I did sudo blkid then I see all of them and on my configdrive the sdb the label is not present. After I did once sudo blkid it works also without sudo! The output is like this:

/dev/sdb1: UUID="2019-08-22-07-33-27-00" LABEL="RancherOS" TYPE="osp9660" PTUUID="2f6cb907" PTTYPE="dos" PARTUUID="2f6cb907-01"
/dev/sdc: LABEL="config-2" UUID="A458-9D90" TYPE="vfat"
axi92 commented 4 years ago

Is it possible that rancheros is not able to detect the filesystem because the permissions are missing? When rancheros is done booting into ram blkid does not show any external devices only the internal disc is shown. Just when I use sudo all the usb devices are shown.

Could that be the cause that I get this on boot: Configdrive was enabled but has no configdrive device or filesystem, ignore cloudinit

Steps to reproduce:

  1. Prepare USB stick A with rancheros.iso
  2. Prepare USB stick B with vfat and openstack/latest/user_data
  3. Boot from USB A
  4. Type blkid
  5. Output is:
    [rancher@rancher ~]$ blkid
    /dev/sda: UUID="a219bda2-3be8-4c40-8246-376ebd6f9f63" TYPE="ext4"
  6. Type sudo blkid
  7. Output is:
    /dev/sda: UUID="a219bda2-3be8-4c40-8246-376ebd6f9f63" TYPE="ext4"
    /dev/sdb1: UUID="2019-08-22-07-33-27-00" LABEL="RancherOS" TYPE="iso9660" PTUUID="2f6cb907" PTTYPE="dos" PARTUUID="2f6cb907-01"
    /dev/sdc: UUID="2019-11-28-14-18-27-00" LABEL="config-2" TYPE="iso9660"
etrexel commented 4 years ago

Was reading through the code that triggers before the log you said you get. It calls this function to resolve the device: https://github.com/rancher/os/blob/88c5b5ef14caf5739b1763d6ea8c82cd8ee9d885/pkg/util/cutil.go#L18 Which happens to state that it is less reliable than blkid -h. Not sure if that is the problem, but that line indicates that your device is not found. May be worth investigating the function that they use to find the device.