kubernetes/kops · warning

error listing systemd services: %v

Error message

error listing systemd services: %v

What it means

Accumulated into the error slice by logDumperNode.dump (pkg/dump/dumper.go:396) when n.listSystemdUnits fails. listSystemdUnits runs `sudo systemctl list-units -t service ...` over the SSH connection; if that ExecPiped call errors, no systemd services can be enumerated and all per-service journalctl captures for this node are skipped. Note this is a warning-level condition: dumpNode logs it via klog and continues dumping the rest of the node.

Source

Thrown at pkg/dump/dumper.go:396

	}

	var errors []error

	// Capture kernel log
	if err := n.shellToFile(ctx, "sudo journalctl --output=short-precise -k", filepath.Join(n.dir, "kern.log")); err != nil {
		errors = append(errors, err)
	}

	// Capture full journal - needed so we can see e.g. disk mounts
	// This does duplicate the other files, but ensures we have all output
	if err := n.shellToFile(ctx, "sudo journalctl --output=short-precise", filepath.Join(n.dir, "journal.log")); err != nil {
		errors = append(errors, err)
	}

	// Capture logs from any systemd services in our list that are registered
	services, err := n.listSystemdUnits(ctx)
	if err != nil {
		errors = append(errors, fmt.Errorf("error listing systemd services: %v", err))
	}
	for _, s := range n.dumper.services {
		name := s + ".service"
		for _, service := range services {
			if service == name {
				if err := n.shellToFile(ctx, "sudo journalctl --output=cat -u "+name, filepath.Join(n.dir, s+".log")); err != nil {
					errors = append(errors, err)
				}
			}
		}
	}

	// Capture iptables configuration
	if err := n.shellToFile(ctx, "sudo iptables -t nat --list-rules", filepath.Join(n.dir, "iptables-nat.log")); err != nil {
		errors = append(errors, err)
	}
	if err := n.shellToFile(ctx, "sudo iptables -t filter --list-rules", filepath.Join(n.dir, "iptables-filter.log")); err != nil {
		errors = append(errors, err)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the wrapped 'error listing systemd units' cause; if it is context.DeadlineExceeded, raise --node-dump-timeout.
  2. Verify the node runs systemd: `ssh <node> command -v systemctl`; if not, expect this warning and ignore, or use a systemd-based image.
  3. SSH in manually and run the exact command (`sudo systemctl list-units -t service --no-pager --no-legend --all`) to see the real remote error.
  4. If the node was concurrently replaced/upgraded, re-run the dump against a stable node.
  5. Treat as non-fatal: dumpNode intentionally continues; only investigate if you need the service journal logs specifically.
Defensive patterns

Strategy: fallback

Validate before calling

// check systemd availability before relying on unit listing
hasSystemd, err := remoteCheck(ctx, client, "command -v systemctl")
if err != nil || !hasSystemd {
    klog.Warningf("node %s: no systemd; skipping service journals", name)
}

Try / catch

services, err := n.listSystemdUnits(ctx)
if err != nil {
    klog.Warningf("continuing without service journals: %v", err)
    services = nil // proceed with remaining dump steps
}

Prevention

When it happens

Trigger: n.listSystemdUnits(ctx) returns an error: the SSH ExecPiped of `sudo systemctl list-units -t service --no-pager --no-legend --all` fails — context timeout expired mid-command, remote session died, systemctl missing (non-systemd image), or non-zero exit from the remote command.

Common situations: Dumping an Alpine/non-systemd node image where systemctl does not exist; nodeDumpTimeout expiring on a heavily loaded node; SSH session dropped because the node is being recycled; older OS images with an incompatible systemctl version.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/b85bb63a568b9d2d. Report an issue: GitHub.