Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reaper Control Plane Deployment Mode #1388

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

rzvoncek
Copy link
Contributor

@rzvoncek rzvoncek commented Aug 22, 2024

What this PR does:

Which issue(s) this PR fixes:
Fixes #1277

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CHANGELOG.md updated (not required for documentation PRs)
  • CLA Signed: DataStax CLA

@rzvoncek rzvoncek requested a review from a team as a code owner August 22, 2024 10:26
@rzvoncek rzvoncek force-pushed the radovan/reaper-control-plane-3 branch from a65db81 to fbc98de Compare August 22, 2024 11:54
return ErrNoReaperStorageRequest
}
}
if r.Spec.Reaper.StorageType == reaperapi.StorageTypeLocal && r.Spec.Reaper.DeploymentMode == reaperapi.DeploymentModePerDc {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need to enforce this here. Reaper won't come up, in this situation, so it's not the end of the world. On the other hand, it broke one e2e test, so perhaps it'll break stuff for users out there also.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny it broke an e2e test given none of them should use local as storage mode 🤔

Copy link
Contributor Author

@rzvoncek rzvoncek Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've actually added a local storage mode to one of the fixtures in the StatefulSet PR here. This is used by the CreateReaperAndDatacenter e2e test.
The idea of doing this was to cover the STS situation without adding a brand new e2e test, which I suppose we should try to avoid.
Here, for the CP mode, the change seems to me being big enough to warrant a new scenario tho.

@rzvoncek rzvoncek force-pushed the radovan/reaper-control-plane-3 branch from fbc98de to cc16a83 Compare August 22, 2024 13:43
Copy link
Contributor

@adejanovski adejanovski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is coming to shape nicely!
I have a few suggestions that should hopefully be easy to implement in order to harmonize with how we do things elsewhere in the operator.
Could you create a ticket to update the docs as well, we'll need to make it easy for users to use this new feature.
Thanks!

return ErrNoReaperStorageRequest
}
}
if r.Spec.Reaper.StorageType == reaperapi.StorageTypeLocal && r.Spec.Reaper.DeploymentMode == reaperapi.DeploymentModePerDc {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny it broke an e2e test given none of them should use local as storage mode 🤔

apis/reaper/v1alpha1/reaper_types.go Outdated Show resolved Hide resolved
CHANGELOG/CHANGELOG-1.18.md Outdated Show resolved Hide resolved
controllers/k8ssandra/secrets.go Outdated Show resolved Hide resolved
controllers/k8ssandra/reaper.go Outdated Show resolved Hide resolved
controllers/k8ssandra/reaper.go Outdated Show resolved Hide resolved
controllers/k8ssandra/reaper.go Outdated Show resolved Hide resolved
@@ -41,6 +41,10 @@ func SuperuserSecretName(kc *api.K8ssandraCluster) string {
}

func (r *K8ssandraClusterReconciler) reconcileReaperSecrets(ctx context.Context, kc *api.K8ssandraCluster, logger logr.Logger) result.ReconcileResult {
if kc.Spec.Reaper != nil && kc.Spec.Reaper.ReaperRef.Name != "" {
logger.Info("ReaperRef points to an existing Reaper, we don't need a new Reaper CQL secret")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Same as before, I'm thinking the reference to an existing reaper isn't what drives the creation of a CQL user, but rather the storage attribute and the fact that we're using JMX (or not).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's as straightforward here. But perhaps I still don't understand things well enough.

We are here in the k8ssandra cluster reconciliation loop, and we're checking what the kc.reaper.Spec tells us.
We are deciding what to do with the CQL secret and the UI secret. We're not dealing with the JMX (except if the CQL and JMX secrets are one and the same).

We only want to reconcile(~create) the secrets if we're using a k8ssandra-cluster-specific Reaper.

We can have a k8ssandra-cluster-specific Reaper with local storage. In that case we don't need a CQL secret, only the UI secret. This is checked on L68.

I think that's why we cannot check for just the storage on L44. I'd really need the isControlPlane() function somewhere, but I cannot have that for other reasons. The ReaperRef presence is still my favourite alternative to that.

To sum up, I think I'd need clarification of:

  • how the JMX secret comes into this?
  • do we actually want to allow bundled Reapers with local storage?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we actually want to allow bundled Reapers with local storage?

Yes, why not? It's an efficient storage mechanism which doesn't require using Cassandra itself.

how the JMX secret comes into this?

The cases where we need Reaper to create users is for:

  • authenticated access with JMX enabled
  • using cassandra as storage for Reaper

One could have a centralized Reaper using JMX to communicate with the Cassandra clusters. It's not the default, but it's a possibility.
In this case, we still need a user and its secret to be created.

It is just a suggestion though and if that feels like some complications we want to deal with later, I'm good with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we actually want to allow bundled Reapers with local storage?

Yes, why not? It's an efficient storage mechanism which doesn't require using Cassandra itself.

I agree with this, so that's sorted.

About the JMX, I still don't get why we worry about it here when the reconcileReaperSecrets does not mention JMX secrets at all.

I'm indeed leaning towards not accepting this suggestion and keeping the condition as it is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok then 👍

controllers/reaper/reaper_controller.go Outdated Show resolved Hide resolved
controllers/reaper/reaper_controller.go Outdated Show resolved Hide resolved
@rzvoncek rzvoncek force-pushed the radovan/reaper-control-plane-3 branch 2 times, most recently from 1cf2b6a to 4281da3 Compare August 27, 2024 15:30
if err := secret.ReconcileSecret(ctx, r.Client, cassandraUserSecretRef.Name, kcKey); err != nil {
logger.Error(err, "Failed to reconcile Reaper CQL user secret", "ReaperCassandraUserSecretRef", cassandraUserSecretRef)
return result.Error(err)
if kc.Spec.Reaper != nil && kc.Spec.Reaper.ReaperRef.Name == "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adejanovski , I had to revert this back to the ReaperRef check.
If I checked only a storage type, then a bundled reaper that uses local storage was not working properly.

@rzvoncek rzvoncek force-pushed the radovan/reaper-control-plane-3 branch from 8b8f0e6 to 259339b Compare August 28, 2024 14:55
@rzvoncek rzvoncek force-pushed the radovan/reaper-control-plane-3 branch from 259339b to f7abe2f Compare August 30, 2024 05:48
Copy link

sonarcloud bot commented Aug 30, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@rzvoncek rzvoncek merged commit dd144c0 into main Aug 30, 2024
60 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Reaper deployment mode: Control Plane
3 participants