system

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: BSD-3-Clause Imports: 56 Imported by: 0

Documentation

Overview

Package system owns Docker system-wide operations — prune, disk usage, host info — and the HTTP surface that exposes them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterSystem

func RegisterSystem(api huma.API, dockerService *docker.DockerClientService, systemService *SystemService, upgradeService *SystemUpgradeService, environmentService *environment.EnvironmentService, cfg *config.Config, activityService *activity.ActivityService, appCtx handlerutil.ActivityAppContext)

RegisterSystem registers system management endpoints using Huma. WebSocket statistics endpoints live in api/ws.

Types

type CheckUpgradeInput

type CheckUpgradeInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type CheckUpgradeOutput

type CheckUpgradeOutput struct {
	Body UpgradeCheckResultData
}

type ConvertDockerRunInput

type ConvertDockerRunInput struct {
	EnvironmentID string                         `path:"id" doc:"Environment ID"`
	Body          system.ConvertDockerRunRequest `doc:"Docker run command"`
}

type ConvertDockerRunOutput

type ConvertDockerRunOutput struct {
	Body system.ConvertDockerRunResponse
}

type Dependencies

type Dependencies struct {
	DB            *database.DB
	Config        *config.Config
	Docker        *docker.DockerClientService
	Container     *container.ContainerService
	Image         *image.ImageService
	Volume        *volume.VolumeService
	Network       *network.NetworkService
	Settings      *settings.SettingsService
	Activity      *activity.ActivityService
	SystemUpgrade *SystemUpgradeService
	Environment   *environment.EnvironmentService
}

Dependencies are the collaborators the system domain needs.

type GetDockerInfoInput

type GetDockerInfoInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type GetDockerInfoOutput

type GetDockerInfoOutput struct {
	Body dockerinfo.Info
}

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module wires the system domain and mounts its routes.

func New

func New(deps Dependencies) *Module

New builds the system domain from its dependencies.

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContext)

RegisterRoutes mounts the system endpoints. A nil module still registers, so OpenAPI spec generation can discover the routes without a service graph.

func (*Module) Service

func (m *Module) Service() *SystemService

Service exposes the system service to collaborators that need it directly, such as the scheduled prune job.

type PruneAllInput

type PruneAllInput struct {
	EnvironmentID string                 `path:"id" doc:"Environment ID"`
	Body          system.PruneAllRequest `doc:"Prune options"`
}

type PruneAllOutput

type PruneAllOutput struct {
	Body base.ApiResponse[system.PruneAllResult]
}

type StartAllContainersInput

type StartAllContainersInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type StartAllContainersOutput

type StartAllContainersOutput struct {
	Body base.ApiResponse[containertypes.ActionResult]
}

type StartAllStoppedContainersInput

type StartAllStoppedContainersInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type StartAllStoppedContainersOutput

type StartAllStoppedContainersOutput struct {
	Body base.ApiResponse[containertypes.ActionResult]
}

type StopAllContainersInput

type StopAllContainersInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type StopAllContainersOutput

type StopAllContainersOutput struct {
	Body base.ApiResponse[containertypes.ActionResult]
}

type SystemHandler

type SystemHandler struct {
	// contains filtered or unexported fields
}

SystemHandler handles system management endpoints.

func (*SystemHandler) CheckUpgradeAvailable

func (h *SystemHandler) CheckUpgradeAvailable(ctx context.Context, input *CheckUpgradeInput) (*CheckUpgradeOutput, error)

CheckUpgradeAvailable checks if a system upgrade is available.

func (*SystemHandler) ConvertDockerRun

func (h *SystemHandler) ConvertDockerRun(ctx context.Context, input *ConvertDockerRunInput) (*ConvertDockerRunOutput, error)

ConvertDockerRun converts a docker run command to docker-compose format.

func (*SystemHandler) GetDockerInfo

func (h *SystemHandler) GetDockerInfo(ctx context.Context, input *GetDockerInfoInput) (*GetDockerInfoOutput, error)

GetDockerInfo returns Docker daemon version and system information.

func (*SystemHandler) GetUpdateAllStatus

func (h *SystemHandler) GetUpdateAllStatus(ctx context.Context, input *UpdateAllStatusInput) (*UpdateAllStatusOutput, error)

GetUpdateAllStatus returns the latest update-all job for live progress polling.

func (*SystemHandler) Health

Health checks if the Docker daemon is responsive.

func (*SystemHandler) PruneAll

func (h *SystemHandler) PruneAll(ctx context.Context, input *PruneAllInput) (*PruneAllOutput, error)

PruneAll removes unused Docker resources.

func (*SystemHandler) StartAllContainers

func (h *SystemHandler) StartAllContainers(ctx context.Context, input *StartAllContainersInput) (*StartAllContainersOutput, error)

StartAllContainers starts all Docker containers.

func (*SystemHandler) StartAllStoppedContainers

StartAllStoppedContainers starts all stopped Docker containers.

func (*SystemHandler) StopAllContainers

func (h *SystemHandler) StopAllContainers(ctx context.Context, input *StopAllContainersInput) (*StopAllContainersOutput, error)

StopAllContainers stops all running Docker containers.

func (*SystemHandler) TriggerUpdateAll

func (h *SystemHandler) TriggerUpdateAll(ctx context.Context, input *TriggerUpdateAllInput) (*TriggerUpdateAllOutput, error)

TriggerUpdateAll starts a fleet-wide update, upgrading the manager first and then the remote agents (the latter resume after the manager restarts).

func (*SystemHandler) TriggerUpgrade

func (h *SystemHandler) TriggerUpgrade(ctx context.Context, input *TriggerUpgradeInput) (*TriggerUpgradeOutput, error)

TriggerUpgrade triggers a system upgrade.

type SystemHealthInput

type SystemHealthInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type SystemHealthOutput

type SystemHealthOutput struct {
	Status int `status:"200"`
}

type SystemService

type SystemService struct {
	// contains filtered or unexported fields
}

func NewSystemService

func NewSystemService(
	db *database.DB,
	dockerService *docker.DockerClientService,
	containerService *container.ContainerService,
	imageService *image.ImageService,
	volumeService *volume.VolumeService,
	networkService *network.NetworkService,
	settingsService *settings.SettingsService,
	activityService *activity.ActivityService,
) *SystemService

func (*SystemService) GetDiskUsagePath

func (s *SystemService) GetDiskUsagePath(ctx context.Context) string

func (*SystemService) PruneAll

func (s *SystemService) PruneAll(ctx context.Context, environmentID string, req system.PruneAllRequest) (*system.PruneAllResult, bool, error)

func (*SystemService) StartAllContainers

func (s *SystemService) StartAllContainers(ctx context.Context, environmentID string) (*containertypes.ActionResult, error)

func (*SystemService) StartAllStoppedContainers

func (s *SystemService) StartAllStoppedContainers(ctx context.Context, environmentID string) (*containertypes.ActionResult, error)

func (*SystemService) StartPruneAll

func (s *SystemService) StartPruneAll(ctx context.Context, environmentID string, req system.PruneAllRequest) *system.PruneAllResult

func (*SystemService) StopAllContainers

func (s *SystemService) StopAllContainers(ctx context.Context, environmentID string) (*containertypes.ActionResult, error)

type SystemUpgradeService

type SystemUpgradeService struct {
	// contains filtered or unexported fields
}

func NewSystemUpgradeService

func NewSystemUpgradeService(
	db *database.DB,
	dockerService *docker.DockerClientService,
	versionService *version.VersionService,
	eventService *event.EventService,
	settingsService *settings.SettingsService,
) *SystemUpgradeService

func (*SystemUpgradeService) AlreadyOnNewestImage

func (s *SystemUpgradeService) AlreadyOnNewestImage(ctx context.Context) bool

AlreadyOnNewestImage reports whether this environment's version check is confident it already runs the newest image. A triggered upgrade still pulls, but will then find nothing to swap in and skip the recreate — so callers can use this to stop waiting for a restart that is not coming.

func (*SystemUpgradeService) CanUpgrade

func (s *SystemUpgradeService) CanUpgrade(ctx context.Context) (bool, error)

CanUpgrade checks if self-upgrade is possible

func (*SystemUpgradeService) GetLatestUpdateAllJob

func (s *SystemUpgradeService) GetLatestUpdateAllJob(ctx context.Context) (*models.EnvironmentUpdateJob, error)

GetLatestUpdateAllJob returns the most recently created update-all job, or nil.

func (*SystemUpgradeService) ResumeUpdateAllOnStartup

func (s *SystemUpgradeService) ResumeUpdateAllOnStartup(ctx context.Context)

ResumeUpdateAllOnStartup is called once at manager startup. When the manager self-upgraded as the final step of an update-all (job left pending_restart), the agents phase already ran before the restart — so this finalizes the manager's own result and closes the job. It is a no-op when there is nothing pending.

func (*SystemUpgradeService) StartUpdateAll

StartUpdateAll begins a fleet-wide update. The agents phase runs first in the background (while the manager is up); the agents goroutine triggers the manager self-upgrade as its final step (job left pending_restart, finalized at next boot). Every environment pulls the latest image, whether or not it reports an update available.

func (*SystemUpgradeService) TriggerUpgradeViaCLI

func (s *SystemUpgradeService) TriggerUpgradeViaCLI(ctx context.Context, user models.User, target updater.SelfUpdateTarget) (string, error)

TriggerUpgradeViaCLI spawns the upgrade CLI command in a separate container and returns that upgrader container's ID. This avoids self-termination issues by running the upgrade from outside. A zero-value target upgrades the current container to its own image tag; the updater engine passes an explicit target with the resolved new image. Update-all uses the returned ID to tell an upgrade that recreated this container from one that found nothing to do — see watchManagerUpgraderInternal.

type TriggerUpdateAllInput

type TriggerUpdateAllInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type TriggerUpdateAllOutput

type TriggerUpdateAllOutput struct {
	Body base.ApiResponse[models.EnvironmentUpdateJob]
}

type TriggerUpgradeData

type TriggerUpgradeData struct {
	Message  string `json:"message" doc:"Response message"`
	UpToDate bool   `json:"upToDate" doc:"Environment already runs the newest image, so no restart is expected"`
}

TriggerUpgradeData reports the upgrade was accepted. UpToDate lets a client skip waiting for a restart: the upgrader still pulls, but when the environment already runs the newest image it finds nothing to swap in and no restart follows.

type TriggerUpgradeInput

type TriggerUpgradeInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type TriggerUpgradeOutput

type TriggerUpgradeOutput struct {
	Body base.ApiResponse[TriggerUpgradeData]
}

type UpdateAllStatusInput

type UpdateAllStatusInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type UpdateAllStatusOutput

type UpdateAllStatusOutput struct {
	Body base.ApiResponse[models.EnvironmentUpdateJob]
}

type UpgradeCheckResultData

type UpgradeCheckResultData struct {
	CanUpgrade bool   `json:"canUpgrade"`
	Error      bool   `json:"error"`
	Message    string `json:"message"`
}

UpgradeCheckResultData is the response for upgrade check.

Jump to

Keyboard shortcuts

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