mirror of
https://github.com/rancher/os.git
synced 2025-08-08 02:04:13 +00:00
Add upgrade flag to upgrade persistent console
This commit is contained in:
parent
8b4e6cc502
commit
ee73337f49
@ -58,6 +58,10 @@ func osSubcommands() []cli.Command {
|
|||||||
Name: "append",
|
Name: "append",
|
||||||
Usage: "kernel args to append by kexec",
|
Usage: "kernel args to append by kexec",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "upgrade-console",
|
||||||
|
Usage: "upgrade console even if persistent",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -157,7 +161,7 @@ func osUpgrade(c *cli.Context) {
|
|||||||
if c.Args().Present() {
|
if c.Args().Present() {
|
||||||
log.Fatalf("invalid arguments %v", c.Args())
|
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.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.String("append")); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,7 +180,7 @@ func yes(in *bufio.Reader, question string) bool {
|
|||||||
return strings.ToLower(line[0:1]) == "y"
|
return strings.ToLower(line[0:1]) == "y"
|
||||||
}
|
}
|
||||||
|
|
||||||
func startUpgradeContainer(image string, stage, force, reboot, kexec bool, kernelArgs string) error {
|
func startUpgradeContainer(image string, stage, force, reboot, kexec bool, upgradeConsole bool, kernelArgs string) error {
|
||||||
in := bufio.NewReader(os.Stdin)
|
in := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
command := []string{
|
command := []string{
|
||||||
@ -193,6 +197,18 @@ func startUpgradeContainer(image string, stage, force, reboot, kexec bool, kerne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if upgradeConsole {
|
||||||
|
cfg, err := config.LoadConfig()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.Rancher.ForceConsoleRebuild = true
|
||||||
|
if err := cfg.Save(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
container, err := compose.CreateService(nil, "os-upgrade", &project.ServiceConfig{
|
container, err := compose.CreateService(nil, "os-upgrade", &project.ServiceConfig{
|
||||||
LogDriver: "json-file",
|
LogDriver: "json-file",
|
||||||
Privileged: true,
|
Privileged: true,
|
||||||
|
@ -86,6 +86,7 @@ type RancherConfig struct {
|
|||||||
Debug bool `yaml:"debug,omitempty"`
|
Debug bool `yaml:"debug,omitempty"`
|
||||||
RmUsr bool `yaml:"rm_usr,omitempty"`
|
RmUsr bool `yaml:"rm_usr,omitempty"`
|
||||||
Log bool `yaml:"log,omitempty"`
|
Log bool `yaml:"log,omitempty"`
|
||||||
|
ForceConsoleRebuild bool `yaml:"force_console_rebuild,omitempty"`
|
||||||
Disable []string `yaml:"disable,omitempty"`
|
Disable []string `yaml:"disable,omitempty"`
|
||||||
ServicesInclude map[string]bool `yaml:"services_include,omitempty"`
|
ServicesInclude map[string]bool `yaml:"services_include,omitempty"`
|
||||||
Modules []string `yaml:"modules,omitempty"`
|
Modules []string `yaml:"modules,omitempty"`
|
||||||
|
@ -76,6 +76,10 @@ func (s *Service) shouldRebuild() (bool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
cfg, err := config.LoadConfig()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
for _, c := range containers {
|
for _, c := range containers {
|
||||||
outOfSync, err := c.(*docker.Container).OutOfSync(s.Service.Config().Image)
|
outOfSync, err := c.(*docker.Container).OutOfSync(s.Service.Config().Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -97,11 +101,24 @@ func (s *Service) shouldRebuild() (bool, error) {
|
|||||||
"rebuildLabelChanged": rebuildLabelChanged,
|
"rebuildLabelChanged": rebuildLabelChanged,
|
||||||
"outOfSync": outOfSync}).Debug("Rebuild values")
|
"outOfSync": outOfSync}).Debug("Rebuild values")
|
||||||
|
|
||||||
if origRebuildLabel == "always" || rebuildLabelChanged || origRebuildLabel != "false" && outOfSync {
|
rebuilding := false
|
||||||
|
if outOfSync {
|
||||||
|
if cfg.Rancher.ForceConsoleRebuild && s.Name() == "console" {
|
||||||
|
cfg.Rancher.ForceConsoleRebuild = false
|
||||||
|
if err := cfg.Save(); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
rebuilding = true
|
||||||
|
} else if origRebuildLabel == "always" || rebuildLabelChanged || origRebuildLabel != "false" {
|
||||||
|
rebuilding = true
|
||||||
|
} else {
|
||||||
|
logrus.Warnf("%s needs rebuilding", name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if rebuilding {
|
||||||
logrus.Infof("Rebuilding %s", name)
|
logrus.Infof("Rebuilding %s", name)
|
||||||
return true, err
|
return true, nil
|
||||||
} else if outOfSync {
|
|
||||||
logrus.Warnf("%s needs rebuilding", name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user