foundationdbcluster

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2020 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const LastPodHashKey = "org.foundationdb/last-applied-pod-spec-hash"

Variables

This section is empty.

Functions

func Add

func Add(mgr manager.Manager) error

Add creates a new FoundationDBCluster Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller and Start it when the Manager is Started.

func AddReconciler

func AddReconciler(mgr manager.Manager, r reconcile.Reconciler) error

add adds a new Controller to mgr with r as the reconcile.Reconciler

func CheckDynamicFilePresent

func CheckDynamicFilePresent(client FdbPodClient, filename string) (bool, error)

CheckDynamicFilePresent waits for a file to be present in the dynamic conf

func ClearMockAdminClients

func ClearMockAdminClients()

ClearMockAdminClients clears the cache of mock Admin clients

func GetConfigMap

func GetConfigMap(context ctx.Context, cluster *fdbtypes.FoundationDBCluster, kubeClient client.Client) (*corev1.ConfigMap, error)

GetConfigMap builds a config map for a cluster's dynamic config

func GetMonitorConf

func GetMonitorConf(cluster *fdbtypes.FoundationDBCluster, processClass string, pod *corev1.Pod, podClient FdbPodClient) (string, error)

GetMonitorConf builds the monitor conf template

func GetPod

func GetPod(context ctx.Context, cluster *fdbtypes.FoundationDBCluster, processClass string, idNum int, kubeClient client.Client) (*corev1.Pod, error)

GetPod builds a pod for a new instance

func GetPodSpec

func GetPodSpec(cluster *fdbtypes.FoundationDBCluster, processClass string, idNum int) (*corev1.PodSpec, error)

GetPodSpec builds a pod spec for a FoundationDB pod

func GetPodSpecHash added in v0.3.0

func GetPodSpecHash(cluster *fdbtypes.FoundationDBCluster, processClass string, id int, spec *corev1.PodSpec) (string, error)

func GetPvc

func GetPvc(cluster *fdbtypes.FoundationDBCluster, processClass string, idNum int) (*corev1.PersistentVolumeClaim, error)

GetPvc builds a persistent volume claim for a FoundationDB instance.

func GetStartCommand

func GetStartCommand(cluster *fdbtypes.FoundationDBCluster, instance FdbInstance, podClient FdbPodClient) (string, error)

func MissingPodError

func MissingPodError(instance FdbInstance, cluster *fdbtypes.FoundationDBCluster) error

MissingPodError creates an error that can be thrown when an instance does not have an associated pod.

func MissingPodErrorByName

func MissingPodErrorByName(instanceName string, cluster *fdbtypes.FoundationDBCluster) error

MissingPodErrorByName creates an error that can be thrown when an instance does not have an associated pod.

func ParseInstanceID added in v0.3.0

func ParseInstanceID(id string) (string, int, error)

ParseInstanceID extracts the components of an instance ID.

func UpdateDynamicFiles

func UpdateDynamicFiles(client FdbPodClient, filename string, contents string, updateFunc func(client FdbPodClient) error) (bool, error)

UpdateDynamicFiles checks if the files in the dynamic conf volume match the expected contents, and tries to copy the latest files from the input volume if they do not.

Types

type AddPods

type AddPods struct{}

AddPods provides a reconciliation step for adding new pods to a cluster.

func (AddPods) Reconcile

func (a AddPods) Reconcile(r *ReconcileFoundationDBCluster, context ctx.Context, cluster *fdbtypes.FoundationDBCluster) (bool, error)

func (AddPods) RequeueAfter

func (a AddPods) RequeueAfter() time.Duration

type AdminClient

type AdminClient interface {
	// GetStatus gets the database's status
	GetStatus() (*fdbtypes.FoundationDBStatus, error)

	// ConfigureDatabase sets the database configuration
	ConfigureDatabase(configuration fdbtypes.DatabaseConfiguration, newDatabase bool) error

	// ExcludeInstances starts evacuating processes so that they can be removed
	// from the database.
	ExcludeInstances(addresses []string) error

	// IncludeInstances removes processes from the exclusion list and allows
	// them to take on roles again.
	IncludeInstances(addresses []string) error

	// CanSafelyRemove checks whether it is safe to remove processes from the
	// cluster
	CanSafelyRemove(addresses []string) ([]string, error)

	// KillProcesses restarts processes
	KillInstances(addresses []string) error

	// ChangeCoordinators changes the coordinator set
	ChangeCoordinators(addresses []string) (string, error)

	// VersionSupported reports whether we can support a cluster with a given
	// version.
	VersionSupported(version string) (bool, error)

	// GetProtocolVersion determines the protocol version that is used by a
	// version of FDB.
	GetProtocolVersion(version string) (string, error)

	// Close shuts down any resources for the client once it is no longer
	// needed.
	Close() error
}

AdminClient describes an interface for running administrative commands on a cluster

func NewCliAdminClient

func NewCliAdminClient(cluster *fdbtypes.FoundationDBCluster, _ client.Client) (AdminClient, error)

NewCliAdminClient generates an Admin client for a cluster

func NewMockAdminClient

func NewMockAdminClient(cluster *fdbtypes.FoundationDBCluster, kubeClient client.Client) (AdminClient, error)

NewMockAdminClient creates an admin client for a cluster.

type BounceProcesses

type BounceProcesses struct{}

BounceProcesses provides a reconciliation step for bouncing fdbserver processes.

func (BounceProcesses) Reconcile

func (BounceProcesses) RequeueAfter

func (b BounceProcesses) RequeueAfter() time.Duration

type ChangeCoordinators

type ChangeCoordinators struct{}

ChangeCoordinators provides a reconciliation step for choosing new coordinators.

func (ChangeCoordinators) Reconcile

func (ChangeCoordinators) RequeueAfter

func (c ChangeCoordinators) RequeueAfter() time.Duration

type CheckClientCompatibility added in v0.2.0

type CheckClientCompatibility struct{}

CheckClientCompatibility confirms that all clients are compatible with the version of FoundationDB configured on the cluster.

func (CheckClientCompatibility) Reconcile added in v0.2.0

func (CheckClientCompatibility) RequeueAfter added in v0.2.0

func (c CheckClientCompatibility) RequeueAfter() time.Duration

type ChooseRemovals

type ChooseRemovals struct{}

ChooseRemovals chooses which processes will be removed during a shrink.

func (ChooseRemovals) Reconcile

func (ChooseRemovals) RequeueAfter

func (c ChooseRemovals) RequeueAfter() time.Duration

type CliAdminClient

type CliAdminClient struct {
	// Cluster is the reference to the cluster model.
	Cluster *fdbtypes.FoundationDBCluster
	// contains filtered or unexported fields
}

CliAdminClient provides an implementation of the admin interface using the FDB CLI.

func (*CliAdminClient) CanSafelyRemove

func (client *CliAdminClient) CanSafelyRemove(addresses []string) ([]string, error)

CanSafelyRemove checks whether it is safe to remove processes from the cluster

func (*CliAdminClient) ChangeCoordinators

func (client *CliAdminClient) ChangeCoordinators(addresses []string) (string, error)

SetConnectionString changes the coordinator set

func (*CliAdminClient) Close

func (client *CliAdminClient) Close() error

Close cleans up any pending resources.

func (*CliAdminClient) ConfigureDatabase

func (client *CliAdminClient) ConfigureDatabase(configuration fdbtypes.DatabaseConfiguration, newDatabase bool) error

ConfigureDatabase sets the database configuration

func (*CliAdminClient) ExcludeInstances

func (client *CliAdminClient) ExcludeInstances(addresses []string) error

ExcludeInstances starts evacuating processes so that they can be removed from the database.

func (*CliAdminClient) GetProtocolVersion added in v0.2.0

func (client *CliAdminClient) GetProtocolVersion(version string) (string, error)

GetProtocolVersion determines the protocol version that is used by a version of FDB.

func (*CliAdminClient) GetStatus

func (client *CliAdminClient) GetStatus() (*fdbtypes.FoundationDBStatus, error)

GetStatus gets the database's status

func (*CliAdminClient) IncludeInstances

func (client *CliAdminClient) IncludeInstances(addresses []string) error

IncludeInstances removes processes from the exclusion list and allows them to take on roles again.

func (*CliAdminClient) KillInstances

func (client *CliAdminClient) KillInstances(addresses []string) error

KillInstances restarts processes

func (*CliAdminClient) VersionSupported

func (client *CliAdminClient) VersionSupported(version string) (bool, error)

VersionSupported reports whether we can support a cluster with a given version.

type ExcludeInstances

type ExcludeInstances struct{}

ExcludeInstances provides a reconciliation step for excluding instances from the database.

func (ExcludeInstances) Reconcile

func (ExcludeInstances) RequeueAfter

func (e ExcludeInstances) RequeueAfter() time.Duration

type FdbInstance

type FdbInstance struct {
	Metadata *metav1.ObjectMeta
	Pod      *corev1.Pod
}

FdbInstance represents an instance of FDB that has been configured in Kubernetes.

func (FdbInstance) NamespacedName

func (instance FdbInstance) NamespacedName() types.NamespacedName

NamespacedName gets the name of an instance along with its namespace

type FdbPodClient

type FdbPodClient interface {
	// GetCluster returns the cluster associated with a client
	GetCluster() *fdbtypes.FoundationDBCluster

	// GetPod returns the pod associated with a client
	GetPod() *corev1.Pod

	// GetPodIP gets the IP address for a pod.
	GetPodIP() string

	// IsPresent checks whether a file in the sidecar is present
	IsPresent(filename string) (bool, error)

	// CheckHash checks whether a file in the sidecar has the expected contents.
	CheckHash(filename string, contents string) (bool, error)

	// GenerateMonitorConf updates the monitor conf file for a pod
	GenerateMonitorConf() error

	// CopyFiles copies the files from the config map to the shared dynamic conf
	// volume
	CopyFiles() error

	// GetVariableSubstitutions gets the current keys and values that this
	// instance will substitute into its monitor conf.
	GetVariableSubstitutions() (map[string]string, error)
}

FdbPodClient provides methods for working with a FoundationDB pod

func NewFdbPodClient

func NewFdbPodClient(cluster *fdbtypes.FoundationDBCluster, pod *corev1.Pod) (FdbPodClient, error)

NewFdbPodClient builds a client for working with an FDB Pod

func NewMockFdbPodClient

func NewMockFdbPodClient(cluster *fdbtypes.FoundationDBCluster, pod *corev1.Pod) (FdbPodClient, error)

NewMockFdbPodClient builds a mock client for working with an FDB pod

type GenerateInitialClusterFile

type GenerateInitialClusterFile struct{}

GenerateInitialClusterFile provides a reconciliation step for generating the cluster file for a newly created cluster.

func (GenerateInitialClusterFile) Reconcile

func (GenerateInitialClusterFile) RequeueAfter

func (g GenerateInitialClusterFile) RequeueAfter() time.Duration

type IncludeInstances

type IncludeInstances struct{}

IncludeInstances provides a reconciliation step for re-including instances after removing them.

func (IncludeInstances) Reconcile

func (IncludeInstances) RequeueAfter

func (i IncludeInstances) RequeueAfter() time.Duration

type MockAdminClient

type MockAdminClient struct {
	Cluster               *fdbtypes.FoundationDBCluster
	KubeClient            client.Client
	DatabaseConfiguration *fdbtypes.DatabaseConfiguration
	ExcludedAddresses     []string
	ReincludedAddresses   []string
	KilledAddresses       []string
	// contains filtered or unexported fields
}

MockAdminClient provides a mock implementation of the cluster admin interface

func (*MockAdminClient) CanSafelyRemove

func (client *MockAdminClient) CanSafelyRemove(addresses []string) ([]string, error)

CanSafelyRemove checks whether it is safe to remove processes from the cluster

func (*MockAdminClient) ChangeCoordinators

func (client *MockAdminClient) ChangeCoordinators(addresses []string) (string, error)

ChangeCoordinators changes the coordinator set

func (*MockAdminClient) Close

func (client *MockAdminClient) Close() error

Close shuts down any resources for the client once it is no longer needed.

func (*MockAdminClient) ConfigureDatabase

func (client *MockAdminClient) ConfigureDatabase(configuration fdbtypes.DatabaseConfiguration, newDatabase bool) error

ConfigureDatabase changes the database configuration

func (*MockAdminClient) ExcludeInstances

func (client *MockAdminClient) ExcludeInstances(addresses []string) error

ExcludeInstances starts evacuating processes so that they can be removed from the database.

func (*MockAdminClient) FreezeStatus

func (client *MockAdminClient) FreezeStatus() error

FreezeStatus causes the GetStatus method to return its current value until UnfreezeStatus is called, or another method is called which would invalidate the status.

func (*MockAdminClient) GetProtocolVersion added in v0.2.0

func (client *MockAdminClient) GetProtocolVersion(version string) (string, error)

GetProtocolVersion determines the protocol version that is used by a version of FDB.

func (*MockAdminClient) GetStatus

func (client *MockAdminClient) GetStatus() (*fdbtypes.FoundationDBStatus, error)

GetStatus gets the database's status

func (*MockAdminClient) IncludeInstances

func (client *MockAdminClient) IncludeInstances(addresses []string) error

IncludeInstances removes processes from the exclusion list and allows them to take on roles again.

func (*MockAdminClient) KillInstances

func (client *MockAdminClient) KillInstances(addresses []string) error

KillInstances restarts processes

func (*MockAdminClient) UnfreezeStatus

func (client *MockAdminClient) UnfreezeStatus()

UnfreezeStatus causes the admin client to start recalculating the status on every call to GetStatus

func (*MockAdminClient) VersionSupported

func (client *MockAdminClient) VersionSupported(version string) (bool, error)

VersionSupported reports whether we can support a cluster with a given version.

type PodLifecycleManager

type PodLifecycleManager interface {
	// GetInstances lists the instances in the cluster
	GetInstances(*ReconcileFoundationDBCluster, *fdbtypes.FoundationDBCluster, ctx.Context, *client.ListOptions) ([]FdbInstance, error)

	// CreateInstance creates a new instance based on a pod definition
	CreateInstance(*ReconcileFoundationDBCluster, ctx.Context, *corev1.Pod) error

	// DeleteInstance shuts down an instance
	DeleteInstance(*ReconcileFoundationDBCluster, ctx.Context, FdbInstance) error

	// CanDeletePods checks whether it is safe to delete pods.
	CanDeletePods(*ReconcileFoundationDBCluster, ctx.Context, *fdbtypes.FoundationDBCluster) (bool, error)

	// UpdatePods updates a list of pods to match the latest specs.
	UpdatePods(*ReconcileFoundationDBCluster, ctx.Context, *fdbtypes.FoundationDBCluster, []FdbInstance) error
}

PodLifecycleManager provides an abstraction around created pods to allow using intermediary replication controllers that will manager the basic pod lifecycle.

type ReconcileFoundationDBCluster

type ReconcileFoundationDBCluster struct {
	client.Client
	Recorder            record.EventRecorder
	Scheme              *runtime.Scheme
	InSimulation        bool
	PodLifecycleManager PodLifecycleManager
	PodClientProvider   func(*fdbtypes.FoundationDBCluster, *corev1.Pod) (FdbPodClient, error)
	AdminClientProvider func(*fdbtypes.FoundationDBCluster, client.Client) (AdminClient, error)
}

ReconcileFoundationDBCluster reconciles a FoundationDBCluster object

func (*ReconcileFoundationDBCluster) Reconcile

Reconcile reads that state of the cluster for a FoundationDBCluster object and makes changes based on the state read and what is in the FoundationDBCluster.Spec. Automatically generate RBAC rules to allow the Controller to read and write FoundationDBClusters. +kubebuilder:rbac:groups=core,resources=pods,verbs=get;watch;list;create;update;delete +kubebuilder:rbac:groups=apps.foundationdb.org,resources=foundationdbclusters,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=apps.foundationdb.org,resources=foundationdbclusters/status,verbs=get;update;patch

type ReconciliationNotReadyError

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

ReconciliationNotReadyError is returned when reconciliation cannot proceed because of a temporary condition or because automation is disabled

func (ReconciliationNotReadyError) Error

func (err ReconciliationNotReadyError) Error() string

type RemovePods

type RemovePods struct{}

RemovePods provides a reconciliation step for removing pods as part of a shrink or replacement.

func (RemovePods) Reconcile

func (RemovePods) RequeueAfter

func (u RemovePods) RequeueAfter() time.Duration

type SetDefaultValues

type SetDefaultValues struct {
}

SetDefaultValues provides a reconciliation step for setting default values in the cluster spec.

func (SetDefaultValues) Reconcile

func (SetDefaultValues) RequeueAfter

func (s SetDefaultValues) RequeueAfter() time.Duration

type StandardPodLifecycleManager

type StandardPodLifecycleManager struct {
}

StandardPodLifecycleManager provides an implementation of PodLifecycleManager that directly creates pods.

func (StandardPodLifecycleManager) CanDeletePods

CanDeletePods checks whether it is safe to delete pods.

func (StandardPodLifecycleManager) CreateInstance

func (manager StandardPodLifecycleManager) CreateInstance(r *ReconcileFoundationDBCluster, context ctx.Context, pod *corev1.Pod) error

CreateInstance creates a new instance based on a pod definition

func (StandardPodLifecycleManager) DeleteInstance

func (manager StandardPodLifecycleManager) DeleteInstance(r *ReconcileFoundationDBCluster, context ctx.Context, instance FdbInstance) error

DeleteInstance shuts down an instance

func (StandardPodLifecycleManager) GetInstances

GetInstances returns a list of instances for FDB pods that have been created.

func (StandardPodLifecycleManager) UpdatePods

UpdatePods updates a list of pods to match the latest specs.

type SubReconciler

type SubReconciler interface {
	/**
	Reconcile runs the reconciler's work.

	If reconciliation can continue, this should return (true, nil).

	If reconciliation encounters an error, this should return (false, err).

	If reconciliation cannot proceed, or if this method has to make a change
	to the cluster spec, this should return (false, nil).

	This method will only be called once for a given instance of the reconciler,
	so you can safely store
	*/
	Reconcile(r *ReconcileFoundationDBCluster, context ctx.Context, cluster *fdbtypes.FoundationDBCluster) (bool, error)

	/**
	RequeueAfter returns the delay before we should run the reconciliation
	again.
	*/
	RequeueAfter() time.Duration
}

* This type describes a class that does part of the work of reconciliation.

type UpdateConfigMap

type UpdateConfigMap struct{}

UpdateConfigMap provides a reconciliation step for updating the dynamic conf for a cluster.

func (UpdateConfigMap) Reconcile

func (UpdateConfigMap) RequeueAfter

func (u UpdateConfigMap) RequeueAfter() time.Duration

type UpdateDatabaseConfiguration

type UpdateDatabaseConfiguration struct{}

UpdateDatabaseConfiguration provides a reconciliation step for changing the database configuration.

func (UpdateDatabaseConfiguration) Reconcile

func (UpdateDatabaseConfiguration) RequeueAfter

func (u UpdateDatabaseConfiguration) RequeueAfter() time.Duration

type UpdateLabels

type UpdateLabels struct{}

UpdateLabels provides a reconciliation step for updating the labels on pods.

func (UpdateLabels) Reconcile

func (UpdateLabels) RequeueAfter

func (u UpdateLabels) RequeueAfter() time.Duration

type UpdatePods

type UpdatePods struct{}

UpdatePods provides a reconciliation step for recreating pods with new pod specs.

func (UpdatePods) Reconcile

func (UpdatePods) RequeueAfter

func (u UpdatePods) RequeueAfter() time.Duration

type UpdateSidecarVersions

type UpdateSidecarVersions struct {
}

UpdateSidecarVersions provides a reconciliation step for upgrading the sidecar.

func (UpdateSidecarVersions) Reconcile

func (UpdateSidecarVersions) RequeueAfter

func (u UpdateSidecarVersions) RequeueAfter() time.Duration

type UpdateStatus

type UpdateStatus struct {
	UpdateGenerations bool
}

UpdateStatus provides a reconciliation step for updating the status in the CRD.

func (UpdateStatus) Reconcile

func (UpdateStatus) RequeueAfter

func (s UpdateStatus) RequeueAfter() time.Duration

Jump to

Keyboard shortcuts

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