diff --git a/nix/host.nix b/nix/host.nix index 185b316..0613fe2 100644 --- a/nix/host.nix +++ b/nix/host.nix @@ -36,7 +36,8 @@ in IPMasquerade = "both"; }; }; - networking.firewall.trustedInterfaces = [ "ve-+" ]; + networking.firewall.trustedInterfaces = + [ (if config.networking.nftables.enable then "ve-*" else "ve-+") ]; networking.firewall.allowedTCPPorts = lib.optional (cfg.clusterPort != null) cfg.clusterPort; systemd.services.slackerbot = { diff --git a/slackerbot/internal/bot/bot.go b/slackerbot/internal/bot/bot.go index 53ee1c9..6fc5268 100644 --- a/slackerbot/internal/bot/bot.go +++ b/slackerbot/internal/bot/bot.go @@ -83,7 +83,7 @@ type Bot struct { type incoming struct { user, channel, ts, threadTS, text string dm bool - heard bool + heard bool } func (m incoming) owner() (string, model.OwnerKind) { @@ -268,6 +268,7 @@ func (b *Bot) onMessage(ctx context.Context, m incoming) { Channel: m.channel, ThreadTS: root, OwnerID: u.ID, ACPID: id, Title: title(m.text), CreatedAt: time.Now(), }) + log.Printf("thread: new thread %s/%s for %s %s (started by %s, session %s)", m.channel, root, u.Kind, u.ID, m.user, id) if w := b.where(ctx, m.channel); w != "" { text = "(You're in " + w + ". Each message starts with the sender's name.)\n" + text } diff --git a/slackerbot/internal/manager/manager.go b/slackerbot/internal/manager/manager.go index 5c979b1..1c006ee 100644 --- a/slackerbot/internal/manager/manager.go +++ b/slackerbot/internal/manager/manager.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "log" "math" "sort" "sync" @@ -210,7 +211,13 @@ func (m *Manager) Ensure(ctx context.Context, id string, kind model.OwnerKind) ( if !v.Used.Add(u.Size).Fits(v.Usable) { return u, &node.NodeFullError{Node: u.Node} } - return u, n.Start(ctx, m.spec(u)) + log.Printf("container: starting %s for %s %s on %s (drive %s, %s)", u.Machine, u.Kind, u.ID, u.Node, u.Drive, u.Size) + if err := n.Start(ctx, m.spec(u)); err != nil { + log.Printf("container: starting %s on %s failed: %v", u.Machine, u.Node, err) + return u, err + } + log.Printf("container: %s is running on %s", u.Machine, u.Node) + return u, nil } // The old home folder stays on its node, untouched. @@ -253,7 +260,12 @@ func (m *Manager) Poweroff(ctx context.Context, u *model.Owner) error { if err != nil { return err } - return n.Poweroff(ctx, u.Machine) + log.Printf("container: shutting down %s for %s %s on %s", u.Machine, u.Kind, u.ID, u.Node) + if err := n.Poweroff(ctx, u.Machine); err != nil { + log.Printf("container: shutting down %s on %s failed: %v", u.Machine, u.Node, err) + return err + } + return nil } func (m *Manager) RunningOwners(ctx context.Context) []model.Owner { diff --git a/slackerbot/internal/manager/migrate.go b/slackerbot/internal/manager/migrate.go index 134e574..2919ab5 100644 --- a/slackerbot/internal/manager/migrate.go +++ b/slackerbot/internal/manager/migrate.go @@ -110,6 +110,7 @@ func (m *Manager) Migrate(ctx context.Context, id string, opts MoveOptions) (*Mo _ = src.CloseExport(context.Background(), e) } if stopped { + log.Printf("container: restarting %s on %s after a failed move", u.Machine, u.Node) if err := src.Start(context.Background(), m.spec(u)); err != nil { return res, fmt.Errorf("%w (and restarting it on %s failed: %v)", cause, u.Node, err) } @@ -151,6 +152,7 @@ func (m *Manager) Migrate(ctx context.Context, id string, opts MoveOptions) (*Mo if opts.WaitIdle != nil { opts.WaitIdle(ctx) } + log.Printf("container: shutting down %s on %s to move it to %s", u.Machine, u.Node, target) if err := src.Poweroff(ctx, u.Machine); err != nil { return rollback(err) } @@ -185,6 +187,7 @@ func (m *Manager) Migrate(ctx context.Context, id string, opts MoveOptions) (*Mo return res, nil } progress(PhaseStart, copied) + log.Printf("container: starting %s on %s after the move from %s", u.Machine, target, oldNode) if err := dst.Start(ctx, m.spec(u)); err != nil { return res, fmt.Errorf("moved to %s, but starting it there failed: %w", target, err) }