diff --git a/cmd/cloudinitexecute/cloudinitexecute.go b/cmd/cloudinitexecute/cloudinitexecute.go index a151602a..f77a0412 100644 --- a/cmd/cloudinitexecute/cloudinitexecute.go +++ b/cmd/cloudinitexecute/cloudinitexecute.go @@ -125,11 +125,15 @@ func WriteFiles(cfg *rancherConfig.CloudConfig, container string) { } func applyPreConsole(cfg *rancherConfig.CloudConfig) { - if _, err := os.Stat(resizeStamp); os.IsNotExist(err) && cfg.Rancher.ResizeDevice != "" { - if err := resizeDevice(cfg); err == nil { - os.Create(resizeStamp) + if cfg.Rancher.ResizeDevice != "" { + if _, err := os.Stat(resizeStamp); os.IsNotExist(err) { + if err := resizeDevice(cfg); err == nil { + os.Create(resizeStamp) + } else { + log.Errorf("Failed to resize %s: %s", cfg.Rancher.ResizeDevice, err) + } } else { - log.Errorf("Failed to resize %s: %s", cfg.Rancher.ResizeDevice, err) + log.Infof("Skipped resizing %s because %s exists", cfg.Rancher.ResizeDevice, resizeStamp) } } diff --git a/cmd/cloudinitsave/cloudinitsave.go b/cmd/cloudinitsave/cloudinitsave.go index 1ba7c152..327e2a36 100755 --- a/cmd/cloudinitsave/cloudinitsave.go +++ b/cmd/cloudinitsave/cloudinitsave.go @@ -72,7 +72,7 @@ func saveCloudConfig() error { network.ApplyNetworkConfig(cfg) log.Debugf("datasources that will be consided: %#v", cfg.Rancher.CloudInit.Datasources) - dss := getDatasources(cfg) + dss := getDatasources(cfg.Rancher.CloudInit.Datasources) if len(dss) == 0 { log.Errorf("currentDatasource - none found") return nil @@ -216,10 +216,10 @@ func fetchAndSave(ds datasource.Datasource) error { // getDatasources creates a slice of possible Datasources for cloudinit based // on the different source command-line flags. -func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource { +func getDatasources(datasources []string) []datasource.Datasource { dss := make([]datasource.Datasource, 0, 5) - for _, ds := range cfg.Rancher.CloudInit.Datasources { + for _, ds := range datasources { parts := strings.SplitN(ds, ":", 2) root := "" @@ -228,6 +228,8 @@ func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource { } switch parts[0] { + case "*": + dss = append(dss, getDatasources([]string{"configdrive", "ec2", "digitalocean", "packet", "gce"})...) case "ec2": dss = append(dss, ec2.NewDatasource(root)) case "file": @@ -243,9 +245,10 @@ func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource { dss = append(dss, proccmdline.NewDatasource()) } case "configdrive": - if root != "" { - dss = append(dss, configdrive.NewDatasource(root)) + if root == "" { + root = "/media/config-2" } + dss = append(dss, configdrive.NewDatasource(root)) case "digitalocean": // TODO: should we enableDoLinkLocal() - to avoid the need for the other kernel/oem options? dss = append(dss, digitalocean.NewDatasource(root)) diff --git a/cmd/control/bootstrap.go b/cmd/control/bootstrap.go index 35f0405f..b069c8a3 100644 --- a/cmd/control/bootstrap.go +++ b/cmd/control/bootstrap.go @@ -45,10 +45,9 @@ func bootstrapAction(c *cli.Context) error { waitForRoot(cfg) } - autoformatDevices := cfg.Rancher.State.Autoformat - log.Debugf("bootstrapAction: Autoformat(%v)", cfg.Rancher.State.Autoformat) - if len(autoformatDevices) > 0 { - if err := autoformat(autoformatDevices); err != nil { + if len(cfg.Rancher.State.Autoformat) > 0 { + log.Infof("bootstrap container: Autoformat(%v) as %s", cfg.Rancher.State.Autoformat, "ext4") + if err := autoformat(cfg.Rancher.State.Autoformat); err != nil { log.Errorf("Failed to run autoformat: %v", err) } } diff --git a/cmd/control/console_init.go b/cmd/control/console_init.go index 392406a8..06a93cc8 100644 --- a/cmd/control/console_init.go +++ b/cmd/control/console_init.go @@ -164,7 +164,7 @@ func generateRespawnConf(cmdline string) string { if strings.Contains(cmdline, fmt.Sprintf("rancher.autologin=%s", tty)) { respawnConf.WriteString(" --autologin rancher") } - respawnConf.WriteString(fmt.Sprintf(" 115200 %s\n", tty)) + respawnConf.WriteString(fmt.Sprintf(" --noclear %s linux\n", tty)) } for _, tty := range []string{"ttyS0", "ttyS1", "ttyS2", "ttyS3", "ttyAMA0"} { @@ -176,7 +176,7 @@ func generateRespawnConf(cmdline string) string { if strings.Contains(cmdline, fmt.Sprintf("rancher.autologin=%s", tty)) { respawnConf.WriteString(" --autologin rancher") } - respawnConf.WriteString(fmt.Sprintf(" 115200 %s\n", tty)) + respawnConf.WriteString(fmt.Sprintf(" %s\n", tty)) } respawnConf.WriteString("/usr/sbin/sshd -D") diff --git a/cmd/control/entrypoint.go b/cmd/control/entrypoint.go index 4d4b9083..fa23b49f 100644 --- a/cmd/control/entrypoint.go +++ b/cmd/control/entrypoint.go @@ -78,19 +78,6 @@ func writeFiles(cfg *config.CloudConfig) error { } func setupCommandSymlinks() { - for _, powerOperation := range []string{ - "/sbin/poweroff", - "/sbin/shutdown", - "/sbin/reboot", - "/sbin/halt", - "/usr/sbin/poweroff", - "/usr/sbin/shutdown", - "/usr/sbin/reboot", - "/usr/sbin/halt", - } { - os.Remove(powerOperation) - } - for _, link := range []symlink{ {config.RosBin, "/usr/bin/cloud-init-execute"}, {config.RosBin, "/usr/bin/cloud-init-save"}, @@ -99,11 +86,16 @@ func setupCommandSymlinks() { {config.RosBin, "/usr/bin/system-docker"}, {config.RosBin, "/usr/sbin/netconf"}, {config.RosBin, "/usr/sbin/wait-for-docker"}, + {config.RosBin, "/usr/sbin/poweroff"}, + {config.RosBin, "/usr/sbin/reboot"}, + {config.RosBin, "/usr/sbin/halt"}, + {config.RosBin, "/usr/sbin/shutdown"}, {config.RosBin, "/sbin/poweroff"}, {config.RosBin, "/sbin/reboot"}, {config.RosBin, "/sbin/halt"}, {config.RosBin, "/sbin/shutdown"}, } { + os.Remove(link.newname) if err := os.Symlink(link.oldname, link.newname); err != nil { log.Error(err) } diff --git a/docs/os/configuration/resizing-device-partition/index.md b/docs/os/configuration/resizing-device-partition/index.md index 428d73e9..92c70660 100644 --- a/docs/os/configuration/resizing-device-partition/index.md +++ b/docs/os/configuration/resizing-device-partition/index.md @@ -7,7 +7,7 @@ layout: os-default ## Resizing a Device Partition --- -The `resize_device` cloud config option can be used to automatically extend the first partition to fill the size of it's device. +The `resize_device` cloud config option can be used to automatically extend the first partition (assuming its `ext4`) to fill the size of it's device. Once the partition has been resized to fill the device, a `/var/lib/rancher/resizefs.done` file will be written to prevent the resize tools from being run again. If you need it to run again, delete that file and reboot. diff --git a/docs/os/running-rancheros/server/pxe/index.md b/docs/os/running-rancheros/server/pxe/index.md index 89b3bd05..12d83c1f 100644 --- a/docs/os/running-rancheros/server/pxe/index.md +++ b/docs/os/running-rancheros/server/pxe/index.md @@ -51,10 +51,10 @@ When this service is run, the `EXTRA_CMDLINE` will be set. Valid cloud-init datasources for RancherOS. | type | default | -|---|---| -| ec2 | DefaultAddress | +|---|---|--| +| ec2 | ec2's DefaultAddress | | file | path | -| cmdline | | +| cmdline | /media/config-2 | | configdrive | | | digitalocean | DefaultAddress | | ec2 | DefaultAddress | @@ -62,6 +62,7 @@ Valid cloud-init datasources for RancherOS. | gce | | | packet | DefaultAddress | | url | url | +| * | This will add ["configdrive", "ec2", "digitalocean", "packet", "gce"] into the list of datasources to try | ### Cloud-Config diff --git a/docs/os/storage/state-partition/index.md b/docs/os/storage/state-partition/index.md index aa81c33c..cacfe7cd 100644 --- a/docs/os/storage/state-partition/index.md +++ b/docs/os/storage/state-partition/index.md @@ -14,16 +14,23 @@ rancher: state: fstype: auto dev: LABEL=RANCHER_STATE - autoformat: - - /dev/sda - - /dev/vda ``` ### Autoformat -You can specify a list of devices to check to format on boot. If the state partition is already found, RancherOS will not try to auto format a partition. By default, auto-formatting is off. +You can specify a list of devices to check to format on boot. If the state partition is already found, RancherOS will not try to auto format a partition. By default, auto-formatting is off. -RancherOS will autoformat the partition to ext4 if the device specified in `autoformat`: +RancherOS will autoformat the partition to `ext4` (_not_ what is set in `fstype`) if the device specified in `autoformat`: * Contains a boot2docker magic string * Starts with 1 megabyte of zeros and `rancher.state.formatzero` is true + + +```yaml +#cloud-config +rancher: + state: + autoformat: + - /dev/sda + - /dev/vda +``` diff --git a/init/bootstrap.go b/init/bootstrap.go index a3ca9384..f1c8788d 100644 --- a/init/bootstrap.go +++ b/init/bootstrap.go @@ -58,7 +58,6 @@ func stopDocker(c chan interface{}) error { func bootstrap(cfg *config.CloudConfig) error { log.Info("Launching Bootstrap Docker") - log.Infof("bootstrap container: Autoformat(%v)", cfg.Rancher.State.Autoformat) c, err := startDocker(cfg) if err != nil { diff --git a/scripts/images/raspberry-pi-hypriot64/README.md b/scripts/images/raspberry-pi-hypriot64/README.md index a1f854e3..f5967d9b 100644 --- a/scripts/images/raspberry-pi-hypriot64/README.md +++ b/scripts/images/raspberry-pi-hypriot64/README.md @@ -1,9 +1,9 @@ -RaspberryPi 2 Image -=================== +RaspberryPi 3 Image (ARMv8 | AARCH64 | ARM64) +============================================= -Build by running `dapper` in this folder and the build will produce `./dist/rancheros-rpi2.zip`. +Build by running `dapper` in this folder and the build will produce `./dist/rancheros-raspberry-pi64.zip`. -This image is compatible with the Raspberry Pi 3 too, but only ARMv7 is supported now. +This image is compatible with the Raspberry Pi 3, since it is the only ARMv8 device in the Raspberry Pi family at the moment. Build Requirements ================== diff --git a/scripts/run b/scripts/run index 0bd36346..b393ee14 100755 --- a/scripts/run +++ b/scripts/run @@ -22,6 +22,10 @@ while [ "$#" -gt 0 ]; do QIND=0 REBUILD=0 ;; + --resizehd) + shift 1 + RESIZEHD=$1 + ;; --pxe) BOOT_PXE=1 ;; @@ -202,6 +206,10 @@ if [ "$QEMU" == "1" ] || [ "$BOOT_ISO" == "1" ] || [ "$BOOT_HD" == "1" ]; then fi fi fi + else + if [ "$RESIZEHD" != "" ]; then + qemu-img resize ${HD} ${RESIZEHD} + fi fi if [ "$SECOND_DRIVE" == "1" ]; then diff --git a/tests/installer_test.go b/tests/installer_test.go index cbe01719..cd76edd7 100755 --- a/tests/installer_test.go +++ b/tests/installer_test.go @@ -2,6 +2,7 @@ package integration import ( "fmt" + "strings" "time" . "gopkg.in/check.v1" @@ -118,6 +119,47 @@ sync s.Stop(c) } +func (s *QemuSuite) TestAutoResize(c *C) { + runArgs := []string{ + "--iso", + "--fresh", + } + version := "" + disk := "/dev/vda1\n" + size := "" + { + s.RunQemuWith(c, runArgs...) + + version = s.CheckOutput(c, version, Not(Equals), "sudo ros -v") + fmt.Printf("installing %s", version) + + s.CheckCall(c, ` +set -ex +echo "ssh_authorized_keys:" > config.yml +echo " - $(cat /home/rancher/.ssh/authorized_keys)" >> config.yml +sudo ros install --force --no-reboot --device /dev/vda -c config.yml --append "rancher.resize_device=/dev/vda" +sync +`) + time.Sleep(500 * time.Millisecond) + s.CheckCall(c, "sudo mount "+strings.TrimSpace(disk)+" /mnt") + size = s.CheckOutput(c, size, Not(Equals), "df -h | grep "+strings.TrimSpace(disk)+" | head -n1 | sed 's/ \\+/;/g' | cut -d ';' -f 2") + s.Stop(c) + } + + // ./scripts/run --no-format --append "rancher.debug=true" + runArgs = []string{ + "--boothd", + "--resizehd", "+20G", + } + s.RunQemuWith(c, runArgs...) + + s.CheckOutput(c, version, Equals, "sudo ros -v") + s.CheckOutput(c, disk, Equals, "blkid | cut -f 1 -d ' ' | sed 's/://'") + s.CheckOutput(c, size, Not(Equals), "df -h | grep "+strings.TrimSpace(disk)+" | head -n1 | sed 's/ \\+/;/g' | cut -d ';' -f 2") + + s.Stop(c) +} + func (s *QemuSuite) KillsMyServerTestInstalledDhcp(c *C) { // ./scripts/run --no-format --append "rancher.debug=true" --iso --fresh runArgs := []string{