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

Replicate medusa bucket secrets to each Cass DC #1202

Merged
merged 2 commits into from
Feb 20, 2024

Conversation

rzvoncek
Copy link
Contributor

@rzvoncek rzvoncek commented Feb 7, 2024

What this PR does:

This PR adds a bucket secret reconciliation process. If Medusa is configured globally (meaning the cluster's medusa config features a medusaConfigurationRef, then this process will make sure the bucket key secrets are properly replicated into the namespaces (and clusters) of each of the DCs. It will also alter the k8ssandra cluster to use the copied secret, instead of the original one.

This PR does not implement the actual replication, it only makes a copy of the secret and places labels on it. We make a copy so that we can clean up after ourselves (the original secret is user-created and we should not touch it). The labels are then picked up by the secret reconciliation process which actually copies them over.

Which issue(s) this PR fixes:
Fixes #1159.

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 force-pushed the radovan/replicate-bucket-key-secrets branch 2 times, most recently from 489af31 to 1175b69 Compare February 8, 2024 09:34
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (ad43fce) 57.32% compared to head (604c696) 57.28%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1202      +/-   ##
==========================================
- Coverage   57.32%   57.28%   -0.04%     
==========================================
  Files         103      103              
  Lines       10715    10759      +44     
==========================================
+ Hits         6142     6163      +21     
- Misses       4037     4054      +17     
- Partials      536      542       +6     
Files Coverage Δ
controllers/k8ssandra/medusa_reconciler.go 63.94% <65.95%> (+1.74%) ⬆️

... and 3 files with indirect coverage changes

@rzvoncek rzvoncek marked this pull request as ready for review February 8, 2024 10:23
@rzvoncek rzvoncek requested a review from a team as a code owner February 8, 2024 10:23
@@ -229,7 +235,7 @@ func mergeStorageProperties(
configKey := types.NamespacedName{Namespace: namespace, Name: medusaSpec.MedusaConfigurationRef.Name}
if err := remoteClient.Get(ctx, configKey, storageProperties); err != nil {
logger.Error(err, fmt.Sprintf("failed to get MedusaConfiguration %s", configKey))
return result.Error(err)
return result.RequeueSoon(r.DefaultDelay)
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Why the change? The only difference I can see is the change of delay when reconcile happens (error will do a reconcile also - but with a backoff timer to prevent flooding the server which this doesn't).

Copy link
Contributor

Choose a reason for hiding this comment

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

issue: This error handling is still incorrect, in case of error, err should be returned for proper requeue process (especially in this case when it can be Kubernetes API server overload or similar and we don't want to make it worse)

@burmanm
Copy link
Contributor

burmanm commented Feb 12, 2024

issue: I see no changes in the envtests, would you be able to add those as well? That provides so much faster response to changes so it helps other developers more than the e2e tests (which realistically, no one is running on their machine and wait until GHA throws something and they're not as easily debuggable).

@rzvoncek rzvoncek force-pushed the radovan/replicate-bucket-key-secrets branch 5 times, most recently from 690dfc1 to 5f7fc60 Compare February 16, 2024 14:24
@rzvoncek
Copy link
Contributor Author

Addressed the issue. Added env tests and updated e2e tests.
While doing this, also changed when we actually do the bucket secret reconciliation. Now it's not happening for each DC, but only once, at the place where we deal with all Medusa-related secrets.

@rzvoncek rzvoncek force-pushed the radovan/replicate-bucket-key-secrets branch 2 times, most recently from b8562e8 to 0c5dab5 Compare February 19, 2024 13:52
@rzvoncek rzvoncek force-pushed the radovan/replicate-bucket-key-secrets branch from 0c5dab5 to 604c696 Compare February 19, 2024 16:14
@rzvoncek
Copy link
Contributor Author

Did another round of improvements. The return error vs. requeue was indeed a problem. All green now (aside from codecov).

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.

Brilliant!
Everything worked perfectly in my tests, with both namespace and cluster scope.

I put a suggestion change for some wording in the docs.

Co-authored-by: Alexander Dejanovski <alex.dejanovski@datastax.com>
@rzvoncek rzvoncek merged commit 571e3b2 into main Feb 20, 2024
9 checks passed
Copy link

Quality Gate Passed Quality Gate passed

Issues
1 New issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

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.

Replicate bucket key secrets to namespaces hosting clusters that reference the MedusaConfiguration
3 participants