mirror of
https://github.com/rancher/os.git
synced 2025-09-01 14:48:55 +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"
|
DETACH = "io.rancher.os.detach"
|
||||||
CREATE_ONLY = "io.rancher.os.createonly"
|
CREATE_ONLY = "io.rancher.os.createonly"
|
||||||
RELOAD_CONFIG = "io.rancher.os.reloadconfig"
|
RELOAD_CONFIG = "io.rancher.os.reloadconfig"
|
||||||
|
CONSOLE = "io.rancher.os.console"
|
||||||
SCOPE = "io.rancher.os.scope"
|
SCOPE = "io.rancher.os.scope"
|
||||||
REBUILD = "io.docker.compose.rebuild"
|
REBUILD = "io.docker.compose.rebuild"
|
||||||
SYSTEM = "system"
|
SYSTEM = "system"
|
||||||
|
@@ -102,24 +102,28 @@ func (s *Service) shouldRebuild(ctx context.Context) (bool, error) {
|
|||||||
"rebuildLabelChanged": rebuildLabelChanged,
|
"rebuildLabelChanged": rebuildLabelChanged,
|
||||||
"outOfSync": outOfSync}).Debug("Rebuild values")
|
"outOfSync": outOfSync}).Debug("Rebuild values")
|
||||||
|
|
||||||
rebuilding := false
|
if newRebuildLabel == "always" {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
if outOfSync {
|
if outOfSync {
|
||||||
if cfg.Rancher.ForceConsoleRebuild && s.Name() == "console" {
|
if s.Name() == "console" {
|
||||||
if err := config.Set("rancher.force_console_rebuild", false); err != nil {
|
if cfg.Rancher.ForceConsoleRebuild {
|
||||||
return false, err
|
if err := config.Set("rancher.force_console_rebuild", false); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
rebuilding = true
|
origConsoleLabel := containerInfo.Config.Labels[config.CONSOLE]
|
||||||
} else if origRebuildLabel == "always" || rebuildLabelChanged || origRebuildLabel != "false" {
|
newConsoleLabel := s.Config().Labels[config.CONSOLE]
|
||||||
rebuilding = true
|
if newConsoleLabel != origConsoleLabel {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
} else if rebuildLabelChanged || origRebuildLabel != "false" {
|
||||||
|
return true, nil
|
||||||
} else {
|
} else {
|
||||||
logrus.Warnf("%s needs rebuilding", name)
|
logrus.Warnf("%s needs rebuilding", name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rebuilding {
|
|
||||||
logrus.Infof("Rebuilding %s", name)
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
@@ -136,6 +140,7 @@ func (s *Service) Up(ctx context.Context, options options.Up) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if shouldRebuild {
|
if shouldRebuild {
|
||||||
|
logrus.Infof("Rebuilding %s", s.Name())
|
||||||
cs, err := s.Service.Containers(ctx)
|
cs, err := s.Service.Containers(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@@ -161,6 +161,7 @@ rancher:
|
|||||||
io.rancher.os.scope: system
|
io.rancher.os.scope: system
|
||||||
io.rancher.os.after: network
|
io.rancher.os.after: network
|
||||||
io.docker.compose.rebuild: always
|
io.docker.compose.rebuild: always
|
||||||
|
io.rancher.os.console: default
|
||||||
net: host
|
net: host
|
||||||
uts: host
|
uts: host
|
||||||
pid: host
|
pid: host
|
||||||
|
Reference in New Issue
Block a user