{"record":{"id":"b85bb63a568b9d2d","repo":"kubernetes/kops","slug":"error-listing-systemd-services-v","errorCode":null,"errorMessage":"error listing systemd services: %v","messagePattern":"error listing systemd services: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/dump/dumper.go","lineNumber":396,"sourceCode":"\t}\n\n\tvar errors []error\n\n\t// Capture kernel log\n\tif err := n.shellToFile(ctx, \"sudo journalctl --output=short-precise -k\", filepath.Join(n.dir, \"kern.log\")); err != nil {\n\t\terrors = append(errors, err)\n\t}\n\n\t// Capture full journal - needed so we can see e.g. disk mounts\n\t// This does duplicate the other files, but ensures we have all output\n\tif err := n.shellToFile(ctx, \"sudo journalctl --output=short-precise\", filepath.Join(n.dir, \"journal.log\")); err != nil {\n\t\terrors = append(errors, err)\n\t}\n\n\t// Capture logs from any systemd services in our list that are registered\n\tservices, err := n.listSystemdUnits(ctx)\n\tif err != nil {\n\t\terrors = append(errors, fmt.Errorf(\"error listing systemd services: %v\", err))\n\t}\n\tfor _, s := range n.dumper.services {\n\t\tname := s + \".service\"\n\t\tfor _, service := range services {\n\t\t\tif service == name {\n\t\t\t\tif err := n.shellToFile(ctx, \"sudo journalctl --output=cat -u \"+name, filepath.Join(n.dir, s+\".log\")); err != nil {\n\t\t\t\t\terrors = append(errors, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Capture iptables configuration\n\tif err := n.shellToFile(ctx, \"sudo iptables -t nat --list-rules\", filepath.Join(n.dir, \"iptables-nat.log\")); err != nil {\n\t\terrors = append(errors, err)\n\t}\n\tif err := n.shellToFile(ctx, \"sudo iptables -t filter --list-rules\", filepath.Join(n.dir, \"iptables-filter.log\")); err != nil {\n\t\terrors = append(errors, err)","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/dump/dumper.go#L378-L414","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the wrapped 'error listing systemd units' cause; if it is context.DeadlineExceeded, raise --node-dump-timeout.","Verify the node runs systemd: `ssh <node> command -v systemctl`; if not, expect this warning and ignore, or use a systemd-based image.","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.","If the node was concurrently replaced/upgraded, re-run the dump against a stable node.","Treat as non-fatal: dumpNode intentionally continues; only investigate if you need the service journal logs specifically."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// check systemd availability before relying on unit listing\nhasSystemd, err := remoteCheck(ctx, client, \"command -v systemctl\")\nif err != nil || !hasSystemd {\n    klog.Warningf(\"node %s: no systemd; skipping service journals\", name)\n}","typeGuard":null,"tryCatchPattern":"services, err := n.listSystemdUnits(ctx)\nif err != nil {\n    klog.Warningf(\"continuing without service journals: %v\", err)\n    services = nil // proceed with remaining dump steps\n}","preventionTips":["Use systemd-based node images so systemctl exists on every node.","Configure NOPASSWD sudo for the SSH user used by the dumper.","Watch for context deadline errors and raise --node-dump-timeout accordingly."],"tags":["ssh","systemd","node-dump","go"],"backgroundTag":"remote-command-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}