mirror of
https://github.com/rancher/os.git
synced 2025-08-31 14:23:11 +00:00
New console label to handle switching between persistent consoles
This commit is contained in:
@@ -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"
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user