migration

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package migration provides functionality for data migration operations in Kubernetes. This package includes components for creating, running, and monitoring Kubernetes jobs that perform data import and migration tasks.

Index

Constants

This section is empty.

Variables

View Source
var ErrExpiredTimestamp = errors.New("final migration timestamp is in the past")

Functions

func IsFinalMigration

func IsFinalMigration(ctx context.Context) bool

func Run added in v0.0.3

func Run(ctx context.Context, finalTimestampStr, regularCron string, changeFQDN bool, runner migrationRunner) error

Run is the main function to run the migration initiating the delta and final migration

func SetFinalMigration

func SetFinalMigration(ctx context.Context) context.Context

func SetTriggerFQDNChange

func SetTriggerFQDNChange(ctx context.Context) context.Context

func SetTriggerFQDNChangeFromEnv

func SetTriggerFQDNChangeFromEnv(ctx context.Context) context.Context

func TriggerFQDNChange

func TriggerFQDNChange(ctx context.Context) bool

Types

type BackupSchedule added in v0.0.3

type BackupSchedule struct {
	// Name of the backup schedule.
	Name string
	// Schedule is defined as a cron expression.
	Schedule string
}

BackupSchedule contains the configuration of a single backup schedule.

type Component added in v0.0.3

type Component struct {
	// Name holds the component name.
	Name string
	// Version holds the component version.
	Version string
}

type Configuration added in v0.0.3

type Configuration struct {
	// GlobalConfig is the global configuration of the exporter system.
	GlobalConfig GlobalConfig
	// DoguConfigs is the configuration of all installed dogus in the exporter system.
	DoguConfigs []DoguConfig
	// BackupSchedules is the configuration of all backup schedules in the exporter system.
	BackupSchedules []BackupSchedule
}

Configuration contains the configuration of the exporter system.

type Dogu added in v0.0.3

type Dogu struct {
	// Name holds the dogu name including the namespace delimited by a slash ("/").
	Name string
	// Version holds the dogu version.
	Version string
	// Volume contains data on the dogu's persistent storage.
	Volume DoguVolume
}

Dogu contains data on a single installed dogu on the exporter side.

type DoguConfig added in v0.0.3

type DoguConfig struct {
	// Name of the dogu.
	Name string
	// NormalConfig normal dogu configuration as KeyValue pairs
	NormalConfig []KeyValue
	// LocalConfig local dogu configuration as KeyValue pairs
	LocalConfig []KeyValue
	// SensitiveConfig sensitive dogu configuration as KeyValue pairs
	SensitiveConfig []KeyValue
}

DoguConfig contains the configuration of a single dogu.

type DoguExport added in v0.0.3

type DoguExport struct {
	// Dogu specifies the name of the Dogu to be exported.
	Dogu string
	// VolumePath specifies the file system path to the volume associated with the Dogu being exported.
	VolumePath string
	// ExporterPort defines the network port used by the exporter process for transferring data.
	ExporterPort int
}

DoguExport contains data for exporting a Dogu, including its name, volume path, and exporter port configuration.

type DoguStarter

type DoguStarter interface {
	StartAll(ctx context.Context) error
}

type DoguStopper

type DoguStopper interface {
	StopAll(ctx context.Context) error
}

type DoguVolume added in v0.0.3

type DoguVolume struct {
	// SizeInBytes contains the expected dogu volume size.
	//
	// While int32 (~2 Gibi bytes) is too small for comfort, int64 (~9 Exbi bytes) should suffice to accommodate the
	// size of even the largest dogu volume.
	SizeInBytes int64
}

DoguVolume contains data on the dogu's persistent storage.

type DoguVolumeResizer added in v0.0.2

type DoguVolumeResizer interface {
	ResizeDogusIfNeeded(ctx context.Context, exporterDogus []Dogu, importerDogus []Dogu) error
}

type ExportModeValidator

type ExportModeValidator interface {
	Validate(ctx context.Context) error
}

type ExportModeValidatorApiClient

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

func NewExportModeValidatorApiClient

func NewExportModeValidatorApiClient(apiClient exportModeClient) *ExportModeValidatorApiClient

func (*ExportModeValidatorApiClient) Validate

type FinalTimestamp added in v0.0.2

type FinalTimestamp time.Time

FinalTimestamp is the timestamp of the final migration.

func Now added in v0.0.2

func Now() FinalTimestamp

Now return a FinalTimestamp with the current time.

func ParseFinalTimestamp added in v0.0.2

func ParseFinalTimestamp(timestamp string) (FinalTimestamp, error)

ParseFinalTimestamp parses the provided string into a FinalTimestamp. The function expects a string in the RFC3339 format. An error is returned when parsing fails or the timestamp lies in the past. An empty string results in a FinalTimestamp with a zero value.

func (FinalTimestamp) Expired added in v0.0.2

func (ft FinalTimestamp) Expired() bool

Expired return the status whether the final timestamp is expired meaning the time now is bigger than the time of the final timestamp. When FinalTimeStamp is the zero value the timestamp expires immediately.

func (FinalTimestamp) IsZero added in v0.0.2

func (ft FinalTimestamp) IsZero() bool

IsZero reports whether the final timestamp is the zero value.

func (FinalTimestamp) String added in v0.0.2

func (ft FinalTimestamp) String() string

String converts FinalTimestamp into a string in RFC3339 format.

func (FinalTimestamp) WaitUntil added in v0.0.2

func (ft FinalTimestamp) WaitUntil(ctx context.Context)

WaitUntil waits until the final timestamp is reached. This method blocks until the timestamp is reached or the provided context is done.

func (FinalTimestamp) WaitUntilReady added in v0.0.2

func (ft FinalTimestamp) WaitUntilReady(ctx context.Context, ready func() bool)

WaitUntilReady waits until the final timestamp is reached and the provided ready function returns true. This method blocks until the timestamp is reached and ready or the provided context is done.

type GetLogWriterFunc added in v0.0.6

type GetLogWriterFunc func() io.Writer

GetLogWriterFunc is a function type to receive to current io.Writer to write the logs to.

type GlobalConfig added in v0.0.3

type GlobalConfig []KeyValue

GlobalConfig contains the global configuration of the exporter system.

type JobProviderDependencies

type JobProviderDependencies struct {
	JobContainerConfig configuration.JobContainer
	SSHConfig          configuration.SSH
	APIKey             string
	DoguVolumeBasePath string
	PVCClient          pvcClient
}

type JobRunner

type JobRunner interface {
	Run(ctx context.Context) error
}

type JobService

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

JobService orchestrates the creation, execution, and monitoring of Kubernetes jobs It provides functionality to run jobs, watch their status, and retrieve their logs

func NewJobService

func NewJobService(deps JobServiceDependencies) (*JobService, error)

NewJobService creates a new JobService with the provided dependencies It initializes the job provider and sets up the necessary functions for watching jobs and streaming logs Returns an error if the job provider cannot be created

func (JobService) Run

func (j JobService) Run(ctx context.Context) (err error)

Run creates and executes a Kubernetes job, watches for its completion, and returns its logs It performs the following steps: 1. Creates a job specification using the job creator 2. Submits the job to the Kubernetes API 3. Sets up a watcher to monitor the job's status 4. Waits for the job to complete or fail 5. Retrieves and returns the job's logs

The method returns an io.ReadCloser containing the job logs if successful, or an error if any step in the process fails

type JobServiceDependencies

type JobServiceDependencies struct {
	JobProviderDependencies
	JobClient    jobClient
	PodClient    podClient
	GetLogWriter GetLogWriterFunc
}

JobServiceDependencies contains all the dependencies required to create a JobService It includes dependencies for job creation, job client for interacting with Kubernetes jobs, and pod client for accessing pod information and logs

type KeyValue added in v0.0.3

type KeyValue struct {
	// Key is the name of the configuration value.
	Key string
	// Value is the value of the configuration value.
	Value string
}

KeyValue contains a key-value pair. This is used to represent configuration values.

type LogInitializerFunc added in v0.0.6

type LogInitializerFunc func() error

type MailSender

type MailSender interface {
	Send(ctx context.Context, isFinal bool, migrationResult error, startTime time.Time, endTime time.Time) error
}

type MaintenanceModeHandler

type MaintenanceModeHandler interface {
	Enable(ctx context.Context) error
	Disable(ctx context.Context) error
}

type Migrator

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

func NewMigrator

func NewMigrator(dependencies MigratorDependencies) *Migrator

func (Migrator) RunMigration

func (m Migrator) RunMigration(ctx context.Context) (err error)

type PVCGetter

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

func NewPVCGetter

func NewPVCGetter(client v1.PersistentVolumeClaimInterface) *PVCGetter

func (PVCGetter) GetDoguVolumes

func (p PVCGetter) GetDoguVolumes(ctx context.Context) ([]doguPVC, error)

type SystemInfo added in v0.0.3

type SystemInfo struct {
	// FQDN contains the DNS name of the exporter systeḿ.
	FQDN string
	// IsMultinode indicates whether the exporter system is a classic CES or a multinode CES instance.
	IsMultinode bool
	// Dogus contains data on all installed dogus on the exporter side.
	Dogus []Dogu
	// Components contain data on all installed components on the exporter side.
	Components []Component
}

SystemInfo contains data on vital data on the exporter side.

type SystemInfoProvider added in v0.0.2

type SystemInfoProvider interface {
	GetExporterSystemInfo(ctx context.Context) (*SystemInfo, error)
	GetImporterSystemInfo(ctx context.Context) (*SystemInfo, error)
}

type SystemInfoValidator

type SystemInfoValidator interface {
	Validate(ctx context.Context, exporterInfo *SystemInfo, importerInfo *SystemInfo) error
}

Directories

Path Synopsis
Package sync provides functions to copy data from the exporter system to the importer system (where this application is running).
Package sync provides functions to copy data from the exporter system to the importer system (where this application is running).

Jump to

Keyboard shortcuts

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