Documentation
¶
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) ContainerLogsTail(ctx context.Context, containerID string, n int) ([]string, int, error)
- func (c *Client) ContainerStats(ctx context.Context, containerID string) (ContainerStatsSample, error)
- func (c *Client) EngineID(ctx context.Context) (string, error)
- func (c *Client) GetCloudContainers(ctx context.Context) ([]*apptypes.ContainerService, error)
- func (c *Client) GetEnabledContainers(ctx context.Context) ([]*apptypes.ContainerService, error)
- func (c *Client) GetOtherContainers(ctx context.Context) ([]OtherContainer, error)
- func (c *Client) HostSpecs(ctx context.Context) HostSpec
- func (c *Client) Hostname(ctx context.Context) string
- func (c *Client) InspectCloud(ctx context.Context, containerID string) (CloudInfo, error)
- func (c *Client) RestartCount(ctx context.Context, containerID string) int
- func (c *Client) ServerVersion(ctx context.Context) string
- func (c *Client) WatchEvents(ctx context.Context) (<-chan events.Message, <-chan error)
- type CloudInfo
- type ContainerStatsSample
- type HostSpec
- type OtherContainer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Docker client with our business logic
func (*Client) ContainerLogsTail ¶
func (c *Client) ContainerLogsTail(ctx context.Context, containerID string, n int) ([]string, int, error)
ContainerLogsTail returns the last n log lines of a container plus the total captured byte size, reading both stdout and stderr.
func (*Client) ContainerStats ¶
func (c *Client) ContainerStats(ctx context.Context, containerID string) (ContainerStatsSample, error)
ContainerStats reads a single (non-streaming) docker stats sample for a container via the one-shot stats endpoint. It is read-only and used only by the optional cloud module. PreCPUStats is intentionally ignored — it is zero for a one-shot read, so CPU percentages are computed by the caller across successive samples.
func (*Client) EngineID ¶
EngineID returns the docker engine ID — the stable host fingerprint and the cloud's billable unit. Persisted by dockerd; survives reboots/reinstalls.
func (*Client) GetCloudContainers ¶
GetCloudContainers lists docktail-managed containers for cloud reporting, INCLUDING stopped/exited ones — unlike GetEnabledContainers, which is running-only because the serve reconciler must never target a dead container. Reporting stopped containers lets the cloud render them as down rather than dropping them, and reserves "removed" for containers that truly leave Docker.
Running containers are parsed at full fidelity (multiple/indexed services and funnel included). A non-running container whose live parse fails — direct mode needs a running IP — falls back to a minimal entry keyed by the same primary service name it carries when running, so it stays in the catalog as a down service instead of being seen as removed. Limitation: a stopped container that declares multiple indexed services reports only its primary service until it is running again.
func (*Client) GetEnabledContainers ¶
GetEnabledContainers returns all running containers managed by DockTail. A container can be managed by a Tailscale service, a funnel, or both.
func (*Client) GetOtherContainers ¶
func (c *Client) GetOtherContainers(ctx context.Context) ([]OtherContainer, error)
GetOtherContainers lists every container that is NOT a docktail-managed service (neither docktail.enable nor docktail.funnel.enable set), INCLUDING stopped ones, for the cloud's container-inventory view. It is read-only and builds each entry straight from the container-list summary — no per-container inspect — so it stays cheap even on a busy host. Used only by the cloud module (DOCKTAIL_CLOUD_KEY set); docktail-managed containers are reported separately by GetCloudContainers as services.
func (*Client) HostSpecs ¶
HostSpecs reads static host capacity from `docker info` (best-effort; zero values on error). Read once at agent start — these do not change at runtime.
func (*Client) InspectCloud ¶
InspectCloud inspects a container and extracts the runtime fields the cloud catalog wants. It is read-only.
func (*Client) RestartCount ¶
RestartCount best-effort reads a container's live restart count via inspect.
func (*Client) ServerVersion ¶
ServerVersion returns the docker server version string (best-effort).
type CloudInfo ¶
type CloudInfo struct {
Image string
ImageTag string
State string // running/exited/restarting/paused/created
Health string // healthy/unhealthy/starting (empty if no healthcheck)
RestartCount int
ComposeProject string
ComposeService string
Networks []string
}
CloudInfo is the runtime enrichment the cloud catalog needs that the reconciler's ContainerService does not already carry.
type ContainerStatsSample ¶
type ContainerStatsSample struct {
CPUTotalUsage uint64 // cumulative container CPU time (ns)
CPUSystemUsage uint64 // cumulative host CPU time (ns)
OnlineCPUs uint64 // CPUs available, for percentage normalization
MemUsageBytes int64 // working set: usage minus inactive file cache
MemLimitBytes int64 // effective limit: container limit, else host total
}
ContainerStatsSample is a single one-shot resource reading for a container. CPU is reported as the raw cumulative counters docker exposes; a percentage is the delta between two samples, so the caller keeps the previous one. Memory is the cache-adjusted working set and its effective limit, both ready to use directly.
type HostSpec ¶
type HostSpec struct {
OS string
KernelVersion string
Arch string
CPUCores int
MemTotalBytes int64
}
HostSpec is static host capacity read once from `docker info` (display-only).
type OtherContainer ¶
type OtherContainer struct {
ID string // short container id — identity within the host
IsAgent bool // this container is running the reporting DockTail agent
Name string
Image string
ImageTag string
State string // running/exited/restarting/paused/created
Status string // human status line, e.g. "Up 3 hours (healthy)"
Health string // healthy/unhealthy/starting (best-effort, parsed from Status)
ComposeProject string
ComposeService string
Ports []string
CreatedAt int64 // unix seconds the container was created
}
OtherContainer is a NON-docktail container as seen for cloud reporting: limited, read-only metadata only. It carries no exec/deploy surface and is never health-checked — the cloud renders it as plain inventory alongside the monitored services.