Skip to content

Commit

Permalink
initial reaper control plane mode
Browse files Browse the repository at this point in the history
  • Loading branch information
emerkle826 committed May 2, 2024
1 parent aa32fe9 commit 83f9773
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
9 changes: 7 additions & 2 deletions apis/reaper/v1alpha1/reaper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ type ReaperSpec struct {
// DatacenterRef is the reference of a CassandraDatacenter resource that this Reaper instance should manage. It will
// also be used as the backend for persisting Reaper's state. Reaper must be able to access the JMX port (7199 by
// default) and the CQL port (9042 by default) on this DC.
// +kubebuilder:validation:Required
DatacenterRef CassandraDatacenterRef `json:"datacenterRef"`
// +optional
DatacenterRef CassandraDatacenterRef `json:"datacenterRef,omitempty"`

// DatacenterAvailability indicates to Reaper its deployment in relation to the target datacenter's network.
// For single-DC clusters, the default (ALL) is fine. For multi-DC clusters, it is recommended to use EACH,
Expand All @@ -267,6 +267,11 @@ type ReaperSpec struct {
// +optional
// +kubebuilder:default=false
SkipSchemaMigration bool `json:"skipSchemaMigration,omitempty"`

// Whether this Reaper instance should register Cassandra clusters for repair. If this is set to false or omitted,
// this Reaper instance will only repair the CassandraDatacener referenced by DatacenterRef.
// +optional
ControlPlaneMode bool `json:"controlPlaneMode,omitempty"`
}

// ReaperProgress is a word summarizing the state of a Reaper resource.
Expand Down
7 changes: 5 additions & 2 deletions charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31875,6 +31875,11 @@ spec:
description: The image tag to use. Defaults to "latest".
type: string
type: object
controlPlaneMode:
description: |-
Whether this Reaper instance should register Cassandra clusters for repair. If this is set to false or omitted,
this Reaper instance will only repair the CassandraDatacener referenced by DatacenterRef.
type: boolean
datacenterAvailability:
default: ALL
description: |-
Expand Down Expand Up @@ -33292,8 +33297,6 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
required:
- datacenterRef
type: object
status:
description: ReaperStatus defines the observed state of Reaper
Expand Down
7 changes: 5 additions & 2 deletions config/crd/bases/reaper.k8ssandra.io_reapers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,11 @@ spec:
description: The image tag to use. Defaults to "latest".
type: string
type: object
controlPlaneMode:
description: |-
Whether this Reaper instance should register Cassandra clusters for repair. If this is set to false or omitted,
this Reaper instance will only repair the CassandraDatacener referenced by DatacenterRef.
type: boolean
datacenterAvailability:
default: ALL
description: |-
Expand Down Expand Up @@ -2447,8 +2452,6 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
required:
- datacenterRef
type: object
status:
description: ReaperStatus defines the observed state of Reaper
Expand Down
19 changes: 13 additions & 6 deletions controllers/reaper/reaper_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,31 @@ func (r *ReaperReconciler) reconcile(ctx context.Context, actualReaper *reaperap
actualReaper.Status.Progress = reaperapi.ReaperProgressPending
actualReaper.Status.SetNotReady()

actualDc, result, err := r.reconcileDatacenter(ctx, actualReaper, logger)
if !result.IsZero() || err != nil {
return result, err
var actualDc *cassdcapi.CassandraDatacenter
// skip DC reconcile if Reaper is in Control Plane
if actualReaper.Spec.ControlPlaneMode {
logger.Info("Skipping Reaper DC reconcile, Reaper is in Control Plane mode")
} else {
dc, result, err := r.reconcileDatacenter(ctx, actualReaper, logger)
if !result.IsZero() || err != nil {
return result, err
}
actualDc = dc
}

actualReaper.Status.Progress = reaperapi.ReaperProgressDeploying

if result, err = r.reconcileDeployment(ctx, actualReaper, actualDc, logger); !result.IsZero() || err != nil {
if result, err := r.reconcileDeployment(ctx, actualReaper, actualDc, logger); !result.IsZero() || err != nil {
return result, err
}

if result, err = r.reconcileService(ctx, actualReaper, logger); !result.IsZero() || err != nil {
if result, err := r.reconcileService(ctx, actualReaper, logger); !result.IsZero() || err != nil {
return result, err
}

actualReaper.Status.Progress = reaperapi.ReaperProgressConfiguring

if result, err = r.configureReaper(ctx, actualReaper, actualDc, logger); !result.IsZero() || err != nil {
if result, err := r.configureReaper(ctx, actualReaper, actualDc, logger); !result.IsZero() || err != nil {
return result, err
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/reaper/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ func NewDeployment(reaper *api.Reaper, dc *cassdcapi.CassandraDatacenter, keysto

readinessProbe := computeProbe(reaper.Spec.ReadinessProbe)
livenessProbe := computeProbe(reaper.Spec.LivenessProbe)
storageType := "cassandra"
if reaper.Spec.ControlPlaneMode {
storageType = "memory"
}

envVars := []corev1.EnvVar{
{
Name: "REAPER_STORAGE_TYPE",
Value: "cassandra",
Value: storageType,
},
{
Name: "REAPER_ENABLE_DYNAMIC_SEED_LIST",
Expand Down

0 comments on commit 83f9773

Please sign in to comment.