1
0
mirror of https://github.com/rancher/os.git synced 2025-09-16 23:21:19 +00:00

Merge branch 'master' into v1.0.x

This commit is contained in:
Sven Dowideit
2017-06-27 10:42:59 +10:00
committed by GitHub
12 changed files with 97 additions and 42 deletions

View File

@@ -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)
}
}

View File

@@ -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))

View File

@@ -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)
}
}

View File

@@ -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")

View File

@@ -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)
}

View File

@@ -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.

View File

@@ -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

View File

@@ -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
```

View File

@@ -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 {

View File

@@ -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
==================

View File

@@ -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

View File

@@ -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{