doctor

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: GPL-3.0, LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package doctor provides host prerequisite checks for sind.

Index

Constants

View Source
const CgroupRoot = "/sys/fs/cgroup"

CgroupRoot is where the unified cgroup2 hierarchy that sind needs is mounted. A systemd host in hybrid mode mounts cgroup2 elsewhere (/sys/fs/cgroup/unified) and runs containers on cgroup v1.

View Source
const MinDockerMajor = 28

MinDockerMajor is the minimum required Docker Engine major version.

View Source
const MinInotifyInstances = 1024

MinInotifyInstances is the fs.inotify.max_user_instances that clusters of 10 or more nodes need. The systemd and journald of every node take inotify instances of the host's root user, and the kernel's default of 128 runs out first.

Variables

This section is empty.

Functions

func CgroupInfo

func CgroupInfo(fs afero.Fs) (mountPath string, hasV2, hasNsdelegate bool)

CgroupInfo reads /proc/mounts from fs. hasV2 reports whether cgroup2 is mounted at CgroupRoot, the unified hierarchy, and hasNsdelegate whether that mount has the nsdelegate option. mountPath is CgroupRoot then, or where else cgroup2 is mounted (a hybrid host), or empty.

func CheckDockerVersion

func CheckDockerVersion(version string) error

CheckDockerVersion returns an error if the Docker version string is below MinDockerMajor or cannot be parsed.

func DockerUnreachable added in v0.11.0

func DockerUnreachable(err error) (detail, remediation string)

DockerUnreachable describes why the docker CLI could not reach the daemon: the detail "not reachable: " followed by the first line of the error, and the commands that fix it when the cause is a missing docker CLI, a user outside the docker group or a daemon that is not running.

func ErrorLine added in v0.11.0

func ErrorLine(err error) string

ErrorLine returns the first line of what a failed command wrote to stderr, or of err's message when it wrote nothing: the line that says what went wrong, for the detail of a check.

func InotifyInstances added in v0.11.0

func InotifyInstances(fs afero.Fs) (n int, ok bool)

InotifyInstances reads fs.inotify.max_user_instances from fs. ok is false when it cannot be read or parsed.

func KernelRelease added in v0.11.0

func KernelRelease(fs afero.Fs) (release string, ok bool)

KernelRelease reads the release of the running kernel from fs. ok is false when it cannot be read.

func NsdelegateRemediation added in v0.11.0

func NsdelegateRemediation(mountPath string) string

NsdelegateRemediation returns the commands that remount cgroup2 at mountPath with nsdelegate on the Docker host, and keep the option across reboots there.

func ParseVersion

func ParseVersion(s string) (major, minor int, err error)

ParseVersion extracts the major and minor version numbers from a Docker version string such as "28.0.0" or "29.3.1-beta.1".

func ProbeCgroupInfo added in v0.11.0

func ProbeCgroupInfo(ctx context.Context, client *docker.Client, image string) (mountPath string, hasV2, hasNsdelegate bool, err error)

ProbeCgroupInfo is CgroupInfo for the kernel the Docker daemon runs on, wherever that is: it reads the mount table in a throwaway container of image, without a network and with cat as the entrypoint, as a custom node image may set one. On a cgroup v2 daemon a container has cgroup2 mounted at CgroupRoot, and the kernel shows nsdelegate, an option of the whole cgroup2 hierarchy, in every cgroup2 mount, in a container's cgroup namespace too. docker run pulls image if the daemon does not have it.

Types

type DaemonLocation added in v0.11.0

type DaemonLocation struct {
	// Endpoint is the address at which the docker CLI reaches the daemon.
	Endpoint docker.Endpoint
	// Elsewhere says why the daemon does not run on this machine, empty
	// when it does.
	Elsewhere string
}

DaemonLocation is where the Docker daemon runs, as far as the machine that runs the docker CLI can tell.

func LocateDaemon added in v0.11.0

func LocateDaemon(ctx context.Context, client *docker.Client, fs afero.Fs, info *docker.DaemonInfo) (DaemonLocation, error)

LocateDaemon tells whether the Docker daemon runs on this machine, whose files fs holds. It does not when the docker CLI reaches it other than through a unix socket (see docker.Client.Endpoint), when info is Docker Desktop's, whose daemon runs in a VM, or when info names another kernel release than this machine runs. A container shares its host's kernel, so a CI job in a container that reaches the host's daemon through a mounted socket counts as local. info is nil when the daemon is not reachable; only the endpoint counts then.

The answer is a heuristic: a unix socket can be forwarded from another host that runs the same kernel release, and a TCP endpoint can be this machine's own daemon.

func (DaemonLocation) Local added in v0.11.0

func (l DaemonLocation) Local() bool

Local reports whether the daemon runs on this machine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL