diff --git a/cmd/control/install.go b/cmd/control/install.go index 09ac95d7..dec1ad63 100755 --- a/cmd/control/install.go +++ b/cmd/control/install.go @@ -939,6 +939,7 @@ func upgradeBootloader(device, baseName, bootDir, diskType string) error { for _, line := range lines { line = strings.TrimSpace(line) if strings.HasPrefix(line, "APPEND") { + log.Errorf("write new (%s) %s", filepath.Join(baseName, bootDir, "global.cfg"), err) // TODO: need to append any extra's the user specified ioutil.WriteFile(filepath.Join(baseName, bootDir, "global.cfg"), []byte(cfg), 0644) break diff --git a/cmd/control/os.go b/cmd/control/os.go index 5e5fbb43..b5e8822e 100644 --- a/cmd/control/os.go +++ b/cmd/control/os.go @@ -64,6 +64,10 @@ func osSubcommands() []cli.Command { Name: "upgrade-console", Usage: "upgrade console even if persistent", }, + cli.BoolFlag{ + Name: "debug", + Usage: "Run installer with debug output", + }, }, }, { @@ -187,7 +191,16 @@ func osUpgrade(c *cli.Context) error { if c.Args().Present() { log.Fatalf("invalid arguments %v", c.Args()) } - if err := startUpgradeContainer(image, c.Bool("stage"), c.Bool("force"), !c.Bool("no-reboot"), c.Bool("kexec"), c.Bool("upgrade-console"), c.String("append")); err != nil { + if err := startUpgradeContainer( + image, + c.Bool("stage"), + c.Bool("force"), + !c.Bool("no-reboot"), + c.Bool("kexec"), + c.Bool("upgrade-console"), + c.Bool("debug"), + c.String("append"), + ); err != nil { log.Fatal(err) } @@ -199,7 +212,7 @@ func osVersion(c *cli.Context) error { return nil } -func startUpgradeContainer(image string, stage, force, reboot, kexec bool, upgradeConsole bool, kernelArgs string) error { +func startUpgradeContainer(image string, stage, force, reboot, kexec, debug bool, upgradeConsole bool, kernelArgs string) error { command := []string{ "-t", "rancher-upgrade", "-r", config.Version, @@ -208,6 +221,9 @@ func startUpgradeContainer(image string, stage, force, reboot, kexec bool, upgra if kexec { command = append(command, "--kexec") } + if debug { + command = append(command, "--debug") + } kernelArgs = strings.TrimSpace(kernelArgs) if kernelArgs != "" { diff --git a/tests/upgrade_test.go b/tests/upgrade_test.go index b3b28c67..4e0e11fa 100755 --- a/tests/upgrade_test.go +++ b/tests/upgrade_test.go @@ -10,6 +10,7 @@ import ( ) func (s *QemuSuite) TestUpgrade050(c *C) { + // install 0.5.0, and then upgrade to `this` version s.commonTestCode(c, "v0.5.0", "default") } func (s *QemuSuite) TestUpgrade061(c *C) { @@ -21,6 +22,12 @@ func (s *QemuSuite) TestUpgrade070(c *C) { func (s *QemuSuite) TestUpgrade071(c *C) { s.commonTestCode(c, "v0.7.1", "default") } +func (s *QemuSuite) TestUpgrade090(c *C) { + s.commonTestCode(c, "v0.9.0", "default") +} +func (s *QemuSuite) TestUpgrade100(c *C) { + s.commonTestCode(c, "v1.0.0", "default") +} func (s *QemuSuite) TestUpgrade071Persistent(c *C) { s.commonTestCode(c, "v0.7.1", "ubuntu") } @@ -126,6 +133,9 @@ sync s.CheckOutput(c, "ros version "+Version+"\n", Equals, "sudo ros -v") s.CheckOutput(c, consoleVer, Equals, "sudo system-docker ps --filter name=^/console$ --format {{.Image}}") + // Make sure the original installed boot cmdline append value + s.CheckOutput(c, ".*rancher.password=rancher.*", Matches, "cat /proc/cmdline") + s.Stop(c) } @@ -153,7 +163,7 @@ echo "---------------------------------- generic" 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.password=rancher -i rancher/os:%s +sudo ros install --force --no-reboot --device /dev/vda -c config.yml --append "rancher.password=rancher rancher.cloud_init.datasources=[invalid]" -i rancher/os:%s sync `, startWithVersion)) time.Sleep(500 * time.Millisecond) @@ -168,6 +178,17 @@ sync s.CheckOutput(c, "ros version "+startWithVersion+"\n", Equals, "sudo ros -v") + if startWithVersion != "v0.5.0" && startWithVersion != "v0.6.1" { + //s.CheckOutput(c, ".*password=ranc.*", Matches, "cat /proc/cmdline") + cmdline := s.CheckOutput(c, "", Not(Equals), "cat /proc/cmdline") + if !strings.Contains(cmdline, "rancher.password=rancher") { + c.Errorf("output(%s) does not contain(%s)", cmdline, "rancher.password=rancher") + } + if !strings.Contains(cmdline, "rancher.cloud_init.datasources=[invalid]") { + c.Errorf("output(%s) does not contain(%s)", cmdline, "rancher.cloud_init.datasources=[invalid]") + } + } + if console != "default" { // Can't preload the startWithVersion console image, as some don't exist by that name - not sure how to approach that //s.PullAndLoadImage(c, fmt.Sprintf("rancher/os-%sconsole:%s", console, startWithVersion)) @@ -195,5 +216,17 @@ sync s.CheckOutput(c, consoleVer, Not(Equals), "sudo system-docker ps --filter name=^/console$ --format {{.Image}}") } + if startWithVersion != "v0.5.0" && startWithVersion != "v0.6.1" { + // Make sure the original installed boot cmdline append value + // s.CheckOutput(c, ".*rancher.password=rancher.*", Matches, "cat /proc/cmdline") + cmdline := s.CheckOutput(c, "", Not(Equals), "cat /proc/cmdline") + if !strings.Contains(cmdline, "rancher.password=rancher") { + c.Errorf("output(%s) does not contain(%s)", cmdline, "rancher.password=rancher") + } + if !strings.Contains(cmdline, "rancher.cloud_init.datasources=[invalid]") { + c.Errorf("output(%s) does not contain(%s)", cmdline, "rancher.cloud_init.datasources=[invalid]") + } + } + s.Stop(c) }