kubernetes/kops · error

error doing systemd show %s: %v Output: %s

Error message

error doing systemd show %s: %v
Output: %s

What it means

getSystemdStatus runs `systemctl show --all <name>` to read unit properties; any non-zero exit of systemctl is wrapped in this error. It means nodeup could not query systemd's view of the service, so Find/RenderLocal cannot determine the service state.

Source

Thrown at upup/pkg/fi/nodeup/nodetasks/service.go:149

	}
	if s.ManageState == nil {
		s.ManageState = new(true)
	}

	// Default Enabled to be the same as running
	if s.Enabled == nil {
		s.Enabled = s.Running
	}

	return s
}

func getSystemdStatus(name string) (map[string]string, error) {
	klog.V(2).Infof("querying state of service %q", name)
	cmd := exec.Command("systemctl", "show", "--all", name)
	output, err := cmd.CombinedOutput()
	if err != nil {
		return nil, fmt.Errorf("error doing systemd show %s: %v\nOutput: %s", name, err, output)
	}
	properties := make(map[string]string)
	for _, line := range strings.Split(string(output), "\n") {
		if line == "" {
			continue
		}
		tokens := strings.SplitN(line, "=", 2)
		if len(tokens) != 2 {
			klog.Warningf("Ignoring line in systemd show output: %q", line)
			continue
		}
		properties[tokens[0]] = tokens[1]
	}
	return properties, nil
}

func (_ *Service) systemdSystemPath() (string, error) {
	d, err := distributions.FindDistribution("/")

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the embedded Output in the error for systemctl's own message.
  2. Confirm the host actually runs systemd: `ps -p 1 -o comm=` should print systemd.
  3. Verify the service unit name is correct and valid (`systemd-escape` if needed).
  4. Check dbus: systemctl failed with 'Failed to connect to bus' typically indicates dbus/systemd must be restarted.

Example fix

// before (container with no systemd)
$ nodeup  # error doing systemd show kubelet.service
// after: run nodeup on a systemd host, or verify unit
$ systemctl cat kubelet.service
Defensive patterns

Strategy: validation

Validate before calling

if init, _ := ioutil.ReadFile("/proc/1/comm"); strings.TrimSpace(string(init)) != "systemd" {
    return errors.New("systemd not running as PID 1; getSystemdStatus will fail")
}

Try / catch

if _, err := getSystemdStatus(name); err != nil {
    if strings.Contains(err.Error(), "Failed to connect to bus") {
        // restart dbus/systemd or fail bootstrap with clear message
    }
}

Prevention

When it happens

Trigger: systemctl exits non-zero: the unit name is invalid, systemd is not running as PID 1 (containers/chroot), dbus is broken, or systemctl binary is missing.

Common situations: Running nodeup inside a container without systemd; unit files with invalid names/escaping; systemd/dbus in a failed state after an upgrade; minimal images without full systemd.

Related errors


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