1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 06:40:31 +00:00

New console label to handle switching between persistent consoles

This commit is contained in:
Josh Curl
2016-06-09 21:31:07 -07:00
parent abfb45401a
commit 7f7d8765ca
3 changed files with 19 additions and 12 deletions

View File

@@ -102,24 +102,28 @@ func (s *Service) shouldRebuild(ctx context.Context) (bool, error) {
"rebuildLabelChanged": rebuildLabelChanged,
"outOfSync": outOfSync}).Debug("Rebuild values")
rebuilding := false
if newRebuildLabel == "always" {
return true, nil
}
if outOfSync {
if cfg.Rancher.ForceConsoleRebuild && s.Name() == "console" {
if err := config.Set("rancher.force_console_rebuild", false); err != nil {
return false, err
if s.Name() == "console" {
if cfg.Rancher.ForceConsoleRebuild {
if err := config.Set("rancher.force_console_rebuild", false); err != nil {
return false, err
}
return true, nil
}
rebuilding = true
} else if origRebuildLabel == "always" || rebuildLabelChanged || origRebuildLabel != "false" {
rebuilding = true
origConsoleLabel := containerInfo.Config.Labels[config.CONSOLE]
newConsoleLabel := s.Config().Labels[config.CONSOLE]
if newConsoleLabel != origConsoleLabel {
return true, nil
}
} else if rebuildLabelChanged || origRebuildLabel != "false" {
return true, nil
} else {
logrus.Warnf("%s needs rebuilding", name)
}
}
if rebuilding {
logrus.Infof("Rebuilding %s", name)
return true, nil
}
}
return false, nil
}
@@ -136,6 +140,7 @@ func (s *Service) Up(ctx context.Context, options options.Up) error {
return err
}
if shouldRebuild {
logrus.Infof("Rebuilding %s", s.Name())
cs, err := s.Service.Containers(ctx)
if err != nil {
return err