Documentation
¶
Overview ¶
Package mirror implements the reloader manager for mirror reloaders.
Index ¶
- Constants
- Variables
- type CopyInfo
- type Manager
- func (m *Manager) CleanupCopy(ctx context.Context, deployment CopyInfo) error
- func (m *Manager) PrepareCopies(ctx context.Context, targets []Target, copyImage string) ([]CopyInfo, error)
- func (m *Manager) Run(ctx context.Context, reloaderConfig *v2.ReloaderConfig, ...) error
- func (m *Manager) Status(ctx context.Context, reloaderConfig *v2.ReloaderConfig, ...) (*reloader.Status, error)
- func (m *Manager) Type() string
- func (m *Manager) Validate(reloaderConfig *v2.ReloaderConfig, caproniConfig *v2.CaproniConfig) error
- type Target
Constants ¶
const ( // ScaleUpReplicaCount is the number of replicas the original deployment // will be scaled up to. This is intentionally hard-coded to avoid // storing state in the old deployments or within Caproni. // // See https://gitlab.com/gitlab-org/gitlab/-/issues/590495#note_3118758329 ScaleUpReplicaCount = 1 )
Variables ¶
var ( // ErrInvalidResourceType is returned when a resource type is not "deployment" or "statefulset". ErrInvalidResourceType = errors.New("resource type must be 'deployment' or 'statefulset'") // ErrInvalidDeploymentStructure is returned when deployment JSON structure is invalid. ErrInvalidDeploymentStructure = errors.New("invalid deployment structure") // ErrContainerNotFound is returned when the specified container is not found in the deployment. ErrContainerNotFound = errors.New("container not found in deployment") )
var ( // ErrInvalidReloaderType is returned when the reloader type is not 'mirror'. ErrInvalidReloaderType = errors.New("reloader type is not 'mirror'") // ErrMirrorConfigMissing is returned when the mirror configuration is missing. ErrMirrorConfigMissing = errors.New("mirror configuration is missing") // ErrTargetConfigMissing is returned when the target configuration is missing. ErrTargetConfigMissing = errors.New("target configuration is missing") // ErrEmptyCommand is returned when a process has an empty command. ErrEmptyCommand = errors.New("empty command for process") // ErrRepositoryNotFound is returned when the referenced repository doesn't exist. ErrRepositoryNotFound = errors.New("repository not found") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager implements reloader.Manager for mirror reloaders.
func NewManager ¶
func NewManager(kubectlBackend kubectl.Backend, executor executor.CommandRunner) *Manager
NewManager creates a new mirror reloader manager.
func (*Manager) CleanupCopy ¶
CleanupCopy deletes a -caproni deployment copy and scales the original back up.
func (*Manager) PrepareCopies ¶
func (m *Manager) PrepareCopies(ctx context.Context, targets []Target, copyImage string) ([]CopyInfo, error)
PrepareCopies scales down original deployments and creates -caproni copies for the given targets. It deduplicates targets and skips unsupported resource types. Returns a slice of CopyInfo for cleanup operations.
func (*Manager) Run ¶
func (m *Manager) Run(ctx context.Context, reloaderConfig *v2.ReloaderConfig, caproniConfig *v2.CaproniConfig) error
Run starts the mirror reloader, blocking until the context is cancelled. This method:
- Generates a mirrord configuration file
- Starts caproni edit-mode-process-supervisor wrapped in mirrord
- Auto-restarts processes that exit unexpectedly
- Cleans up on shutdown
func (*Manager) Status ¶
func (m *Manager) Status(ctx context.Context, reloaderConfig *v2.ReloaderConfig, caproniConfig *v2.CaproniConfig) (*reloader.Status, error)
Status returns the current status of the reloader.
func (*Manager) Validate ¶
func (m *Manager) Validate(reloaderConfig *v2.ReloaderConfig, caproniConfig *v2.CaproniConfig) error
Validate validates the mirror reloader configuration. Mirror reloaders don't have file path dependencies, so this primarily validates the configuration structure.