rescue

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package rescue provides rescue mode for failed provisioning recovery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup added in v0.0.7

func Setup(ctx context.Context, cfg *Config) error

Setup prepares the rescue environment based on the config. It configures SSH access and password authentication when rescue mode is shell or wait.

Types

type Action

type Action struct {
	Type    Mode   `json:"type"`
	Message string `json:"message"`
}

Action represents a rescue action to take.

func Decide

func Decide(cfg *Config, state *RetryState) Action

Decide determines the rescue action based on config and state.

type Config

type Config struct {
	Mode           Mode          `json:"mode"`
	MaxRetries     int           `json:"maxRetries,omitempty"`
	RetryDelay     time.Duration `json:"retryDelay,omitempty"`
	ShellTimeout   time.Duration `json:"shellTimeout,omitempty"`
	SSHKeys        []string      `json:"sshKeys,omitempty"`
	PasswordHash   string        `json:"passwordHash,omitempty"`
	AutoMountDisks bool          `json:"autoMountDisks,omitempty"`
	NetworkConfig  bool          `json:"networkConfig,omitempty"`
}

Config holds rescue mode configuration.

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

ApplyDefaults sets default values for unset fields.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the rescue config.

type Mode

type Mode string

Mode determines what happens when provisioning fails.

const (
	// ModeReboot reboots the machine after failure.
	ModeReboot Mode = "reboot"
	// ModeShell drops to a debug shell.
	ModeShell Mode = "shell"
	// ModeRetry retries the provisioning.
	ModeRetry Mode = "retry"
	// ModeWait waits for manual intervention.
	ModeWait Mode = "wait"
)

func ParseMode

func ParseMode(s string) (Mode, error)

ParseMode parses a rescue mode string.

type RetryState

type RetryState struct {
	Attempts   int       `json:"attempts"`
	MaxRetries int       `json:"maxRetries"`
	LastError  string    `json:"lastError,omitempty"`
	LastRetry  time.Time `json:"lastRetry,omitempty"`
}

RetryState tracks retry attempts.

func (*RetryState) CanRetry

func (s *RetryState) CanRetry() bool

CanRetry returns whether another retry is allowed.

func (*RetryState) RecordAttempt

func (s *RetryState) RecordAttempt(err error)

RecordAttempt records a retry attempt.

func (*RetryState) Remaining

func (s *RetryState) Remaining() int

Remaining returns the number of retries remaining.

Jump to

Keyboard shortcuts

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