state

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checkpoint

type Checkpoint struct {
	Phase        Phase            `json:"phase"`                   // k3s|calico|liqo|peering|offloading
	Timestamp    time.Time        `json:"timestamp"`               // Checkpoint creation time
	Status       CheckpointStatus `json:"status"`                  // success|failed
	SnapshotPath string           `json:"snapshot_path,omitempty"` // Optional snapshot path
}

Checkpoint represents an installation checkpoint

type CheckpointStatus

type CheckpointStatus string

CheckpointStatus is the status of an installation checkpoint.

const (
	CheckpointStatusSuccess CheckpointStatus = "success"
	CheckpointStatusFailed  CheckpointStatus = "failed"
)

type ErrorInfo

type ErrorInfo struct {
	Phase       Phase     `json:"phase"`
	Timestamp   time.Time `json:"timestamp"`
	Error       string    `json:"error"`
	Recoverable bool      `json:"recoverable"`
}

ErrorInfo represents error information

type Manager

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

Manager manages installation state

func NewManager

func NewManager(configDir, agentID string) *Manager

NewManager creates a new state manager agentID can be either the agent ID (UUID) or agent name

func (*Manager) AddCheckpoint

func (m *Manager) AddCheckpoint(phase Phase, status CheckpointStatus, snapshotPath string)

AddCheckpoint adds a new checkpoint

func (*Manager) Backup

func (m *Manager) Backup() (string, error)

Backup copies state.json to a timestamped backup beside it.

func (*Manager) CanResume

func (m *Manager) CanResume() bool

CanResume checks if installation can be resumed

func (*Manager) ClearCheckpoints

func (m *Manager) ClearCheckpoints(phase Phase)

ClearCheckpoints removes all checkpoints for the given phase.

func (*Manager) ClearError

func (m *Manager) ClearError()

ClearError clears the last error

func (*Manager) ClearLocalState

func (m *Manager) ClearLocalState() error

ClearLocalState removes the cluster state directory.

func (*Manager) GetAgentID

func (m *Manager) GetAgentID() string

GetAgentID returns the agent ID

func (*Manager) GetAgentName

func (m *Manager) GetAgentName() string

GetAgentName returns the agent name

func (*Manager) GetLastCheckpoint

func (m *Manager) GetLastCheckpoint() *Checkpoint

GetLastCheckpoint returns the last successful checkpoint

func (*Manager) GetRegisterScope

func (m *Manager) GetRegisterScope() *RegisterScope

GetRegisterScope returns persisted register flags, if any.

func (*Manager) GetState

func (m *Manager) GetState() *State

GetState returns the current state

func (*Manager) HasSuccessfulCheckpoint

func (m *Manager) HasSuccessfulCheckpoint(phase Phase) bool

HasSuccessfulCheckpoint reports whether a phase completed successfully.

func (*Manager) Load

func (m *Manager) Load() error

Load loads state from file

func (*Manager) ResetCheckpoints

func (m *Manager) ResetCheckpoints()

ResetCheckpoints clears checkpoints and error while preserving agent identity.

func (*Manager) RollbackToLastCheckpoint

func (m *Manager) RollbackToLastCheckpoint() (*Checkpoint, error)

RollbackToLastCheckpoint truncates checkpoints after the last success and sets phase to it.

func (*Manager) Save

func (m *Manager) Save() error

Save saves state to file

func (*Manager) SetAgentInfo

func (m *Manager) SetAgentInfo(agentID, agentName string)

SetAgentInfo sets agent ID and name

func (*Manager) SetError

func (m *Manager) SetError(phase Phase, errorMsg string, recoverable bool)

SetError sets the last error information

func (*Manager) SetPhase

func (m *Manager) SetPhase(phase Phase)

SetPhase sets the current installation phase

func (*Manager) SetRegisterScope

func (m *Manager) SetRegisterScope(scope RegisterScope)

SetRegisterScope persists register flags for standalone verify.

func (*Manager) SetVersions

func (m *Manager) SetVersions(versions map[string]string)

SetVersions stores component versions used during registration.

func (*Manager) StateDir

func (m *Manager) StateDir() string

StateDir returns the cluster state directory.

func (*Manager) StatePath

func (m *Manager) StatePath() string

StatePath returns the path to state.json.

type Phase

type Phase string

Phase is an installation phase persisted in state.json.

const (
	PhaseCurrent         Phase = "current"
	PhaseK3s             Phase = "k3s"
	PhaseCalico          Phase = "calico"
	PhaseLiqo            Phase = "liqo"
	PhasePeering         Phase = "peering"
	PhaseOffloading      Phase = "offloading"
	PhaseInboundPeering  Phase = "inbound_peering"
	PhaseOperatorInstall Phase = "operator_install"
	PhaseComplete        Phase = "complete"
	PhaseFailed          Phase = "failed"
)

func ReconcilePhase

func ReconcilePhase(k3sOK, calicoOK, liqoOK, peeringOK, complete bool) Phase

ReconcilePhase updates phase based on detected installed components.

type RegisterScope

type RegisterScope struct {
	DisableOffloading   bool     `json:"disable_offloading,omitempty"`
	SkipOperatorInstall bool     `json:"skip_operator_install,omitempty"`
	HypervisorDriver    string   `json:"hypervisor_driver,omitempty"`
	OperatorNamespace   string   `json:"operator_namespace,omitempty"` // optional offload ns
	VNCGatewayNamespace string   `json:"vnc_gateway_namespace,omitempty"`
	OffloadNamespaces   []string `json:"offload_namespaces,omitempty"`
}

RegisterScope is the subset of register flags that affect post-install verify.

type State

type State struct {
	AgentID           string            `json:"agent_id,omitempty"`          // Agent ID (UUID) generated by backend
	AgentName         string            `json:"agent_name,omitempty"`        // Agent name (user-provided)
	RegistrationTime  time.Time         `json:"registration_time,omitempty"` // When agent was registered
	Phase             Phase             `json:"phase"`                       // current|k3s|calico|liqo|peering|offloading|complete|failed
	LastUpdated       time.Time         `json:"last_updated"`                // Last state update timestamp
	RollbackAvailable bool              `json:"rollback_available"`          // Whether rollback is available
	Checkpoints       []Checkpoint      `json:"checkpoints"`                 // Installation checkpoints
	LastError         *ErrorInfo        `json:"last_error,omitempty"`        // Last error information
	Versions          map[string]string `json:"versions,omitempty"`          // Component versions used at register
	// RegisterScope stores register flags needed by standalone cluster verify.
	RegisterScope *RegisterScope `json:"register_scope,omitempty"`
}

State represents the installation state

Jump to

Keyboard shortcuts

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