diff --git a/config/types.go b/config/types.go index e1fa12a5..d4744216 100644 --- a/config/types.go +++ b/config/types.go @@ -31,6 +31,7 @@ const ( DETACH = "io.rancher.os.detach" CREATE_ONLY = "io.rancher.os.createonly" RELOAD_CONFIG = "io.rancher.os.reloadconfig" + CONSOLE = "io.rancher.os.console" SCOPE = "io.rancher.os.scope" REBUILD = "io.docker.compose.rebuild" SYSTEM = "system" diff --git a/docker/service.go b/docker/service.go index 7a58b6fc..e8b7125e 100644 --- a/docker/service.go +++ b/docker/service.go @@ -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 diff --git a/os-config.tpl.yml b/os-config.tpl.yml index ccd6b4f7..c31ba828 100644 --- a/os-config.tpl.yml +++ b/os-config.tpl.yml @@ -161,6 +161,7 @@ rancher: io.rancher.os.scope: system io.rancher.os.after: network io.docker.compose.rebuild: always + io.rancher.os.console: default net: host uts: host pid: host