cassandracluster

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package cassandra contains the reconciliation logic for the vault Custom Resource.

Index

Constants

View Source
const (
	JolokiaPort     = 8778
	JolokiaPortName = "jolokia"
)

Variables

This section is empty.

Functions

func Add

func Add(mgr manager.Manager) error

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

func CheckNonAllowedRemoveDC

func CheckNonAllowedRemoveDC(rcc *ReconcileCassandraCluster, cc *api.CassandraCluster,
	status *api.CassandraClusterStatus, oldCRD *api.CassandraCluster) (bool, string)

CheckNonAllowedRemoveDC checks to see if the Operator accepts or refuses the CRD changes

func FlipCassandraClusterUpdateSeedListStatus

func FlipCassandraClusterUpdateSeedListStatus(cc *api.CassandraCluster, status *api.CassandraClusterStatus)

FlipCassandraClusterUpdateSeedListStatus checks if all racks has the status UpdateSeedList=To-do It then sets UpdateSeedList to Ongoing to start the operation

func GetLastOrFirstPod

func GetLastOrFirstPod(podsList *v1.PodList, last bool) (*v1.Pod, error)

GetLastOrFirstPod returns the last or first pod satisfying the selector and being in the namespace

func JolokiaURL

func JolokiaURL(host string, port int) string

JolokiaURL returns the url used to connect to a Jolokia server based on a host and a port

func PodContainersReady

func PodContainersReady(pod *v1.Pod) bool

PodContainersReady returns true if all container in the Pod are ready

func UpdateCassandraClusterStatusPhase

func UpdateCassandraClusterStatusPhase(cc *api.CassandraCluster, status *api.CassandraClusterStatus)

UpdateCassandraClusterStatusPhase goal is to calculate the Cluster Phase according to StatefulSet Status.

func UpdateStatusIfDockerImageHasChanged

func UpdateStatusIfDockerImageHasChanged(cc *api.CassandraCluster, dcRackName string, storedStatefulSet *appsv1.StatefulSet, status *api.CassandraClusterStatus) bool

UpdateStatusIfDockerImageHasChanged updates CassandraCluster Action Status if it detect a changes in the DockerImage:

func UpdateStatusIfRollingRestart

func UpdateStatusIfRollingRestart(cc *api.CassandraCluster, dc,
	rack int, dcRackName string, storedStatefulSet *appsv1.StatefulSet, status *api.CassandraClusterStatus) bool

func UpdateStatusIfScaling

func UpdateStatusIfScaling(cc *api.CassandraCluster, dcRackName string, storedStatefulSet *appsv1.StatefulSet, status *api.CassandraClusterStatus) bool

UpdateStatusIfScaling will detect any change of replicas For Scale Down the operator will need to first Decommission the last node from Cassandra before remooving it from kubernetes. For Scale Up some PodOperations may be scheduled if Auto-pilot is activeted.

func UpdateStatusIfSeedListHasChanged

func UpdateStatusIfSeedListHasChanged(cc *api.CassandraCluster, dcRackName string, storedStatefulSet *appsv1.StatefulSet, status *api.CassandraClusterStatus) bool

UpdateStatusIfSeedListHasChanged updates CassandraCluster Action Status if it detect a changes

func UpdateStatusIfStatefulSetChanged

func UpdateStatusIfStatefulSetChanged(cc *api.CassandraCluster, dcRackName string, storedStatefulSet *appsv1.StatefulSet, status *api.CassandraClusterStatus) bool

UpdateStatusIfStatefulSetChanged detects if there is a change in the statefulset which was not already caught If we detect a Statefulset change with this method, then the operator won't catch it before the statefulset tells the operator that a change is ongoing. That mean that all statefulsets may do their rolling upgrade in parallel, so there will be <nbRacks> node down in // in the cluster.

func UpdateStatusIfconfigMapHasChanged

func UpdateStatusIfconfigMapHasChanged(cc *api.CassandraCluster, dcRackName string, storedStatefulSet *appsv1.StatefulSet, status *api.CassandraClusterStatus) bool

UpdateStatusIfconfigMapHasChanged updates CassandraCluster Action Status if it detect a changes : - a new configmapName in the CRD - or the add or remoove of the configmap in the CRD

Types

type JolokiaClient

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

JolokiaClient is a structure that exposes a host and a jolokia client

func NewJolokiaClient

func NewJolokiaClient(host string, port int, rcc *ReconcileCassandraCluster,
	secretRef v1.LocalObjectReference, namespace string) (*JolokiaClient, error)

NewJolokiaClient returns a new Joloka client for the host name and port provided

func (*JolokiaClient) HasDataInDC

func (jolokiaClient *JolokiaClient) HasDataInDC(dc string) ([]string, error)

HasDataInDC checks partition ranges of all non local keyspaces and ensure no data is replicated to the chosen datacenter

func (*JolokiaClient) NodeCleanup

func (jolokiaClient *JolokiaClient) NodeCleanup() error

NodeCleanup triggers a cleanup of all keyspaces on the pod using a jolokia client and return the index of the last keyspace accessed and any error

func (*JolokiaClient) NodeCleanupKeyspaces

func (jolokiaClient *JolokiaClient) NodeCleanupKeyspaces(keyspaces []string) error

NodeCleanupKeyspaces triggers a cleanup of each keyspaces on the pod using a jolokia client and returns the index of the last keyspace accessed and any error

func (*JolokiaClient) NodeDecommission

func (jolokiaClient *JolokiaClient) NodeDecommission() error

NodeDecommission decommissions a node using a jolokia client and returns any error

func (*JolokiaClient) NodeOperationMode

func (jolokiaClient *JolokiaClient) NodeOperationMode() (string, error)

NodeOperationMode returns OperationMode of a node using a jolokia client and returns any error

func (*JolokiaClient) NodeRebuild

func (jolokiaClient *JolokiaClient) NodeRebuild(dc string) error

NodeRebuild triggers a rebuild of all keyspaces on the pod using a jolokia client and returns any error

func (*JolokiaClient) NodeRemove

func (jolokiaClient *JolokiaClient) NodeRemove(hostid string) error

NodeRemove remove node hostid on the pod using a jolokia client and returns any error

func (*JolokiaClient) NodeUpgradeSSTables

func (jolokiaClient *JolokiaClient) NodeUpgradeSSTables(threads int) error

NodeUpgradeSSTables triggers an upgradeSSTables of each keyspaces through a jolokia client and returns any error

func (*JolokiaClient) NodeUpgradeSSTablesKeyspaces

func (jolokiaClient *JolokiaClient) NodeUpgradeSSTablesKeyspaces(keyspaces []string,
	threads int) error

NodeUpgradeSSTablesKeyspaces triggers an upgradeSSTables for a list of keyspaces through a jolokia connection and returns any error

type JvmMemory

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

JvmMemory sets the maximium size of the heap

type ReconcileCassandraCluster

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

ReconcileCassandraCluster reconciles a CassandraCluster object

func (*ReconcileCassandraCluster) CheckDeletePVC

func (rcc *ReconcileCassandraCluster) CheckDeletePVC(cc *api.CassandraCluster) error

CheckDeletePVC checks if DeletePVC is updated and update DeletePVC strategy

func (*ReconcileCassandraCluster) CheckNonAllowedChanged

func (rcc *ReconcileCassandraCluster) CheckNonAllowedChanged(cc *api.CassandraCluster,
	status *api.CassandraClusterStatus) bool

CheckNonAllowedChanged - checks if there are some changes on CRD that are not allowed on statefulset If a non Allowed Changed is Find we won't Update associated kubernetes objects, but we will put back the old value and Patch the CRD with correct values

func (*ReconcileCassandraCluster) CheckNonAllowedScaleDown

func (rcc *ReconcileCassandraCluster) CheckNonAllowedScaleDown(cc *api.CassandraCluster,
	status *api.CassandraClusterStatus,
	oldCRD *api.CassandraCluster) (bool, string)

CheckNonAllowedScaleDown goal is to discard the scaleDown to 0 is there is still replicated data towards the corresponding DC

func (*ReconcileCassandraCluster) CreateOrUpdatePod

func (rcc *ReconcileCassandraCluster) CreateOrUpdatePod(namespace string, name string, pod *v1.Pod) error

func (*ReconcileCassandraCluster) CreateOrUpdatePodDisruptionBudget

func (rcc *ReconcileCassandraCluster) CreateOrUpdatePodDisruptionBudget(pdb *policyv1beta1.PodDisruptionBudget) error

CreateOrUpdatePodDisruptionBudget Create PodDisruptionBudget if not existing, or update it if existing.

func (*ReconcileCassandraCluster) CreateOrUpdateStatefulSet

func (rcc *ReconcileCassandraCluster) CreateOrUpdateStatefulSet(statefulSet *appsv1.StatefulSet,
	status *api.CassandraClusterStatus, dcRackName string) error

CreateOrUpdateStatefulSet Create statefulset if not existing, or update it if existing.

func (*ReconcileCassandraCluster) CreatePod

func (rcc *ReconcileCassandraCluster) CreatePod(pod *v1.Pod) error

func (*ReconcileCassandraCluster) CreatePodDisruptionBudget

func (rcc *ReconcileCassandraCluster) CreatePodDisruptionBudget(pdb *policyv1beta1.PodDisruptionBudget) error

CreatePodDisruptionBudget create a new PodDisruptionBudget pdb

func (*ReconcileCassandraCluster) CreateStatefulSet

func (rcc *ReconcileCassandraCluster) CreateStatefulSet(statefulSet *appsv1.StatefulSet) error

CreateStatefulSet create a new statefulset ss

func (*ReconcileCassandraCluster) DeletePVCs

func (rcc *ReconcileCassandraCluster) DeletePVCs(cc *api.CassandraCluster, dcName string, rackName string)

DeletePVC deletes persistentvolumes of nodes in a rack

func (*ReconcileCassandraCluster) DeletePod

func (rcc *ReconcileCassandraCluster) DeletePod(pod *v1.Pod) error

DeletePod delete a pod

func (*ReconcileCassandraCluster) DeletePodDisruptionBudget

func (rcc *ReconcileCassandraCluster) DeletePodDisruptionBudget(pdb *policyv1beta1.PodDisruptionBudget) error

DeletePodDisruptionBudget delete a new PodDisruptionBudget pdb

func (*ReconcileCassandraCluster) DeleteService

func (rcc *ReconcileCassandraCluster) DeleteService(namespace, name string) error

func (*ReconcileCassandraCluster) DeleteStatefulSet

func (rcc *ReconcileCassandraCluster) DeleteStatefulSet(namespace, name string) error

func (*ReconcileCassandraCluster) ForceDeletePod

func (rcc *ReconcileCassandraCluster) ForceDeletePod(pod *v1.Pod) error

ForceDeletePod delete a pod with a grace period of 0 seconds

func (*ReconcileCassandraCluster) GetFirstPod

func (rcc *ReconcileCassandraCluster) GetFirstPod(namespace string, selector map[string]string) (*v1.Pod, error)

GetFirstPod returns the first pod satisfying the selector and being in the namespace

func (*ReconcileCassandraCluster) GetLastPod

func (rcc *ReconcileCassandraCluster) GetLastPod(namespace string, selector map[string]string) (*v1.Pod, error)

GetLastPod returns the last pod satisfying the selector and being in the namespace

func (*ReconcileCassandraCluster) GetPVC

func (rcc *ReconcileCassandraCluster) GetPVC(namespace, name string) (*v1.PersistentVolumeClaim, error)

func (*ReconcileCassandraCluster) GetPod

func (rcc *ReconcileCassandraCluster) GetPod(namespace, name string) (*v1.Pod, error)

func (*ReconcileCassandraCluster) GetPodDisruptionBudget

func (rcc *ReconcileCassandraCluster) GetPodDisruptionBudget(namespace,
	name string) (*policyv1beta1.PodDisruptionBudget, error)

GetPodDisruptionBudget return the PodDisruptionBudget name from the cluster in the namespace

func (*ReconcileCassandraCluster) GetStatefulSet

func (rcc *ReconcileCassandraCluster) GetStatefulSet(namespace, name string) (*appsv1.StatefulSet, error)

GetStatefulSet return the Statefulset name from the cluster in the namespace

func (*ReconcileCassandraCluster) ListPVC

func (rcc *ReconcileCassandraCluster) ListPVC(namespace string,
	selector map[string]string) (*v1.PersistentVolumeClaimList, error)

func (*ReconcileCassandraCluster) ListPods

func (rcc *ReconcileCassandraCluster) ListPods(namespace string, selector map[string]string) (*v1.PodList, error)

func (*ReconcileCassandraCluster) Reconcile

func (rcc *ReconcileCassandraCluster) Reconcile(request reconcile.Request) (reconcile.Result, error)

Reconcile reads that state of the cluster for a CassandraCluster object and makes changes based on the state read and what is in the CassandraCluster.Spec a Pod as an example 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.

func (*ReconcileCassandraCluster) ReconcileRack

func (rcc *ReconcileCassandraCluster) ReconcileRack(cc *api.CassandraCluster,
	status *api.CassandraClusterStatus) (err error)

ReconcileRack will try to reconcile cassandra for each of the couple DC/Rack defined in the topology

func (*ReconcileCassandraCluster) UpdateCassandraRackStatusPhase

func (rcc *ReconcileCassandraCluster) UpdateCassandraRackStatusPhase(cc *api.CassandraCluster, dcName string,
	rackName string, storedStatefulSet *appsv1.StatefulSet, status *api.CassandraClusterStatus) error

UpdateCassandraRackStatusPhase goal is to calculate the Cluster Phase according to StatefulSet Status. The Phase is: Initializing -> Running <--> Pending The Phase is a very high level view of the cluster, for a better view we need to see Actions and Pod Operations

func (*ReconcileCassandraCluster) UpdatePod

func (rcc *ReconcileCassandraCluster) UpdatePod(pod *v1.Pod) error

func (*ReconcileCassandraCluster) UpdatePodDisruptionBudget

func (rcc *ReconcileCassandraCluster) UpdatePodDisruptionBudget(pdb *policyv1beta1.PodDisruptionBudget) error

UpdatePodDisruptionBudget updates an existing PodDisruptionBudget pdb

func (*ReconcileCassandraCluster) UpdatePodLabel

func (rcc *ReconcileCassandraCluster) UpdatePodLabel(pod *v1.Pod, label map[string]string) error

func (*ReconcileCassandraCluster) UpdateStatefulSet

func (rcc *ReconcileCassandraCluster) UpdateStatefulSet(statefulSet *appsv1.StatefulSet) error

UpdateStatefulSet updates an existing statefulset ss

func (*ReconcileCassandraCluster) UpdateStatusIfActionEnded

func (rcc *ReconcileCassandraCluster) UpdateStatusIfActionEnded(cc *api.CassandraCluster, dcName string,
	rackName string, storedStatefulSet *appsv1.StatefulSet, status *api.CassandraClusterStatus) bool

UpdateStatusIfActionEnded Implement Tests to detect End of Ongoing Actions

Jump to

Keyboard shortcuts

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