restart fix + slack commands
This commit is contained in:
1 parent
e90c9f324b
commit
25fcf85855
22 files changed
+1077
-119
No files matched your search
@@ -248,6 +248,50 @@ func (m *Manager) EnsureProgress(ctx context.Context, id string, kind model.Owne
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// Restart stops a running container and starts it again, so it boots the
|
||||
// node's current system.
|
||||
func (m *Manager) Restart(ctx context.Context, id string, kind model.OwnerKind, progress func(StartEvent)) (*model.Owner, error) {
|
||||
if m.IsMigrating(id) {
|
||||
return nil, ErrMigrating
|
||||
}
|
||||
unlock := m.ownerMu.Lock(id)
|
||||
u, err := m.ownerRecord(id, kind)
|
||||
if err == nil && u.Node != "" {
|
||||
var n node.Node
|
||||
if n, err = m.nodeByName(u.Node); err == nil && n.IsRunning(u.Machine) {
|
||||
log.Printf("container: restarting %s for %s %s on %s", u.Machine, u.Kind, u.ID, u.Node)
|
||||
if err = n.Poweroff(ctx, u.Machine); err == nil {
|
||||
err = n.WaitStopped(ctx, u.Machine)
|
||||
}
|
||||
}
|
||||
}
|
||||
unlock()
|
||||
if err != nil {
|
||||
return u, err
|
||||
}
|
||||
return m.EnsureProgress(ctx, id, kind, progress)
|
||||
}
|
||||
|
||||
func (m *Manager) Outdated(ctx context.Context, u *model.Owner) bool {
|
||||
if u == nil || u.Node == "" {
|
||||
return false
|
||||
}
|
||||
n, err := m.nodeByName(u.Node)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
running, err := n.Running(ctx)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
for _, r := range running {
|
||||
if r.Name == u.Machine {
|
||||
return r.Outdated
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// The old home folder stays on its node, untouched.
|
||||
func (m *Manager) Recreate(id string) error {
|
||||
if m.IsMigrating(id) {
|
||||
|
||||
Reference in new issue
Block a user