Help us shape the future of Go! Take the 2026 Go Developer Survey

reconciliation

package
v1.6.0 Latest Latest
Warning

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

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

Documentation

Overview

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

Index

Constants

View Source
const (
	DefaultTerminationGracePeriodSeconds = 120
	ServerConfigContainerName            = "server-config-init"
	CassandraContainerName               = "cassandra"
	PvcName                              = "server-data"
	SystemLoggerContainerName            = "server-system-logger"
)
View Source
const (
	ReaperUIPort            = 7080
	ReaperAdminPort         = 7081
	ReaperDefaultPullPolicy = corev1.PullIfNotPresent
	ReaperContainerName     = "reaper"
	ReaperHealthCheckPath   = "/healthcheck"
	ReaperKeyspace          = "reaper_db"
	ReaperSchemaInitJob     = "ReaperSchemaInitJob"
	// This code currently lives at https://github.com/jsanda/create_keyspace.
	ReaperSchemaInitJobImage = "jsanda/reaper-init-keyspace:latest"
)

Variables

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

	// Provides reasonable defaults for the configuration container.
	DefaultsConfigInitContainer = buildResourceRequirements(1000, 256)

	// Provides reasonable defaults for the reaper sidecar container.
	DefaultsReaperContainer = buildResourceRequirements(2000, 512)
)
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}
)

Functions

func DatacentersForNode added in v1.5.0

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 added in v1.5.1

func HasStartedDecommissioning(pod *v1.Pod, epData httphelper.CassMetadataEndpoints) bool

func IsDoneDecommissioning added in v1.5.0

func IsDoneDecommissioning(pod *v1.Pod, epData httphelper.CassMetadataEndpoints) bool

func ListAllStartedPods

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

func MapPodsToEndpointDataByName added in v1.5.0

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 NewReconciler

func NewReconciler(mgr manager.Manager) reconcile.Reconciler

NewReconciler returns a new reconcile.Reconciler

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 ReconcileCassandraDatacenter

type ReconcileCassandraDatacenter struct {

	// SecretWatches is used in the controller when setting up the watches and
	// during reconciliation where we update the mappings for the watches.
	// Putting it here allows us to get it to both places.
	SecretWatches dynamicwatch.DynamicWatches
	// contains filtered or unexported fields
}

ReconcileCassandraDatacenter reconciles a cassandraDatacenter object This is placed here to avoid a circular dependency

func (*ReconcileCassandraDatacenter) Reconcile

Reconcile reads that state of the cluster for a Datacenter object and makes changes based on the state read and what is in the cassandraDatacenter.Spec Note: The Controller will requeue the Request to be processed again if the returned error is non-nil or Result.Requeue is true, otherwise upon completion it will remove the work from the queue. See: https://godoc.org/sigs.k8s.io/controller-runtime/pkg/reconcile#Result

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
	PSPHealthUpdater psp.HealthStatusUpdater
	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(
	req *reconcile.Request,
	cli runtimeClient.Client,
	scheme *runtime.Scheme,
	rec record.EventRecorder,
	secretWatches dynamicwatch.DynamicWatches,
	reqLogger logr.Logger) (*ReconciliationContext, error)

CreateReconciliationContext gathers all information needed for computeReconciliationActions into a struct.

func (*ReconciliationContext) CalculateRackInfoForDecomm added in v1.5.0

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) CheckAdditionalSeedEndpoints added in v1.4.0

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

func (*ReconciliationContext) CheckCassandraNodeStatuses added in v1.3.0

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) CheckDcPodDisruptionBudget

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

func (*ReconciliationContext) CheckDecommissioningNodes added in v1.5.0

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

Wait for decommissioning nodes to finish before continuing to reconcile

func (*ReconciliationContext) CheckForInvalidState added in v1.5.0

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

func (*ReconciliationContext) CheckHeadlessServices

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

ReconcileHeadlessService ...

func (*ReconciliationContext) CheckInternodeCredentialCreation added in v1.4.0

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) CheckReaperSchemaInitialized added in v1.3.0

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

func (*ReconciliationContext) CheckReaperService added in v1.3.0

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

func (*ReconciliationContext) CheckRollingRestart

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

func (*ReconciliationContext) CheckStatefulSetControllerCaughtUp added in v1.5.0

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

func (*ReconciliationContext) CheckSuperuserSecretCreation

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

func (*ReconciliationContext) CreateEndpointsForAdditionalSeedService added in v1.4.0

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

func (*ReconciliationContext) CreateHeadlessServices

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

func (*ReconciliationContext) CreateUsers added in v1.3.0

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

func (*ReconciliationContext) DecommissionNodeOnRack added in v1.5.0

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

func (*ReconciliationContext) DecommissionNodes added in v1.5.0

func (*ReconciliationContext) DeletePodPvcs added in v1.5.0

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

func (*ReconciliationContext) EnsurePodsCanAbsorbDecommData added in v1.5.0

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

func (*ReconciliationContext) GetAllNodes added in v1.5.1

func (rc *ReconciliationContext) GetAllNodes() ([]*corev1.Node, error)

func (*ReconciliationContext) GetAllNodesInDC added in v1.5.0

func (rc *ReconciliationContext) GetAllNodesInDC() ([]*corev1.Node, error)

func (*ReconciliationContext) GetAllPodsNotReadyInDC added in v1.5.0

func (rc *ReconciliationContext) GetAllPodsNotReadyInDC() []*corev1.Pod

func (*ReconciliationContext) GetClient added in v1.5.0

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

func (*ReconciliationContext) GetContext added in v1.5.0

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

func (*ReconciliationContext) GetDCPods added in v1.5.0

func (rc *ReconciliationContext) GetDCPods() []*corev1.Pod

func (*ReconciliationContext) GetDatacenter added in v1.5.0

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

func (*ReconciliationContext) GetInProgressNodeReplacements added in v1.5.0

func (rc *ReconciliationContext) GetInProgressNodeReplacements() []string

func (*ReconciliationContext) GetLogger added in v1.5.0

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

func (*ReconciliationContext) GetNotReadyPodsBootstrappedInDC added in v1.5.0

func (rc *ReconciliationContext) GetNotReadyPodsBootstrappedInDC() []*corev1.Pod

func (*ReconciliationContext) GetPodPVC added in v1.5.0

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

func (*ReconciliationContext) GetPodPVCs added in v1.5.0

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 added in v1.5.0

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

func (*ReconciliationContext) GetUsers added in v1.3.0

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

func (*ReconciliationContext) IsInitialized added in v1.5.0

func (rc *ReconciliationContext) IsInitialized() bool

func (*ReconciliationContext) IsStopped added in v1.5.0

func (rc *ReconciliationContext) IsStopped() bool

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) RemoveDcFromNodeToDcMap added in v1.5.0

func (rc *ReconciliationContext) RemoveDcFromNodeToDcMap(dcToRemove types.NamespacedName)

func (*ReconciliationContext) RemoveDecommissionedPodFromSts added in v1.5.0

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

func (*ReconciliationContext) RemovePod added in v1.5.0

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

func (*ReconciliationContext) SetDatacenterAsOwner added in v1.5.0

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

func (*ReconciliationContext) StartNodeReplace added in v1.5.0

func (rc *ReconciliationContext) StartNodeReplace(podName string) error

func (*ReconciliationContext) UpdateCassandraNodeStatus

func (rc *ReconciliationContext) UpdateCassandraNodeStatus() error

func (*ReconciliationContext) UpdatePod added in v1.5.0

func (rc *ReconciliationContext) UpdatePod(pod *corev1.Pod) 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 added in v1.3.0

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