takodstate

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SchemaVersion = 1
)

Variables

View Source
var ErrNotFound = errors.New("takod state not found")

Functions

func PersistDesiredToServers added in v0.10.0

func PersistDesiredToServers(pool *ssh.Pool, cfg *config.Config, environment string, serverNames []string, desired *DesiredRevision, event Event, verbose bool) error

PersistDesiredToServers durably records placement/config intent before any workload mutation. Actual snapshots remain untouched until reconciliation finishes, so an interrupted operation is visible as desired/actual drift.

func PersistToServers

func PersistToServers(pool *ssh.Pool, cfg *config.Config, environment string, serverNames []string, desired *DesiredRevision, actual *ActualSnapshot, nodeActual map[string]*ActualSnapshot, event Event, verbose bool) error

func StaleNodeActualNames added in v0.4.8

func StaleNodeActualNames(previous *ActualSnapshot, current *ActualSnapshot, currentNodeActual map[string]*ActualSnapshot) []string

StaleNodeActualNames returns previous node snapshots that are no longer active.

Types

type ActualNodeSnapshot

type ActualNodeSnapshot struct {
	Node       string                   `json:"node"`
	Services   map[string]ActualService `json:"services"`
	CapturedAt time.Time                `json:"capturedAt"`
}

type ActualService

type ActualService struct {
	Name              string            `json:"name"`
	Image             string            `json:"image,omitempty"`
	RevisionImages    map[string]string `json:"revisionImages,omitempty"`
	Replicas          int               `json:"replicas"`
	Containers        []string          `json:"containers,omitempty"`
	ConfigHash        string            `json:"configHash,omitempty"`
	RuntimeID         string            `json:"runtimeId,omitempty"`
	Persistent        bool              `json:"persistent,omitempty"`
	CurrentRevision   string            `json:"currentRevision,omitempty"`
	PreviousRevision  string            `json:"previousRevision,omitempty"`
	WarmingRevisions  []string          `json:"warmingRevisions,omitempty"`
	DeployStrategy    string            `json:"deployStrategy,omitempty"`
	ActiveContainers  []string          `json:"activeContainers,omitempty"`
	WarmingContainers []string          `json:"warmingContainers,omitempty"`
}

type ActualSnapshot

type ActualSnapshot struct {
	SchemaVersion int                           `json:"schemaVersion"`
	Project       string                        `json:"project"`
	Environment   string                        `json:"environment"`
	Node          string                        `json:"node,omitempty"`
	TargetNodes   []string                      `json:"targetNodes,omitempty"`
	Services      map[string]ActualService      `json:"services"`
	Nodes         map[string]ActualNodeSnapshot `json:"nodes,omitempty"`
	CapturedAt    time.Time                     `json:"capturedAt"`
}

func BuildActualSnapshot

func BuildActualSnapshot(project string, environment string, targetNodes []string, actual map[string]*reconcile.ActualService) *ActualSnapshot

func BuildActualSnapshotWithNodes

func BuildActualSnapshotWithNodes(project string, environment string, targetNodes []string, actual map[string]*reconcile.ActualService, nodeActual map[string]map[string]*reconcile.ActualService) *ActualSnapshot

func BuildNodeActualSnapshot

func BuildNodeActualSnapshot(project string, environment string, node string, actual map[string]*reconcile.ActualService) *ActualSnapshot

type DesiredBuild added in v0.9.0

type DesiredBuild struct {
	Context    string   `json:"context"`
	ArgKeys    []string `json:"argKeys,omitempty"`
	Target     string   `json:"target,omitempty"`
	Dockerfile string   `json:"dockerfile,omitempty"`
}

type DesiredRevision

type DesiredRevision struct {
	SchemaVersion int                       `json:"schemaVersion"`
	RevisionID    string                    `json:"revisionId"`
	Project       string                    `json:"project"`
	Environment   string                    `json:"environment"`
	Source        string                    `json:"source"`
	TargetNodes   []string                  `json:"targetNodes"`
	Builds        map[string]DesiredBuild   `json:"builds,omitempty"`
	Services      map[string]DesiredService `json:"services"`
	Git           GitInfo                   `json:"git,omitempty"`
	CreatedAt     time.Time                 `json:"createdAt"`
}

func BuildDesiredRevision

func BuildDesiredRevision(cfg *config.Config, environment string, source string, services map[string]config.ServiceConfig, imageRefs map[string]string, targetNodes []string, git GitInfo) (*DesiredRevision, error)

func BuildDesiredRevisionWithAssignments added in v0.10.0

func BuildDesiredRevisionWithAssignments(cfg *config.Config, environment string, source string, services map[string]config.ServiceConfig, imageRefs map[string]string, targetNodes []string, assignments map[string][]scheduler.Assignment, git GitInfo) (*DesiredRevision, error)

func BuildDesiredRevisionWithPlacementIntent added in v0.10.0

func BuildDesiredRevisionWithPlacementIntent(cfg *config.Config, environment string, source string, services map[string]config.ServiceConfig, imageRefs map[string]string, targetNodes []string, assignments map[string][]scheduler.Assignment, pendingRemovals map[string]config.ServiceConfig, git GitInfo) (*DesiredRevision, error)

BuildDesiredRevisionWithPlacementIntent retains removal-pending service bindings until cleanup succeeds, making interrupted removals retryable.

func BuildDesiredRevisionWithPlacementSnapshot added in v0.10.0

func BuildDesiredRevisionWithPlacementSnapshot(cfg *config.Config, environment string, source string, services map[string]config.ServiceConfig, imageRefs map[string]string, targetNodes []string, assignments map[string][]scheduler.Assignment, pendingRemovals map[string]config.ServiceConfig, preservedServices map[string]DesiredService, git GitInfo) (*DesiredRevision, error)

BuildDesiredRevisionWithPlacementSnapshot carries prior desired-service records that are outside the current workflow's scope. This is necessary for targeted and non-removal operations: rewriting desired state must not clear an unrelated removalPending marker or forget a workload removed from the operator's current config before a full deploy reconciles it.

type DesiredService

type DesiredService struct {
	APIVersion      string                         `json:"apiVersion,omitempty"`
	Kind            string                         `json:"kind,omitempty"`
	Name            string                         `json:"name"`
	WorkloadKind    string                         `json:"workloadKind,omitempty"`
	Type            string                         `json:"type"`
	Image           string                         `json:"image,omitempty"`
	ImageFrom       string                         `json:"imageFrom,omitempty"`
	Build           string                         `json:"build,omitempty"`
	BuildArgKeys    []string                       `json:"buildArgKeys,omitempty"`
	BuildTarget     string                         `json:"buildTarget,omitempty"`
	Command         string                         `json:"command,omitempty"`
	CommandArgs     []string                       `json:"commandArgs,omitempty"`
	Entrypoint      string                         `json:"entrypoint,omitempty"`
	EntrypointArgs  []string                       `json:"entrypointArgs,omitempty"`
	Labels          map[string]string              `json:"labels,omitempty"`
	Port            int                            `json:"port,omitempty"`
	Replicas        int                            `json:"replicas"`
	Assignments     []scheduler.Assignment         `json:"assignments,omitempty"`
	Restart         string                         `json:"restart,omitempty"`
	Persistent      bool                           `json:"persistent,omitempty"`
	Placement       *config.PlacementConfig        `json:"placement,omitempty"`
	Domains         []string                       `json:"domains,omitempty"`
	Volumes         []string                       `json:"volumes,omitempty"`
	Files           []config.ServiceFileConfig     `json:"files,omitempty"`
	EnvKeys         []string                       `json:"envKeys,omitempty"`
	EnvFile         bool                           `json:"envFile,omitempty"`
	User            string                         `json:"user,omitempty"`
	WorkingDir      string                         `json:"workingDir,omitempty"`
	StopGracePeriod string                         `json:"stopGracePeriod,omitempty"`
	Init            bool                           `json:"init,omitempty"`
	ExtraHosts      []string                       `json:"extraHosts,omitempty"`
	Ulimits         map[string]config.UlimitConfig `json:"ulimits,omitempty"`
	ShmSize         string                         `json:"shmSize,omitempty"`
	SecretRefs      []string                       `json:"secretRefs,omitempty"`
	DependsOn       []string                       `json:"dependsOn,omitempty"`
	HealthCheck     config.HealthCheckConfig       `json:"healthCheck,omitempty"`
	DeployStrategy  string                         `json:"deployStrategy,omitempty"`
	RemovalPending  bool                           `json:"removalPending,omitempty"`
}

type Event

type Event struct {
	SchemaVersion int               `json:"schemaVersion"`
	Type          string            `json:"type"`
	Project       string            `json:"project"`
	Environment   string            `json:"environment"`
	RevisionID    string            `json:"revisionId,omitempty"`
	Service       string            `json:"service,omitempty"`
	Message       string            `json:"message,omitempty"`
	Details       map[string]string `json:"details,omitempty"`
	Time          time.Time         `json:"time"`
}

func NewEvent

func NewEvent(project string, environment string, eventType string, revisionID string, message string, details map[string]string) Event

type GitInfo

type GitInfo struct {
	Commit      string `json:"commit,omitempty"`
	CommitShort string `json:"commitShort,omitempty"`
	Branch      string `json:"branch,omitempty"`
	Message     string `json:"message,omitempty"`
	Author      string `json:"author,omitempty"`
}

type Manager

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

func NewManager

func NewManager(client any, cfg *config.Config, environment string) *Manager

func (*Manager) AppendEvent

func (m *Manager) AppendEvent(event Event) error

func (*Manager) DeleteNodeActual added in v0.4.8

func (m *Manager) DeleteNodeActual(node string) error

func (*Manager) ReadActual

func (m *Manager) ReadActual() (*ActualSnapshot, error)

func (*Manager) ReadDesired

func (m *Manager) ReadDesired() (*DesiredRevision, error)

func (*Manager) ReadNodeActual

func (m *Manager) ReadNodeActual(node string) (*ActualSnapshot, error)

func (*Manager) WithRequestTimeout added in v0.4.16

func (m *Manager) WithRequestTimeout(timeout time.Duration) *Manager

WithRequestTimeout returns a shallow copy that uses a custom takod request deadline. A non-positive timeout keeps the package default.

func (*Manager) WriteActual

func (m *Manager) WriteActual(snapshot *ActualSnapshot) error

func (*Manager) WriteDesired

func (m *Manager) WriteDesired(revision *DesiredRevision) error

func (*Manager) WriteNodeActual

func (m *Manager) WriteNodeActual(node string, snapshot *ActualSnapshot) error

Jump to

Keyboard shortcuts

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