From e43fb097c88c43d24b7b80a5ae87a1615baad7b8 Mon Sep 17 00:00:00 2001 From: Serhiy Berezin Date: Fri, 2 Dec 2016 00:40:04 +0000 Subject: [PATCH 01/19] Fixed serial console login did not work on Online.net and it dougter Scaleway.com but shown garbage and broken futher output instead --- cmd/control/console_init.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/control/console_init.go b/cmd/control/console_init.go index 759527e3..79890eba 100644 --- a/cmd/control/console_init.go +++ b/cmd/control/console_init.go @@ -139,7 +139,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"} { @@ -151,7 +151,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") From f7605990a5e3a974e651e5c317cb04cb9d3fe635 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Fri, 12 May 2017 01:48:19 +0000 Subject: [PATCH 02/19] Add a default for configdrive, and add '*' to scan all defaultable datasources Signed-off-by: Sven Dowideit --- cmd/cloudinitsave/cloudinitsave.go | 13 ++++++++----- docs/os/running-rancheros/server/pxe/index.md | 7 ++++--- 2 files changed, 12 insertions(+), 8 deletions(-) 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/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 From 62c90961644f2b4ef3dbd12a04eace1307a7a417 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Fri, 2 Jun 2017 10:33:47 +1000 Subject: [PATCH 03/19] Test resize, and update docs Signed-off-by: Sven Dowideit --- cmd/cloudinitexecute/cloudinitexecute.go | 12 ++++-- cmd/control/bootstrap.go | 7 ++-- .../resizing-device-partition/index.md | 2 +- docs/os/storage/state-partition/index.md | 17 +++++--- init/bootstrap.go | 1 - scripts/run | 8 ++++ tests/installer_test.go | 42 +++++++++++++++++++ 7 files changed, 74 insertions(+), 15 deletions(-) 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/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/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/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/run b/scripts/run index bd230448..73cf0659 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 ;; @@ -198,6 +202,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 22a7fde6..e48dd52b 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" @@ -117,3 +118,44 @@ sync s.CheckOutput(c, version, Equals, "sudo ros -v") 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) +} From 242d42fbb1a533e3eee67c324f8799a6a491cd1f Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Fri, 2 Jun 2017 14:17:29 +1000 Subject: [PATCH 04/19] remove symlink error messages on second run of entrypoint Signed-off-by: Sven Dowideit --- cmd/control/entrypoint.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) 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) } From f0b992854198c3990e21c02b3cbdbc3505d842f5 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Thu, 8 Jun 2017 01:03:43 +0000 Subject: [PATCH 05/19] linux kernel 4.9.31 Signed-off-by: Sven Dowideit --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 6ae0bd0c..f9788cca 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -56,7 +56,7 @@ ARG DOCKER_BUILD_VERSION=1.10.3 ARG DOCKER_BUILD_PATCH_VERSION=v${DOCKER_BUILD_VERSION}-ros1 ARG SELINUX_POLICY_URL=https://github.com/rancher/refpolicy/releases/download/v0.0.3/policy.29 -ARG KERNEL_VERSION_amd64=4.9.30-rancher +ARG KERNEL_VERSION_amd64=4.9.31-rancher ARG KERNEL_URL_amd64=https://github.com/rancher/os-kernel/releases/download/v${KERNEL_VERSION_amd64}/linux-${KERNEL_VERSION_amd64}-x86.tar.gz ARG KERNEL_URL_arm64=https://github.com/imikushin/os-kernel/releases/download/Estuary-4.4.0-arm64.8/linux-4.4.0-rancher-arm64.tar.gz From 6bbde90e0ae4251fe8134d3e14c7216b41f1baff Mon Sep 17 00:00:00 2001 From: Sebastiaan van Steenis Date: Fri, 9 Jun 2017 17:23:25 +0200 Subject: [PATCH 06/19] Remove link to removed page DKMS --- docs/_includes/os-sidebar.html | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/_includes/os-sidebar.html b/docs/_includes/os-sidebar.html index fa2114f6..bb08e466 100644 --- a/docs/_includes/os-sidebar.html +++ b/docs/_includes/os-sidebar.html @@ -51,7 +51,6 @@
  • Adding kernel parameters
  • Loading kernel modules
  • Install kernel modules that require kernel headers
  • -
  • DKMS
  • From d0bfdb444ecd6fcd4f9a915a4ce2671e2c59874c Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Mon, 12 Jun 2017 12:36:04 +1000 Subject: [PATCH 07/19] Add some specific examples for registry mirror settings Signed-off-by: Sven Dowideit --- docs/os/configuration/docker/index.md | 41 +++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/docs/os/configuration/docker/index.md b/docs/os/configuration/docker/index.md index 93681fa2..087de7d9 100644 --- a/docs/os/configuration/docker/index.md +++ b/docs/os/configuration/docker/index.md @@ -28,7 +28,7 @@ You can also customize Docker after it's been started using `ros config`. $ sudo ros config set rancher.docker.storage_driver overlay ``` -#### Valid Keys for Docker +#### User Docker settings Many of the standard Docker daemon arguments can be placed under the `rancher.docker` key. The command needed to start the Docker daemon will be generated based on these arguments. The following arguments are currently supported. @@ -77,7 +77,7 @@ rancher: storage_driver: overlay ``` -#### Valid Keys for System Docker +#### System Docker settings All daemon arguments shown in the first table are also available to System Docker. The following are also supported. @@ -85,3 +85,40 @@ Key | Value | Default | Description ---|---|---| --- `extra_args` | List of Strings | `[]` | Arbitrary daemon arguments, appended to the generated command `environment` | List of Strings (optional) | `[]` | + +### Using a pull through registry mirror + +There are 3 Docker engines that can be configured to use the pull-through Docker Hub registry mirror cache: + +``` +#cloud-config +rancher: + bootstrap_docker: + registry_mirror: "http://10.10.10.23:5555" + docker: + registry_mirror: "http://10.10.10.23:5555" + system_docker: + registry_mirror: "http://10.10.10.23:5555" +``` + +`bootstrap_docker` is used to prepare and initial network and pull any cloud-config options that can be used to configure the final network configuration and System-docker - its very unlikely to pull any images. + +A successful pull through mirror cache request by System-docker looks like: + +``` +[root@rancher-dev rancher]# system-docker pull alpine +Using default tag: latest +DEBU[0201] Calling GET /v1.23/info +> WARN[0201] Could not get operating system name: Error opening /usr/lib/os-release: open /usr/lib/os-release: no such file or directory +WARN[0201] Could not get operating system name: Error opening /usr/lib/os-release: open /usr/lib/os-release: no such file or directory +DEBU[0201] Calling POST /v1.23/images/create?fromImage=alpine%3Alatest +DEBU[0201] hostDir: /etc/docker/certs.d/10.10.10.23:5555 +DEBU[0201] Trying to pull alpine from http://10.10.10.23:5555/ v2 +DEBU[0204] Pulling ref from V2 registry: alpine:latest +DEBU[0204] pulling blob "sha256:2aecc7e1714b6fad58d13aedb0639011b37b86f743ba7b6a52d82bd03014b78e" latest: Pulling from library/alpine +DEBU[0204] Downloaded 2aecc7e1714b to tempfile /var/lib/system-docker/tmp/GetImageBlob281102233 2aecc7e1714b: Extracting 1.99 MB/1.99 MB +DEBU[0204] Untar time: 0.161064213s +DEBU[0204] Applied tar sha256:3fb66f713c9fa9debcdaa58bb9858bd04c17350d9614b7a250ec0ee527319e59 to 841c99a5995007d7a66b922be9bafdd38f8090af17295b4a44436ef433a2aecc7e1714b: Pull complete +Digest: sha256:0b94d1d1b5eb130dd0253374552445b39470653fb1a1ec2d81490948876e462c +Status: Downloaded newer image for alpine:latest +``` From 1eb6991798071a3d5bb7966986be178b3a9ac21d Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Wed, 14 Jun 2017 13:45:04 +1000 Subject: [PATCH 08/19] Add apt-cacher build arg Signed-off-by: Sven Dowideit --- Dockerfile.dapper | 11 ++++++++--- scripts/installer/kexec/Dockerfile.dapper | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index f9788cca..da674db4 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -1,8 +1,13 @@ FROM ubuntu:16.04 # FROM arm64=aarch64/ubuntu:16.04 arm=armhf/ubuntu:16.04 -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ +# get the apt-cacher proxy set +ARG APTPROXY= + +RUN echo "Acquire::http { Proxy \"$APTPROXY\"; };" >> /etc/apt/apt.conf.d/01proxy \ + && cat /etc/apt/apt.conf.d/01proxy \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ build-essential \ ca-certificates \ cpio \ @@ -32,7 +37,7 @@ RUN apt-get update && \ ########## Dapper Configuration ##################### -ENV DAPPER_ENV VERSION DEV_BUILD RUNTEST DEBUG +ENV DAPPER_ENV VERSION DEV_BUILD RUNTEST DEBUG APTPROXY ENV DAPPER_DOCKER_SOCKET true ENV DAPPER_SOURCE /go/src/github.com/rancher/os ENV DAPPER_OUTPUT ./bin ./dist ./build/initrd ./build/kernel diff --git a/scripts/installer/kexec/Dockerfile.dapper b/scripts/installer/kexec/Dockerfile.dapper index a60d39f7..49ad5889 100644 --- a/scripts/installer/kexec/Dockerfile.dapper +++ b/scripts/installer/kexec/Dockerfile.dapper @@ -1,8 +1,12 @@ FROM ubuntu:16.04 # FROM arm64=aarch64/ubuntu:16.04 arm=armhf/ubuntu:16.04 +# get the apt-cacher proxy set +ARG APTPROXY= -RUN apt-get update \ +RUN echo "Acquire::http { Proxy \"$APTPROXY\"; };" >> /etc/apt/apt.conf.d/01proxy \ + && cat /etc/apt/apt.conf.d/01proxy \ + && apt-get update \ && apt-get install -yq build-essential autoconf libtool gawk alien fakeroot \ zlib1g-dev uuid-dev libattr1-dev libblkid-dev libselinux-dev libudev-dev libdevmapper-dev \ module-init-tools \ @@ -30,7 +34,7 @@ RUN mkdir -p /source/dist \ ########## Dapper Configuration ##################### -ENV DAPPER_ENV VERSION DEV_BUILD RUNTEST +ENV DAPPER_ENV VERSION DEV_BUILD RUNTEST APTPROXY #ENV DAPPER_DOCKER_SOCKET true ENV DAPPER_SOURCE /source ENV DAPPER_OUTPUT ./dist From 4551278b99a43b439d2c9b1d5b25ab40982c17af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Prud=27homme?= Date: Thu, 15 Jun 2017 09:16:51 +0200 Subject: [PATCH 09/19] Fix OpenStack console log problem #1094 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 75a760ca..0277377b 100755 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ itest: qcows: cp dist/artifacts/rancheros.iso scripts/images/openstack/ cd scripts/images/openstack && \ - APPEND="console=tty1 printk.devkmsg=on rancher.autologin=ttyS0" \ + APPEND="console=tty1 console=ttyS0,115200n8 printk.devkmsg=on rancher.autologin=ttyS0" \ NAME=openstack ../../../.dapper cd scripts/images/openstack && \ APPEND="console=tty1 rancher.debug=true printk.devkmsg=on notsc clocksource=kvm-clock rancher.network.interfaces.eth0.ipv4ll rancher.cloud_init.datasources=[digitalocean] rancher.autologin=tty1 rancher.autologin=ttyS0" \ From 172a4782dfc4683a23bf2c6a15671c8dd049d721 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Mon, 19 Jun 2017 14:33:07 +1000 Subject: [PATCH 10/19] linux 4.9.33 Signed-off-by: Sven Dowideit --- Dockerfile.dapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index da674db4..a3b33844 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -61,7 +61,7 @@ ARG DOCKER_BUILD_VERSION=1.10.3 ARG DOCKER_BUILD_PATCH_VERSION=v${DOCKER_BUILD_VERSION}-ros1 ARG SELINUX_POLICY_URL=https://github.com/rancher/refpolicy/releases/download/v0.0.3/policy.29 -ARG KERNEL_VERSION_amd64=4.9.31-rancher +ARG KERNEL_VERSION_amd64=4.9.33-rancher ARG KERNEL_URL_amd64=https://github.com/rancher/os-kernel/releases/download/v${KERNEL_VERSION_amd64}/linux-${KERNEL_VERSION_amd64}-x86.tar.gz ARG KERNEL_URL_arm64=https://github.com/imikushin/os-kernel/releases/download/Estuary-4.4.0-arm64.8/linux-4.4.0-rancher-arm64.tar.gz From c467aedcda4cf4907286d6a4d9f9fb738f990115 Mon Sep 17 00:00:00 2001 From: Mauricio Ugaz Date: Mon, 19 Jun 2017 18:27:01 -0400 Subject: [PATCH 11/19] Simple update README.md to AARCH64 desciption --- scripts/images/raspberry-pi-hypriot64/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 ================== From 284f029b1993ae21f8ee2899ded63a5140502e54 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Mon, 8 May 2017 12:35:51 +0000 Subject: [PATCH 12/19] buildroot v2017.02.2 Signed-off-by: Sven Dowideit --- Dockerfile.dapper | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index a3b33844..745c85ea 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -79,9 +79,9 @@ ARG OS_SERVICES_REPO=https://raw.githubusercontent.com/${OS_REPO}/os-services ARG IMAGE_NAME=${OS_REPO}/os ARG DFS_IMAGE=${OS_REPO}/docker:v${DOCKER_VERSION}-2 -ARG OS_BASE_URL_amd64=https://github.com/rancher/os-base/releases/download/v2016.08.1-2/os-base_amd64.tar.xz -ARG OS_BASE_URL_arm64=https://github.com/rancher/os-base/releases/download/v2016.08.1-2/os-base_arm64.tar.xz -ARG OS_BASE_URL_arm=https://github.com/rancher/os-base/releases/download/v2016.08.1-3/os-base_arm.tar.xz +ARG OS_BASE_URL_amd64=https://github.com/rancher/os-base/releases/download/v2017.02.3-1/os-base_amd64.tar.xz +ARG OS_BASE_URL_arm64=https://github.com/rancher/os-base/releases/download/v2017.02.3-1/os-base_arm64.tar.xz +ARG OS_BASE_URL_arm=https://github.com/rancher/os-base/releases/download/v2017.02.3-1/os-base_arm.tar.xz ###################################################### # Set up environment and export all ARGS as ENV From 3e68d3c92c673ac54791268e40c60b56724a3b70 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Tue, 20 Jun 2017 14:51:04 +1000 Subject: [PATCH 13/19] Use a locally configured ENGINE_REGISTRY_MIRROR if available Signed-off-by: Sven Dowideit --- scripts/run-common | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/run-common b/scripts/run-common index 62b7475e..d4f45093 100755 --- a/scripts/run-common +++ b/scripts/run-common @@ -48,4 +48,8 @@ REBUILD=1 QEMUARCH=${qemuarch["${ARCH}"]} TTYCONS=${ttycons["${ARCH}"]} -DEFAULT_KERNEL_ARGS="printk.devkmsg=on rancher.debug=true rancher.password=rancher console=${TTYCONS} rancher.autologin=${TTYCONS}" +if [ "$ENGINE_REGISTRY_MIRROR" != "" ]; then + REGISTRY_MIRROR="rancher.bootstrap_docker.registry_mirror=${ENGINE_REGISTRY_MIRROR} rancher.system_docker.registry_mirror=${ENGINE_REGISTRY_MIRROR} rancher.docker.registry_mirror=${ENGINE_REGISTRY_MIRROR}" +fi + +DEFAULT_KERNEL_ARGS="printk.devkmsg=on rancher.debug=true rancher.password=rancher console=${TTYCONS} rancher.autologin=${TTYCONS} ${REGISTRY_MIRROR} " From 3978d93fcac9213262303c5be0c1ba00e450f34c Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Tue, 13 Jun 2017 19:33:27 +1000 Subject: [PATCH 14/19] Add a failing test for dualnics with static ip missing Signed-off-by: Sven Dowideit --- Dockerfile.dapper | 3 +- scripts/global.cfg | 2 +- scripts/run | 19 +++- tests/common_test.go | 89 ++++++++++++++++-- tests/installer_test.go | 109 ++++++++++++++++++++++ trash.conf | 1 + vendor/github.com/gbazil/telnet/LICENSE | 21 +++++ vendor/github.com/gbazil/telnet/README.md | 9 ++ vendor/github.com/gbazil/telnet/telnet.go | 81 ++++++++++++++++ 9 files changed, 319 insertions(+), 15 deletions(-) create mode 100644 vendor/github.com/gbazil/telnet/LICENSE create mode 100644 vendor/github.com/gbazil/telnet/README.md create mode 100644 vendor/github.com/gbazil/telnet/telnet.go diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 745c85ea..ba0c4d7f 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -33,7 +33,8 @@ RUN echo "Acquire::http { Proxy \"$APTPROXY\"; };" >> /etc/apt/apt.conf.d/01prox syslinux-common \ vim \ wget \ - xorriso + xorriso \ + telnet ########## Dapper Configuration ##################### diff --git a/scripts/global.cfg b/scripts/global.cfg index 3f0206f6..b9db5a29 100755 --- a/scripts/global.cfg +++ b/scripts/global.cfg @@ -1 +1 @@ -APPEND rancher.autologin=tty1 rancher.autologin=ttyS0 console=tty0 console=ttyS0 printk.devkmsg=on ${APPEND} +APPEND rancher.autologin=tty1 rancher.autologin=ttyS0 console=tty0 rancher.autologin=ttyS1 rancher.console=ttyS1 console=ttyS0 printk.devkmsg=on ${APPEND} diff --git a/scripts/run b/scripts/run index 73cf0659..db0a51b1 100755 --- a/scripts/run +++ b/scripts/run @@ -120,6 +120,9 @@ while [ "$#" -gt 0 ]; do # use the bios console, not serial (lets you see syslinux) CONSOLEDISPLAY=1 ;; + --netconsole) + NETCONSOLE=1 + ;; --installed) ./scripts/create-installed INSTALLED=1 @@ -162,6 +165,7 @@ if [ "$APPEND_INIT" != "" ]; then fi if [ "$BOOT_PXE" == "1" ]; then + KERNEL_ARGS="console=tty1 rancher.console=tty1 rancher.autologin=tty1 ${KERNEL_ARGS}" set -ex PIXIECORE=$(which pixiecore) sudo -E $PIXIECORE boot \ @@ -259,15 +263,19 @@ if [ "$QIND" != "1" ]; then HOME=${HOME:-/} fi +# default serial console +DISPLAY_OPTS="-nographic -serial mon:stdio -display none" + if [ "$CONSOLEDISPLAY" == "1" ]; then DISPLAY_OPTS="-curses" -else - # default - DISPLAY_OPTS="-nographic -serial mon:stdio -display none" +fi +if [ "$NETCONSOLE" == "1" ]; then + # put ttyS1 on port 4444 + DISPLAY_OPTS="${DISPLAY_OPTS} -serial tcp::4444,server" + KERNEL_ARGS="rancher.console=ttyS1 rancher.autologin=ttyS1 ${KERNEL_ARGS}" fi if [ "$QEMU" == "1" ]; then - if [ "$INSTALLED" == "1" ]; then # kernel args only works when using -kernel KERNEL_ARGS="" @@ -315,7 +323,8 @@ elif [ "$BOOT_ISO" == "1" ] || $(eval "${hd["$ARCH"]} ${HD}") \ ${SECOND_DRIVE_ENABLE} \ -smp 1 \ - ${ISO_OPTS} + ${ISO_OPTS} \ + "${@}" elif [ "$QIND" == "1" ]; then NAME=${NAME:-ros-qind} diff --git a/tests/common_test.go b/tests/common_test.go index 9d6f9d0c..1b557290 100755 --- a/tests/common_test.go +++ b/tests/common_test.go @@ -9,6 +9,8 @@ import ( "testing" "time" + "github.com/gbazil/telnet" + . "gopkg.in/check.v1" ) @@ -41,6 +43,7 @@ type QemuSuite struct { runCommand string sshCommand string qemuCmd *exec.Cmd + netConsole telnet.Telnet } func (s *QemuSuite) TearDownTest(c *C) { @@ -54,6 +57,9 @@ func (s *QemuSuite) RunQemuWith(c *C, additionalArgs ...string) error { err := s.runQemu(c, additionalArgs...) c.Assert(err, IsNil) + err = s.WaitForSSH() + c.Assert(err, IsNil) + return err } @@ -82,19 +88,84 @@ func (s *QemuSuite) RunQemuInstalled(c *C, additionalArgs ...string) error { return err } +// RunQemuWithNetConsole requires user to specify all the `scripts/run` arguments +func (s *QemuSuite) RunQemuWithNetConsole(c *C, additionalArgs ...string) error { + runArgs := []string{ + "--netconsole", + } + runArgs = append(runArgs, additionalArgs...) + + err := s.runQemu(c, runArgs...) + c.Assert(err, IsNil) + + time.Sleep(500 * time.Millisecond) + // start telnet, and wait for prompt + for i := 0; i < 20; i++ { + s.netConsole, err = telnet.DialTimeout("127.0.0.1:4444", 5*time.Second) + if err == nil { + fmt.Printf("t%d SUCCEEDED\n", i) + break + } + fmt.Printf("t%d", i) + time.Sleep(500 * time.Millisecond) + } + c.Assert(err, IsNil) + + for i := 0; i < 20; i++ { + time.Sleep(1 * time.Second) + + res := s.NetCall("uname") + if strings.Contains(res, "Linux") { + fmt.Printf("W%d SUCCEEDED(%s)\n", i, res) + break + } + } + + s.NetCall("ip a") + s.NetCall("cat /proc/cmdline") + + return err +} + +func (s *QemuSuite) NetCall(cmd string) string { + s.netConsole.Write(cmd + "\n") + r, err := s.netConsole.Read("\n") + fmt.Printf("cmd> %s", r) + result := "" + r = "" + for err == nil { + r, err = s.netConsole.Read("\n") + fmt.Printf("\t%s", r) + result = result + r + } + fmt.Printf("\n") + // Note, if the result contains something like "+ cmd\n", you may have set -xe on + return result +} +func (s *QemuSuite) NetCheckCall(c *C, additionalArgs ...string) { + out := s.NetCall(strings.Join(additionalArgs, " ")) + c.Assert(out, Not(Equals), "") +} +func (s *QemuSuite) NetCheckOutput(c *C, result string, check Checker, additionalArgs ...string) string { + out := s.NetCall(strings.Join(additionalArgs, " ")) + out = strings.Replace(out, "\r", "", -1) + c.Assert(out, check, result) + return out +} + func (s *QemuSuite) runQemu(c *C, args ...string) error { c.Assert(s.qemuCmd, IsNil) // can't run 2 qemu's at once (yet) s.qemuCmd = exec.Command(s.runCommand, args...) - if os.Getenv("DEBUG") != "" { - s.qemuCmd.Stdout = os.Stdout - s.qemuCmd.Stderr = os.Stderr - } + //if os.Getenv("DEBUG") != "" { + s.qemuCmd.Stdout = os.Stdout + s.qemuCmd.Stderr = os.Stderr + //} if err := s.qemuCmd.Start(); err != nil { return err } fmt.Printf("--- %s: starting qemu %s, %v\n", c.TestName(), s.runCommand, args) - return s.WaitForSSH() + return nil } func (s *QemuSuite) WaitForSSH() error { @@ -171,12 +242,14 @@ func (s *QemuSuite) CheckOutputContains(c *C, result string, additionalArgs ...s } func (s *QemuSuite) Stop(c *C) { - //s.MakeCall("sudo halt") - //time.Sleep(2000 * time.Millisecond) + fmt.Printf("%s: stopping qemu\n", c.TestName()) + //s.MakeCall("sudo poweroff") + time.Sleep(1000 * time.Millisecond) //c.Assert(s.WaitForSSH(), IsNil) - //fmt.Println("%s: stopping qemu", c.TestName()) + fmt.Printf("%s: stopping qemu 2\n", c.TestName()) c.Assert(s.qemuCmd.Process.Kill(), IsNil) + fmt.Printf("%s: stopping qemu 3\n", c.TestName()) s.qemuCmd.Process.Wait() //time.Sleep(time.Millisecond * 1000) s.qemuCmd = nil diff --git a/tests/installer_test.go b/tests/installer_test.go index e48dd52b..fa0af65a 100755 --- a/tests/installer_test.go +++ b/tests/installer_test.go @@ -159,3 +159,112 @@ sync s.Stop(c) } + +func (s *QemuSuite) KillsMyServerTestInstalledDhcp(c *C) { + // ./scripts/run --no-format --append "rancher.debug=true" --iso --fresh + runArgs := []string{ + "--iso", + "--fresh", +// "-net", "nic,vlan=0,model=virtio", +// "-net", "user,vlan=0", +// "-net", "nic,vlan=0,model=virtio", +// "-net", "user,vlan=0", + } + version := "" + { + s.RunQemuWith(c, runArgs...) + + s.MakeCall("ip a") + + version = s.CheckOutput(c, version, Not(Equals), "sudo ros -v") + fmt.Printf("installing %s", version) + + s.CheckCall(c, ` +echo "ssh_authorized_keys:" > config.yml +echo " - $(cat /home/rancher/.ssh/authorized_keys)" >> config.yml +echo "rancher:" >> config.yml +echo " network:" >> config.yml +echo " interfaces:" >> config.yml +echo " eth2:" >> config.yml +echo " dhcp: true" >> config.yml +echo " eth1:" >> config.yml +echo " address: 10.0.2.253/24" >> config.yml +echo " dhcp: false" >> config.yml +echo " gateway: 10.0.2.1" >> config.yml +echo " mtu: 1500" >> config.yml +ip a +echo "===================" +cat config.yml | sudo ros config merge +sudo ros service stop network +sleep 1 +sudo ros service start network +sleep 1 +ip a +echo "===================" +sudo ros install --force --no-reboot --device /dev/vda -c config.yml -a "console=ttyS0 rancher.console=ttyS0 rancher.autologin=ttyS0 rancher.console=ttyS1 rancher.autologin=ttyS1 rancher.debug=true" +sync +`) + time.Sleep(500 * time.Millisecond) + s.Stop(c) + } + + runArgs = []string{ + "--boothd", + "-net", "nic,vlan=0,model=virtio", + "-net", "user,vlan=0", + "-net", "nic,vlan=0,model=virtio", + "-net", "user,vlan=0", + } + s.RunQemuWithNetConsole(c, runArgs...) + + s.NetCheckOutput(c, version, Equals, "sudo ros -v") + s.NetCheckOutput(c, "", Not(Equals), "sh", "-c", "ip a show eth1 | grep 10.0.2..253") + s.Stop(c) +} + +func (s *QemuSuite) TestConfigDhcp(c *C) { + runArgs := []string{ + "--iso", + "--fresh", + "-net", "nic,vlan=0,model=virtio", + "-net", "user,vlan=0", + "-net", "nic,vlan=0,model=virtio", + "-net", "user,vlan=0", + } + version := "" + { + s.RunQemuWithNetConsole(c, runArgs...) + + s.NetCall("ip a") + + version = s.NetCheckOutput(c, version, Not(Equals), "sudo ros -v") + fmt.Printf("installing %s", version) + + s.NetCheckCall(c, ` +echo "ssh_authorized_keys:" > config.yml +echo " - $(cat /home/rancher/.ssh/authorized_keys)" >> config.yml +echo "rancher:" >> config.yml +echo " network:" >> config.yml +echo " interfaces:" >> config.yml +echo " eth2:" >> config.yml +echo " dhcp: true" >> config.yml +echo " eth1:" >> config.yml +echo " address: 10.0.2.253/24" >> config.yml +echo " dhcp: false" >> config.yml +echo " gateway: 10.0.2.1" >> config.yml +echo " mtu: 1500" >> config.yml +ip a +echo "===================" +cat config.yml | sudo ros config merge +sudo ros service stop network +sleep 1 +sudo ros service start network +sleep 1 +ip a +`) + + s.NetCheckOutput(c, version, Equals, "sudo ros -v") + s.NetCheckOutput(c, "", Not(Equals), "sh", "-c", "ip a show eth1 2>/dev/null | grep 10.0.2.253") + s.Stop(c) + } +} diff --git a/trash.conf b/trash.conf index b195b949..b93f2ed5 100644 --- a/trash.conf +++ b/trash.conf @@ -59,3 +59,4 @@ golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/gol google.golang.org/grpc ab0be5212fb225475f2087566eded7da5d727960 https://github.com/grpc/grpc-go.git gopkg.in/fsnotify.v1 v1.2.0 github.com/fatih/structs dc3312cb1a4513a366c4c9e622ad55c32df12ed3 +github.com/gbazil/telnet ba7da85c947a39063cddb0ffbff20b6bbbe9222f diff --git a/vendor/github.com/gbazil/telnet/LICENSE b/vendor/github.com/gbazil/telnet/LICENSE new file mode 100644 index 00000000..bb0dc4da --- /dev/null +++ b/vendor/github.com/gbazil/telnet/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Vasily Suvorov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/gbazil/telnet/README.md b/vendor/github.com/gbazil/telnet/README.md new file mode 100644 index 00000000..0e83318c --- /dev/null +++ b/vendor/github.com/gbazil/telnet/README.md @@ -0,0 +1,9 @@ +# telnet + +[© Vasily Suvorov 2016](http://bazil.pro) + +#### DESCRIPTION + +Package telnet provides very simple interface for interacting with telnet devices from golang's routines. + +[![GoDoc](https://godoc.org/github.com/gbazil/telnet?status.svg)](https://godoc.org/github.com/gbazil/telnet) diff --git a/vendor/github.com/gbazil/telnet/telnet.go b/vendor/github.com/gbazil/telnet/telnet.go new file mode 100644 index 00000000..5e00214d --- /dev/null +++ b/vendor/github.com/gbazil/telnet/telnet.go @@ -0,0 +1,81 @@ +// Package telnet provides very simple interface for interacting with telnet devices from go routines. +package telnet + +import ( + "bufio" + "bytes" + "net" + "strings" + "time" +) + +// Telnet presents struct with net.Conn interface for telnet protocol plus buffered reader and timeout setup +type Telnet struct { + conn net.Conn + reader *bufio.Reader + timeout time.Duration +} + +// Dial constructs connection to a telnet device. Address string must be in format: "ip:port" (e.g. "127.0.0.1:23"). +// Default timeout is set to 5 seconds. +func Dial(addr string) (t Telnet, err error) { + t.conn, err = net.Dial("tcp", addr) + + if err == nil { + t.reader = bufio.NewReader(t.conn) + t.timeout = time.Second * 5 // default + } + + return +} + +// DialTimeout acts like Dial but takes a specific timeout (in nanoseconds). +func DialTimeout(addr string, timeout time.Duration) (t Telnet, err error) { + t.conn, err = net.DialTimeout("tcp", addr, timeout) + + if err == nil { + t.reader = bufio.NewReader(t.conn) + t.timeout = timeout + } + + return +} + +// Read reads all data into string from telnet device until it meets the expected or stops on timeout. +func (t Telnet) Read(expect string) (str string, err error) { + var buf bytes.Buffer + t.conn.SetReadDeadline(time.Now().Add(t.timeout)) + + for { + b, e := t.reader.ReadByte() + if e != nil { + err = e + break + } + + if b == 255 { + t.reader.Discard(2) + } else { + buf.WriteByte(b) + } + + if strings.Contains(buf.String(), expect) { + str = buf.String() + break + } + } + + return +} + +// Write writes string (command or data) to telnet device. Do not forget add LF to end of string! +func (t Telnet) Write(s string) (i int, err error) { + t.conn.SetWriteDeadline(time.Now().Add(t.timeout)) + i, err = t.conn.Write([]byte(s)) + return +} + +// SetTimeout changes default or start timeout for all interactions +func (t Telnet) SetTimeout(timeout time.Duration) { + t.timeout = timeout +} From 75168c6d1160df5b925da791f3bdde2752f88903 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Tue, 13 Jun 2017 12:11:53 +0000 Subject: [PATCH 15/19] Swap the remove and apply IP order - seem to fix the problem Signed-off-by: Sven Dowideit --- netconf/netconf_linux.go | 12 +++++++----- tests/common_test.go | 8 ++++---- tests/installer_test.go | 17 ++++++++++------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/netconf/netconf_linux.go b/netconf/netconf_linux.go index c800c899..406f200d 100755 --- a/netconf/netconf_linux.go +++ b/netconf/netconf_linux.go @@ -402,11 +402,6 @@ func applyInterfaceConfig(link netlink.Link, netConf InterfaceConfig) error { addrMap := make(map[string]bool) for _, address := range addresses { addrMap[address] = true - log.Infof("Applying %s to %s", address, link.Attrs().Name) - err := applyAddress(address, link, netConf) - if err != nil { - log.Errorf("Failed to apply address %s to %s: %v", address, link.Attrs().Name, err) - } } for _, addr := range existingAddrs { if _, ok := addrMap[addr.IPNet.String()]; !ok { @@ -419,6 +414,13 @@ func applyInterfaceConfig(link netlink.Link, netConf InterfaceConfig) error { } } } + for _, address := range addresses { + log.Infof("Applying %s to %s", address, link.Attrs().Name) + err := applyAddress(address, link, netConf) + if err != nil { + log.Errorf("Failed to apply address %s to %s: %v", address, link.Attrs().Name, err) + } + } // TODO: can we set to default? if netConf.MTU > 0 { diff --git a/tests/common_test.go b/tests/common_test.go index 1b557290..6e34eed4 100755 --- a/tests/common_test.go +++ b/tests/common_test.go @@ -156,10 +156,10 @@ func (s *QemuSuite) NetCheckOutput(c *C, result string, check Checker, additiona func (s *QemuSuite) runQemu(c *C, args ...string) error { c.Assert(s.qemuCmd, IsNil) // can't run 2 qemu's at once (yet) s.qemuCmd = exec.Command(s.runCommand, args...) - //if os.Getenv("DEBUG") != "" { - s.qemuCmd.Stdout = os.Stdout - s.qemuCmd.Stderr = os.Stderr - //} + if os.Getenv("DEBUG") != "" { + s.qemuCmd.Stdout = os.Stdout + s.qemuCmd.Stderr = os.Stderr + } if err := s.qemuCmd.Start(); err != nil { return err } diff --git a/tests/installer_test.go b/tests/installer_test.go index fa0af65a..cd76edd7 100755 --- a/tests/installer_test.go +++ b/tests/installer_test.go @@ -165,10 +165,10 @@ func (s *QemuSuite) KillsMyServerTestInstalledDhcp(c *C) { runArgs := []string{ "--iso", "--fresh", -// "-net", "nic,vlan=0,model=virtio", -// "-net", "user,vlan=0", -// "-net", "nic,vlan=0,model=virtio", -// "-net", "user,vlan=0", + // "-net", "nic,vlan=0,model=virtio", + // "-net", "user,vlan=0", + // "-net", "nic,vlan=0,model=virtio", + // "-net", "user,vlan=0", } version := "" { @@ -260,11 +260,14 @@ sudo ros service stop network sleep 1 sudo ros service start network sleep 1 +echo "===================" +sudo system-docker logs network +echo "===================" ip a `) - s.NetCheckOutput(c, version, Equals, "sudo ros -v") - s.NetCheckOutput(c, "", Not(Equals), "sh", "-c", "ip a show eth1 2>/dev/null | grep 10.0.2.253") - s.Stop(c) + s.NetCheckOutput(c, version, Equals, "sudo ros -v") + s.NetCheckOutput(c, "", Not(Equals), "sh", "-c", "\"ip a show eth1 | grep 10.0.2.253\"") + s.Stop(c) } } From 94a4fe77786dfd0aa475bf66efdaf410718d5205 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Thu, 22 Jun 2017 12:44:18 +1000 Subject: [PATCH 16/19] Fix ElideCmdline test by making it more robust Signed-off-by: Sven Dowideit --- tests/cmdline_test.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/cmdline_test.go b/tests/cmdline_test.go index fd007c24..d15afc23 100755 --- a/tests/cmdline_test.go +++ b/tests/cmdline_test.go @@ -1,7 +1,11 @@ package integration -import . "gopkg.in/check.v1" -import "fmt" +import ( + . "gopkg.in/check.v1" + + "fmt" + "strings" +) func (s *QemuSuite) TestElideCmdLine(c *C) { extra := "cc.hostname=nope rancher.password=three" @@ -15,11 +19,10 @@ func (s *QemuSuite) TestElideCmdLine(c *C) { s.RunQemuWith(c, runArgs...) s.CheckOutput(c, "nope\n", Equals, "hostname") - s.CheckOutput(c, - "printk.devkmsg=on rancher.debug=true rancher.password=rancher console=ttyS0 rancher.autologin=ttyS0 cc.something=yes rancher.password=two rancher.state.dev=LABEL=RANCHER_STATE rancher.state.autoformat=[/dev/sda,/dev/vda] rancher.rm_usr -- \n", - Equals, - "cat /proc/cmdline", - ) + cmdline := s.CheckOutput(c, "", Not(Equals), "cat /proc/cmdline",) + if strings.Contains(cmdline, extra) { + c.Errorf("/proc/cmdline (%s) contains info that should be elided (%s)", cmdline, extra) + } s.CheckOutput(c, fmt.Sprintf("/init %s\n", extra), Equals, From 5dd92a610ba30af12e9872c89c4279bbf1a3edde Mon Sep 17 00:00:00 2001 From: Robert Juliano Date: Tue, 6 Jun 2017 01:30:54 +0000 Subject: [PATCH 17/19] Add test for vfat formatted config drive --- Dockerfile.dapper | 1 + scripts/run | 6 ++++-- tests/cloud_init_test.go | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dapper b/Dockerfile.dapper index ba0c4d7f..0bf4eb82 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -24,6 +24,7 @@ RUN echo "Acquire::http { Proxy \"$APTPROXY\"; };" >> /etc/apt/apt.conf.d/01prox libselinux1-dev \ locales \ module-init-tools \ + mtools \ openssh-client \ pkg-config \ qemu \ diff --git a/scripts/run b/scripts/run index db0a51b1..b393ee14 100755 --- a/scripts/run +++ b/scripts/run @@ -250,8 +250,10 @@ if [ "$QIND" != "1" ]; then CLOUD_CONFIG_DISK="-cdrom ${BASE}/state/configdrive.iso" ;; fat) - echo "TODO: implement a vfat formated qemu img & copy the config files into it" - exit 1 + truncate --size 2M ${BASE}/state/configdrive.img + mkfs.vfat -n config-2 ${BASE}/state/configdrive.img + mcopy -osi ${BASE}/state/configdrive.img ${CCROOT}/* :: + CLOUD_CONFIG_DISK="-hdb ${BASE}/state/configdrive.img" ;; *) CLOUD_CONFIG_DISK="-fsdev local,security_model=passthrough,readonly,id=fsdev0,path=${CCROOT} \ diff --git a/tests/cloud_init_test.go b/tests/cloud_init_test.go index 756a4254..5a090f75 100644 --- a/tests/cloud_init_test.go +++ b/tests/cloud_init_test.go @@ -28,3 +28,13 @@ func (s *QemuSuite) TestIsoCloudConfig(c *C) { s.CheckCall(c, `ls .ssh/authorized_keys`) } + +func (s *QemuSuite) TestFatCloudConfig(c *C) { + runArgs := []string{ + "--fresh", + "--cloud-config-fat", + } + s.RunQemuWith(c, runArgs...) + + s.CheckCall(c, `ls .ssh/authorized_keys`) +} From 09bd518cd053148f84f560127ef71e7fbda573a7 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Fri, 23 Jun 2017 11:48:28 +0000 Subject: [PATCH 18/19] go fmt tests/cloud_init_test.go Signed-off-by: Sven Dowideit --- tests/cloud_init_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/cloud_init_test.go b/tests/cloud_init_test.go index 5a090f75..a83f854e 100644 --- a/tests/cloud_init_test.go +++ b/tests/cloud_init_test.go @@ -30,11 +30,11 @@ func (s *QemuSuite) TestIsoCloudConfig(c *C) { } func (s *QemuSuite) TestFatCloudConfig(c *C) { - runArgs := []string{ - "--fresh", - "--cloud-config-fat", - } - s.RunQemuWith(c, runArgs...) + runArgs := []string{ + "--fresh", + "--cloud-config-fat", + } + s.RunQemuWith(c, runArgs...) - s.CheckCall(c, `ls .ssh/authorized_keys`) + s.CheckCall(c, `ls .ssh/authorized_keys`) } From 19e2c91f1bfd34d7e5ea7c82b342091e9d1c9869 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 23 Jun 2017 23:39:16 +0200 Subject: [PATCH 19/19] Increasing raspberry image to 2G --- scripts/images/raspberry-pi-hypriot/scripts/build.sh | 2 +- scripts/images/raspberry-pi-hypriot64/scripts/build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/images/raspberry-pi-hypriot/scripts/build.sh b/scripts/images/raspberry-pi-hypriot/scripts/build.sh index 9be4198d..dfd7af49 100755 --- a/scripts/images/raspberry-pi-hypriot/scripts/build.sh +++ b/scripts/images/raspberry-pi-hypriot/scripts/build.sh @@ -11,7 +11,7 @@ cp assets/*.deb build/ #---build SD card image--- # size of root and boot partion (in MByte) -IMAGE_TOTAL_SIZE=500 +IMAGE_TOTAL_SIZE=2048 BOOT_PARTITION_START=2048 BOOT_PARTITION_SIZE=25 #---don't change here--- diff --git a/scripts/images/raspberry-pi-hypriot64/scripts/build.sh b/scripts/images/raspberry-pi-hypriot64/scripts/build.sh index c3724f45..51814f6e 100755 --- a/scripts/images/raspberry-pi-hypriot64/scripts/build.sh +++ b/scripts/images/raspberry-pi-hypriot64/scripts/build.sh @@ -11,7 +11,7 @@ cp assets/*.tar.gz build/ #---build SD card image--- # size of root and boot partion (in MByte) -IMAGE_TOTAL_SIZE=500 +IMAGE_TOTAL_SIZE=2048 BOOT_PARTITION_START=2048 BOOT_PARTITION_SIZE=25 #---don't change here---