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 medusa validation #1054

Merged
merged 3 commits into from
Sep 19, 2023
Merged

Conversation

burmanm
Copy link
Contributor

@burmanm burmanm commented Sep 18, 2023

What this PR does:
Adds validation to MedusaRestoreJob controller that verifies the targetted MedusaBackup can be used to safely restore the target CassandraDatacenter

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

Checklist

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

@burmanm burmanm requested a review from a team as a code owner September 18, 2023 14:46
@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Merging #1054 (2e6e29b) into main (580f2d2) will increase coverage by 0.09%.
Report is 1 commits behind head on main.
The diff coverage is 60.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1054      +/-   ##
==========================================
+ Coverage   57.27%   57.37%   +0.09%     
==========================================
  Files         100      100              
  Lines       10109    10160      +51     
==========================================
+ Hits         5790     5829      +39     
- Misses       3815     3823       +8     
- Partials      504      508       +4     
Files Changed Coverage Δ
apis/medusa/v1alpha1/medusarestorejob_types.go 100.00% <ø> (ø)
controllers/medusa/medusarestorejob_controller.go 57.33% <60.78%> (+0.72%) ⬆️

... and 3 files with indirect coverage changes

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.

Awesome stuff, I would just like one tiny change to avoid breaking restores of backups created before we modified the MedusaBackup CRD.

@@ -54,6 +54,9 @@ type MedusaRestoreJobStatus struct {
Finished []string `json:"finished,omitempty"`

Failed []string `json:"failed,omitempty"`

// Message gives the reason why restore operation failed
Message string `json:"message,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: putting StartTime, FinishTime and Message as printcolumns would be a nice addition. Can do that in a subsequent ticket.

return fmt.Errorf("target backup has not completed successfully")
}

if backup.Status.TotalNodes != cassdc.Spec.Size {
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 would break for all backups that were created prior to the new fields being added in the MedusaBackup CRD, right?
Maybe we should detect that and skip validation in this case?
I guess that if backup.Status.TotalNodes = backup.Status.FinishedNodes == 0 then we can skip the validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, backwards compatibility. Will do.

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
5.8% 5.8% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

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.

Looks good now 👍

@adejanovski adejanovski merged commit 2588923 into k8ssandra:main Sep 19, 2023
59 of 60 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.

Verify a backup before trying to restore it
2 participants