controllers

package
v0.0.0-...-a735c6b Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BackupScheduling defines the schedule associated with instance backups
	BackupScheduling string = "backup"
	// MaintenanceScheduling defines the schedule associated with maintenance except for backup
	MaintenanceScheduling string = "maintenance"
	// MaintenanceUnscheduling defines the schedule associated with maintenance removal
	MaintenanceUnscheduling string = "removal"
)

Variables

View Source
var (
	// ErrBackupFailed is reported the backup has failed
	ErrBackupFailed = errors.New("BackupFailed")

	// ErrBackupRunning is reported the backup is always running
	ErrBackupRunning = errors.New("BackupRunning")
)
View Source
var (
	// ErrChannelNotFound is reported when the channel does not exist
	ErrChannelNotFound = errors.New("ChannelNotFound")

	// ErrChatConnectionFailed is reported when the connection failed
	ErrChatConnectionFailed = errors.New("ConnectionFailed")
)
View Source
var (
	// ErrNotImplemented is reported when a feature is not implemented
	ErrNotImplemented = errors.New("NotImplemented")

	// ErrUserDatabaseMismatch is reported when the user and database do not match for a Grant
	ErrUserDatabaseMismatch = errors.New("UserDatabaseMismatch")

	// ErrStoreNotFound is reported when a store is not found
	ErrStoreNotFound = errors.New("StoreNotFound")

	// ErrStoreNotReady is reported when a store is not ready
	ErrStoreNotReady = errors.New("StoreNotReady")

	// ErrDatabaseNotFound is reported when a database is not found
	ErrDatabaseNotFound = errors.New("DatabaseNotFound")

	// ErrDatabaseNotReady is reported when a database is not ready
	ErrDatabaseNotReady = errors.New("DatabaseNotReady")

	// ErrUserNotFound is reported when a user is not found
	ErrUserNotFound = errors.New("UserNotFound")

	// ErrUserNotReady is reported when a user is not ready
	ErrUserNotReady = errors.New("UserNotReady")

	// ErrInstanceNotFound is reported when an instance is not found
	ErrInstanceNotFound = errors.New("InstanceNotFound")

	// ErrInstanceNotReady is reported when an instance is not ready
	ErrInstanceNotReady = errors.New("InstanceNotReady")

	// ErrPodNotFound is reported when a pod is not found
	ErrPodNotFound = errors.New("PodNotFound")

	// ErrAgentAccessFailed is reported when the agent could not be accessed
	ErrAgentAccessFailed = errors.New("AgentAccessFailed")

	// ErrAgentRequestFailed is reported when the agent request fails
	ErrAgentRequestFailed = errors.New("AgentRequestFailed")
)
View Source
var (
	// ErrMissingPassword is reported when a password is missing for a user
	ErrMissingPassword = errors.New("MissingPassword")

	// ErrKeyNotFound is reported when a key is not found in configMap or secret
	ErrKeyNotFound = errors.New("KeyNotFound")

	// ErrConfigMapNotFound is reported when a configMap is not found
	ErrConfigMapNotFound = errors.New("ConfigMapNotFound")

	// ErrSecretNotFound is reported when a secret is not found
	ErrSecretNotFound = errors.New("SecretNotFound")
)
View Source
var (
	// ErrMissingVariable shows when a variable is missing from the store
	ErrMissingVariable = errors.New("MissingVariable")
)

Functions

This section is empty.

Types

type APIReconciler

type APIReconciler struct {
	client.Client
	Log logr.Logger
}

APIReconciler reconciles an object

func (*APIReconciler) GetAPI

func (a *APIReconciler) GetAPI(ctx context.Context, instanceName types.NamespacedName) (*agent.APIClient, error)

GetAPI is the script that gets the API from an instance name and namespace

func (*APIReconciler) GetDatabase

func (a *APIReconciler) GetDatabase(ctx context.Context, databaseName types.NamespacedName) (*mysqlv1alpha1.Database, error)

GetDatabase gets a database from the name and namespace

func (*APIReconciler) GetStore

func (a *APIReconciler) GetStore(ctx context.Context, storeName types.NamespacedName) (*mysqlv1alpha1.Store, error)

GetStore gets a store from the name and namespace

func (*APIReconciler) GetUser

func (a *APIReconciler) GetUser(ctx context.Context, userName types.NamespacedName) (*mysqlv1alpha1.User, error)

GetUser gets a user from the name and namespace

type BackupJob

type BackupJob struct {
	client.Client
	Instance types.NamespacedName
	Log      logr.Logger
	Scheme   *runtime.Scheme
}

BackupJob is a struct that manages Jobs for backups

func NewBackupJob

func NewBackupJob(client client.Client, instance types.NamespacedName, log logr.Logger, scheme *runtime.Scheme) *BackupJob

NewBackupJob creates a BackupJob to schedule it

func (*BackupJob) Run

func (b *BackupJob) Run()

Run implement the Job interface to use with Cron AddFunc()

type BackupManager

type BackupManager struct {
	Context     context.Context
	Reconciler  *BackupReconciler
	TimeManager *TimeManager
}

BackupManager provides methods to manage the backup subcomponents

func (*BackupManager) CreateBackup

func (bm *BackupManager) CreateBackup(backup *mysqlv1alpha1.Backup) (*mysqlv1alpha1.BackupDetails, error)

CreateBackup is the script that creates a user

func (*BackupManager) GetEnvVars

func (bm *BackupManager) GetEnvVars(store mysqlv1alpha1.Store) (map[string]string, error)

GetEnvVars returns the environment variables for the store

func (*BackupManager) MonitorBackup

func (bm *BackupManager) MonitorBackup(backup *mysqlv1alpha1.Backup) (*mysqlv1alpha1.BackupDetails, error)

MonitorBackup watch backup progress and update results

type BackupReconciler

type BackupReconciler struct {
	client.Client
	Log        logr.Logger
	Scheme     *runtime.Scheme
	Properties StatefulSetProperties
}

BackupReconciler reconciles a Backup object

func (*BackupReconciler) Reconcile

func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile implement the reconciliation loop for backups

func (*BackupReconciler) SetupWithManager

func (r *BackupReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager configure type of events the manager should watch

type ChatManager

type ChatManager struct {
	Context     context.Context
	Reconciler  *ChatReconciler
	TimeManager *TimeManager
}

ChatManager provides methods to manage chat subcomponents

type ChatReconciler

type ChatReconciler struct {
	client.Client
	Log       logr.Logger
	Scheme    *runtime.Scheme
	Connector SlackConnector
	Chats     map[string]*slack.Client
}

ChatReconciler reconciles a Chat object

func (*ChatReconciler) Reconcile

func (r *ChatReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile implement the reconciliation loop for chats

func (*ChatReconciler) SetupWithManager

func (r *ChatReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type Crontab

type Crontab interface {
	// contains filtered or unexported methods
}

Crontab interface is provided to allow unit tests

func NewDefaultCrontab

func NewDefaultCrontab() Crontab

NewDefaultCrontab provides contrab abilities to the operator

func NewMockCrontabCrontab

func NewMockCrontabCrontab() Crontab

NewMockCrontabCrontab initialize a predictable incarnation to ease tests

type DatabaseManager

type DatabaseManager struct {
	Context     context.Context
	Reconciler  *DatabaseReconciler
	TimeManager *TimeManager
}

DatabaseManager provides methods to manage database subcomponents

func (*DatabaseManager) CreateDatabase

func (dm *DatabaseManager) CreateDatabase(database *mysqlv1alpha1.Database) error

CreateDatabase is the script that creates a database

type DatabaseReconciler

type DatabaseReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

DatabaseReconciler reconciles a Database object

func (*DatabaseReconciler) Reconcile

func (r *DatabaseReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile implement the reconciliation loop for databases

func (*DatabaseReconciler) SetupWithManager

func (r *DatabaseReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager configure type of events the manager should watch

type DefaultCrontab

type DefaultCrontab struct {
	Cron        *cron.Cron
	Incarnation string
}

DefaultCrontab provides a simple struct to manage cron EntryID for instances

type DefaultSlackConnector

type DefaultSlackConnector struct {
}

DefaultSlackConnector an implementation of the SlackConnector

func (*DefaultSlackConnector) GetAPIwithChannel

func (cc *DefaultSlackConnector) GetAPIwithChannel(cm *ChatManager, chat *mysqlv1alpha1.Chat) (*slack.Client, string, error)

GetAPIwithChannel returns the API with the Channel ID for a named group or channel

func (*DefaultSlackConnector) PostMessage

func (cc *DefaultSlackConnector) PostMessage(api *slack.Client, channel string, message string) error

PostMessage Post a message on the API

type EnvManager

type EnvManager struct {
	client.Client
	Log logr.Logger
}

EnvManager reconciles an Environment object

func (*EnvManager) GetEnvVars

func (em *EnvManager) GetEnvVars(ctx context.Context, store mysqlv1alpha1.Store) (map[string]string, error)

GetEnvVars returns the environment variables for the store

type GrantManager

type GrantManager struct {
	Context     context.Context
	Reconciler  *GrantReconciler
	TimeManager *TimeManager
}

GrantManager provides methods to manage grant subcomponents

func (*GrantManager) CreateGrant

func (gm *GrantManager) CreateGrant(grant *mysqlv1alpha1.Grant) error

CreateGrant is the script that creates a grant

type GrantReconciler

type GrantReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

GrantReconciler reconciles a Grant object

func (*GrantReconciler) Reconcile

func (r *GrantReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile implement the reconciliation loop for users

func (*GrantReconciler) SetupWithManager

func (r *GrantReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type InstanceManager

type InstanceManager struct {
	Context     context.Context
	Reconciler  *InstanceReconciler
	Properties  *StatefulSetProperties
	TimeManager *TimeManager
}

InstanceManager provides methods to manage the instance subcomponents

type InstanceReconciler

type InstanceReconciler struct {
	client.Client
	Log        logr.Logger
	Scheme     *runtime.Scheme
	Properties *StatefulSetProperties
	Crontab    Crontab
}

InstanceReconciler reconciles a Instance object

func (*InstanceReconciler) Reconcile

func (r *InstanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile implement the reconciliation loop for instances

func (*InstanceReconciler) SetupWithManager

func (r *InstanceReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager configure type of events the manager should watch

type MaintenanceJob

type MaintenanceJob struct {
	client.Client
	Instance types.NamespacedName
	Log      logr.Logger
	Scheme   *runtime.Scheme
	Crontab  Crontab
}

MaintenanceJob is a struct that manages Jobs for maintenance

func NewMaintenanceJob

func NewMaintenanceJob(client client.Client, instance types.NamespacedName, log logr.Logger, scheme *runtime.Scheme, crontab Crontab) *MaintenanceJob

NewMaintenanceJob creates a MaintenanceJob to schedule it

func (*MaintenanceJob) Run

func (b *MaintenanceJob) Run()

Run implement the Job interface to use with Cron AddFunc()

type MockCrontab

type MockCrontab struct {
	Incarnation string
}

MockCrontab provides a simple struct to mock cron EntryID

type OperationManager

type OperationManager struct {
	Context     context.Context
	Reconciler  *OperationReconciler
	TimeManager *TimeManager
}

OperationManager provides methods to manage operations

func (*OperationManager) NoOp

func (om *OperationManager) NoOp() error

NoOp is a No Operation function

type OperationReconciler

type OperationReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

OperationReconciler reconciles a Operation object

func (*OperationReconciler) Reconcile

func (r *OperationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.

func (*OperationReconciler) SetupWithManager

func (r *OperationReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type SlackConnector

type SlackConnector interface {
	GetAPIwithChannel(cm *ChatManager, chat *mysqlv1alpha1.Chat) (*slack.Client, string, error)
	PostMessage(api *slack.Client, channel string, message string) error
}

SlackConnector is an interface to the SlackConnector and is used to perform tests

func NewDefaultSlackConnector

func NewDefaultSlackConnector() SlackConnector

NewDefaultSlackConnector generates a Slack connector based on slack-go

type StatefulSetProperties

type StatefulSetProperties struct {
	AgentVersion string
	MySQLVersion string
}

StatefulSetProperties defines the default agent and mysql versions

func (*StatefulSetProperties) NewStatefulSetForInstance

func (s *StatefulSetProperties) NewStatefulSetForInstance(instance *mysqlv1alpha1.Instance, store *mysqlv1alpha1.Store, location string) *appsv1.StatefulSet

NewStatefulSetForInstance returns a MySQL StatefulSet with the instance name/namespace

type StoreManager

type StoreManager struct {
	Context     context.Context
	Reconciler  *StoreReconciler
	TimeManager *TimeManager
}

StoreManager provides methods to manage the store subcomponents

func (*StoreManager) GetEnvVars

func (sm *StoreManager) GetEnvVars(store mysqlv1alpha1.Store) (map[string]string, error)

GetEnvVars returns the environment variables for the store

type StoreReconciler

type StoreReconciler struct {
	client.Client
	Log      logr.Logger
	Scheme   *runtime.Scheme
	Storages map[string]backend.Storage
}

StoreReconciler reconciles a Store object

func (*StoreReconciler) Reconcile

func (r *StoreReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile implement the reconciliation loop for stores

func (*StoreReconciler) SetupWithManager

func (r *StoreReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager configure type of events the manager should watch

type TimeManager

type TimeManager []time.Duration

TimeManager manages a set of time durations

func NewTimeManager

func NewTimeManager() *TimeManager

NewTimeManager creates a set of time durations

func (*TimeManager) Next

func (t *TimeManager) Next(c time.Time) time.Duration

Next returns the next duration based on the first time

type UnMaintenanceJob

type UnMaintenanceJob struct {
	client.Client
	Instance types.NamespacedName
	Log      logr.Logger
	Scheme   *runtime.Scheme
	Crontab  Crontab
}

UnMaintenanceJob is a struct that manages Jobs to stop maintenance

func NewUnMaintenanceJob

func NewUnMaintenanceJob(client client.Client, instance types.NamespacedName, log logr.Logger, scheme *runtime.Scheme, crontab Crontab) *UnMaintenanceJob

NewUnMaintenanceJob creates a MaintenanceJob to schedule it

func (*UnMaintenanceJob) Run

func (b *UnMaintenanceJob) Run()

Run implement the Job interface to use with Cron AddFunc()

type UserManager

type UserManager struct {
	Context     context.Context
	Reconciler  *UserReconciler
	TimeManager *TimeManager
}

UserManager provides methods to manage user subcomponents

func (*UserManager) CreateUser

func (um *UserManager) CreateUser(user *mysqlv1alpha1.User) error

CreateUser is the script that creates a user

func (*UserManager) GetPassword

func (um *UserManager) GetPassword(user *mysqlv1alpha1.User) (string, error)

GetPassword returns the password for the user

type UserReconciler

type UserReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

UserReconciler reconciles a User object

func (*UserReconciler) Reconcile

func (r *UserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile implement the reconciliation loop for users

func (*UserReconciler) SetupWithManager

func (r *UserReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager configure type of events the manager should watch

Jump to

Keyboard shortcuts

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