reconciliation

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 53 Imported by: 3

Documentation

Overview

Copyright DataStax, Inc. Please see the included license file for details.

Index

Constants

View Source
const (
	DefaultTerminationGracePeriodSeconds = 120
	ServerConfigContainerName            = "server-config-init"
	ServerBaseConfigContainerName        = "server-config-init-base"
	CassandraContainerName               = "cassandra"
	PvcName                              = "server-data"
	SystemLoggerContainerName            = "server-system-logger"
)

Variables

View Source
var (
	// Provides reasonable defaults for the logger container.
	DefaultsLoggerContainer = buildResourceRequirements(100, 64, 0, 128)

	// Provides reasonable defaults for the configuration container.
	DefaultsConfigInitContainer = buildResourceRequirements(1000, 256, 1000, 384)
)
View Source
var (
	ResultShouldNotRequeue     reconcile.Result = reconcile.Result{Requeue: false}
	ResultShouldRequeueNow     reconcile.Result = reconcile.Result{Requeue: true}
	ResultShouldRequeueSoon    reconcile.Result = reconcile.Result{Requeue: true, RequeueAfter: 2 * time.Second}
	ResultShouldRequeueTenSecs reconcile.Result = reconcile.Result{Requeue: true, RequeueAfter: 10 * time.Second}

	QuietDurationFunc func(int) time.Duration = func(secs int) time.Duration { return time.Duration(secs) * time.Second }
)

Functions

func DatacentersForNode

func DatacentersForNode(nodeName string) []types.NamespacedName

Get the dcNames and dcNamespaces for a node

func FilterPodListByCassNodeState

func FilterPodListByCassNodeState(pods []*corev1.Pod, state string) []*corev1.Pod

func FilterPodListByLabel

func FilterPodListByLabel(pods []*corev1.Pod, labelName string, labelVal string) []*corev1.Pod

func FilterPodListByLabels

func FilterPodListByLabels(pods []*corev1.Pod, labelMap map[string]string) []*corev1.Pod

Takes a list of *Pod and filters down to only the pods that match every label/val in the provided label map.

func FindIpForHostId

func FindIpForHostId(endpointData httphelper.CassMetadataEndpoints, hostId string) (string, error)

func HasStartedDecommissioning

func HasStartedDecommissioning(pod *corev1.Pod, epData httphelper.CassMetadataEndpoints, nodeStatuses api.CassandraStatusMap) bool

func IsDoneDecommissioning

func IsDoneDecommissioning(pod *corev1.Pod, epData httphelper.CassMetadataEndpoints, nodeStatuses api.CassandraStatusMap, logger logr.Logger) bool

func ListAllStartedPods

func ListAllStartedPods(pods []*corev1.Pod) []*corev1.Pod

func MapPodsToEndpointDataByName

func MapPodsToEndpointDataByName(pods []*v1.Pod, epData httphelper.CassMetadataEndpoints) map[string]httphelper.EndpointState

func MockSetControllerReference

func MockSetControllerReference() func()

MockSetControllerReference returns a method that will automatically reverse the mock

func PodPtrsFromPodList

func PodPtrsFromPodList(podList *corev1.PodList) []*corev1.Pod

Types

type RackInformation

type RackInformation struct {
	RackName  string
	NodeCount int
	SeedCount int
}

RackInformation contains an identifying name and a node count for a logical rack

type ReconciliationContext

type ReconciliationContext struct {
	Request        *reconcile.Request
	Client         runtimeClient.Client
	Scheme         *runtime.Scheme
	Datacenter     *api.CassandraDatacenter
	NodeMgmtClient httphelper.NodeMgmtClient
	Recorder       record.EventRecorder
	ReqLogger      logr.Logger
	SecretWatches  dynamicwatch.DynamicWatches

	// According to golang recommendations the context should not be stored in a struct but given that
	// this is passed around as a parameter we feel that its a fair compromise. For further discussion
	// see: golang/go#22602
	Ctx context.Context

	Services  []*corev1.Service
	Endpoints *corev1.Endpoints
	// contains filtered or unexported fields
}

ReconciliationContext contains all of the input necessary to calculate a list of ReconciliationActions

func CreateMockReconciliationContext

func CreateMockReconciliationContext(
	reqLogger logr.Logger) *ReconciliationContext

CreateMockReconciliationContext ...

func CreateReconciliationContext

func CreateReconciliationContext(
	ctx context.Context,
	req *reconcile.Request,
	cli runtimeClient.Client,
	scheme *runtime.Scheme,
	rec record.EventRecorder,
	secretWatches dynamicwatch.DynamicWatches) (*ReconciliationContext, error)

CreateReconciliationContext gathers all information needed for computeReconciliationActions into a struct.

func (*ReconciliationContext) CalculateRackInfoForDecomm

func (rc *ReconciliationContext) CalculateRackInfoForDecomm(currentSize int) ([]*RackInformation, error)

func (*ReconciliationContext) CalculateRackInformation

func (rc *ReconciliationContext) CalculateRackInformation() error

CalculateRackInformation determine how many nodes per rack are needed

func (*ReconciliationContext) CalculateReconciliationActions

func (rc *ReconciliationContext) CalculateReconciliationActions() (reconcile.Result, error)

calculateReconciliationActions will iterate over an ordered list of reconcilers which will determine if any action needs to be taken on the CassandraDatacenter. If a change is needed then the apply function will be called on that reconciler and the request will be requeued for the next reconciler to handle in the subsequent reconcile loop, otherwise the next reconciler will be called.

func (*ReconciliationContext) CheckAdditionalSeedEndpoints

func (rc *ReconciliationContext) CheckAdditionalSeedEndpoints() result.ReconcileResult

func (*ReconciliationContext) CheckCassandraNodeStatuses

func (rc *ReconciliationContext) CheckCassandraNodeStatuses() result.ReconcileResult

func (*ReconciliationContext) CheckClearActionConditions

func (rc *ReconciliationContext) CheckClearActionConditions() result.ReconcileResult

func (*ReconciliationContext) CheckConditionInitializedAndReady

func (rc *ReconciliationContext) CheckConditionInitializedAndReady() result.ReconcileResult

func (*ReconciliationContext) CheckConfigSecret

func (rc *ReconciliationContext) CheckConfigSecret() result.ReconcileResult

CheckConfigSecret When the ConfigSecret property is set, take the configuration from the specified secret and add to the datacenter configuration secret. The datacenter configuration is created by cass-operator. A second secret is used because cass-operator adds additional properties to the configuration, and we do not want to write that updated configuration back to the user's secret since we do not own it.

func (*ReconciliationContext) CheckDcPodDisruptionBudget

func (rc *ReconciliationContext) CheckDcPodDisruptionBudget() result.ReconcileResult

func (*ReconciliationContext) CheckDecommissioningNodes

func (rc *ReconciliationContext) CheckDecommissioningNodes(epData httphelper.CassMetadataEndpoints) result.ReconcileResult

Wait for decommissioning nodes to finish before continuing to reconcile

func (*ReconciliationContext) CheckForInvalidState

func (rc *ReconciliationContext) CheckForInvalidState() result.ReconcileResult

func (*ReconciliationContext) CheckFullQueryLogging added in v1.9.0

func (rc *ReconciliationContext) CheckFullQueryLogging() result.ReconcileResult

CheckFullQueryLogging sets FQL enabled or disabled. It calls the NodeMgmtClient which calls the Cassandra management API and returns a result.ReconcileResult.

func (*ReconciliationContext) CheckHeadlessServices

func (rc *ReconciliationContext) CheckHeadlessServices() result.ReconcileResult

ReconcileHeadlessService ...

func (*ReconciliationContext) CheckInternodeCredentialCreation

func (rc *ReconciliationContext) CheckInternodeCredentialCreation() result.ReconcileResult

func (*ReconciliationContext) CheckPodsReady

CheckPodsReady loops over all the server pods and starts them

func (*ReconciliationContext) CheckRackCreation

func (rc *ReconciliationContext) CheckRackCreation() result.ReconcileResult

func (*ReconciliationContext) CheckRackForceUpgrade

func (rc *ReconciliationContext) CheckRackForceUpgrade() result.ReconcileResult

func (*ReconciliationContext) CheckRackLabels

func (rc *ReconciliationContext) CheckRackLabels() result.ReconcileResult

func (*ReconciliationContext) CheckRackPodLabels

func (rc *ReconciliationContext) CheckRackPodLabels() result.ReconcileResult

CheckRackPodLabels checks each pod and its volume(s) and makes sure they have the proper labels

func (*ReconciliationContext) CheckRackPodTemplate

func (rc *ReconciliationContext) CheckRackPodTemplate() result.ReconcileResult

func (*ReconciliationContext) CheckRackScale

func (rc *ReconciliationContext) CheckRackScale() result.ReconcileResult

CheckRackScale loops over each statefulset and makes sure that it has the right amount of desired replicas. At this time we can only increase the amount of replicas.

func (*ReconciliationContext) CheckRackStoppedState

func (rc *ReconciliationContext) CheckRackStoppedState() result.ReconcileResult

func (*ReconciliationContext) CheckRollingRestart

func (rc *ReconciliationContext) CheckRollingRestart() result.ReconcileResult

func (*ReconciliationContext) CheckStatefulSetControllerCaughtUp

func (rc *ReconciliationContext) CheckStatefulSetControllerCaughtUp() result.ReconcileResult

func (*ReconciliationContext) CheckSuperuserSecretCreation

func (rc *ReconciliationContext) CheckSuperuserSecretCreation() result.ReconcileResult

func (*ReconciliationContext) CreateEndpointsForAdditionalSeedService

func (rc *ReconciliationContext) CreateEndpointsForAdditionalSeedService() result.ReconcileResult

func (*ReconciliationContext) CreateHeadlessServices

func (rc *ReconciliationContext) CreateHeadlessServices() result.ReconcileResult

func (*ReconciliationContext) CreateUsers

func (rc *ReconciliationContext) CreateUsers() result.ReconcileResult

func (*ReconciliationContext) DecommissionNodeOnRack

func (rc *ReconciliationContext) DecommissionNodeOnRack(rackName string, epData httphelper.CassMetadataEndpoints, lastPodSuffix string) error

func (*ReconciliationContext) DecommissionNodes

func (*ReconciliationContext) DeletePodPvcs

func (rc *ReconciliationContext) DeletePodPvcs(pod *corev1.Pod) error

func (*ReconciliationContext) EnsurePodsCanAbsorbDecommData

func (rc *ReconciliationContext) EnsurePodsCanAbsorbDecommData(decommPod *corev1.Pod, epData httphelper.CassMetadataEndpoints) error

func (*ReconciliationContext) GetAdditionalSeedEndpoint

func (rc *ReconciliationContext) GetAdditionalSeedEndpoint() (*corev1.Endpoints, error)

func (*ReconciliationContext) GetClient

func (rc *ReconciliationContext) GetClient() runtimeClient.Client

func (*ReconciliationContext) GetContext

func (rc *ReconciliationContext) GetContext() context.Context

func (*ReconciliationContext) GetDatacenter

func (rc *ReconciliationContext) GetDatacenter() *api.CassandraDatacenter

func (*ReconciliationContext) GetLogger

func (rc *ReconciliationContext) GetLogger() logr.Logger

func (*ReconciliationContext) GetPodPVC

func (rc *ReconciliationContext) GetPodPVC(podNamespace string, podName string) (*corev1.PersistentVolumeClaim, error)

func (*ReconciliationContext) GetStatefulSetForRack

func (rc *ReconciliationContext) GetStatefulSetForRack(
	nextRack *RackInformation) (*appsv1.StatefulSet, bool, error)

GetStatefulSetForRack returns the statefulset for the rack and whether it currently exists and whether an error occurred

func (*ReconciliationContext) GetUsedStorageForPods

func (rc *ReconciliationContext) GetUsedStorageForPods(epData httphelper.CassMetadataEndpoints) (map[string]float64, error)

func (*ReconciliationContext) GetUsers

func (rc *ReconciliationContext) GetUsers() []api.CassandraUser

func (*ReconciliationContext) IsValid

func (*ReconciliationContext) ProcessDeletion

func (rc *ReconciliationContext) ProcessDeletion() result.ReconcileResult

ProcessDeletion ...

func (*ReconciliationContext) ReconcileAllRacks

func (rc *ReconciliationContext) ReconcileAllRacks() (reconcile.Result, error)

ReconcileAllRacks determines if a rack needs to be reconciled.

func (*ReconciliationContext) ReconcileNextRack

func (rc *ReconciliationContext) ReconcileNextRack(statefulSet *appsv1.StatefulSet) error

ReconcileNextRack ensures that the resources for a rack have been properly created

func (*ReconciliationContext) ReconcilePods

func (rc *ReconciliationContext) ReconcilePods(statefulSet *appsv1.StatefulSet) error

ReconcilePods ...

func (*ReconciliationContext) RemoveDecommissionedPodFromSts

func (rc *ReconciliationContext) RemoveDecommissionedPodFromSts(pod *corev1.Pod) error

func (*ReconciliationContext) SetDatacenterAsOwner

func (rc *ReconciliationContext) SetDatacenterAsOwner(controlled metav1.Object) error

func (*ReconciliationContext) UpdateCassandraNodeStatus

func (rc *ReconciliationContext) UpdateCassandraNodeStatus(force bool) error

func (*ReconciliationContext) UpdateRackNodeCount

func (rc *ReconciliationContext) UpdateRackNodeCount(statefulSet *appsv1.StatefulSet, newNodeCount int32) error

Updates the node count on a rack (statefulset)

func (*ReconciliationContext) UpdateSecretWatches

func (rc *ReconciliationContext) UpdateSecretWatches() error

func (*ReconciliationContext) UpdateStatus

func (rc *ReconciliationContext) UpdateStatus() result.ReconcileResult

func (*ReconciliationContext) UpdateStatusForUserActions

func (rc *ReconciliationContext) UpdateStatusForUserActions() error

Jump to

Keyboard shortcuts

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