Skip to content

Commit

Permalink
Add bypass for validation for older backups, add printcolumns for pre…
Browse files Browse the repository at this point in the history
…ttier output of MedusaRestoreJob
  • Loading branch information
burmanm committed Sep 19, 2023
1 parent 4af1df4 commit 2e6e29b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apis/medusa/v1alpha1/medusarestorejob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type MedusaRestoreJobStatus struct {

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Started",type=date,JSONPath=".status.startTime",description="Restore start time"
//+kubebuilder:printcolumn:name="Finished",type=date,JSONPath=".status.finishTime",description="Restore finish time"
//+kubebuilder:printcolumn:name="Error",type=string,JSONPath=".status.message",description="Error message"

// MedusaRestoreJob is the Schema for the medusarestorejobs API
type MedusaRestoreJob struct {
Expand Down
15 changes: 14 additions & 1 deletion config/crd/bases/medusa.k8ssandra.io_medusarestorejobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ spec:
singular: medusarestorejob
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: Restore start time
jsonPath: .status.startTime
name: Started
type: date
- description: Restore finish time
jsonPath: .status.finishTime
name: Finished
type: date
- description: Error message
jsonPath: .status.message
name: Error
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: MedusaRestoreJob is the Schema for the medusarestorejobs API
Expand Down
5 changes: 5 additions & 0 deletions controllers/medusa/medusarestorejob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ func (r *MedusaRestoreJobReconciler) prepareRestore(ctx context.Context, request
}

func validateBackupForRestore(backup *medusav1alpha1.MedusaBackup, cassdc *cassdcapi.CassandraDatacenter) error {
if backup.Status.TotalNodes == 0 && backup.Status.FinishedNodes == 0 {
// This is an old backup without enough data, need to skip for backwards compatibility
return nil
}

Check warning on line 281 in controllers/medusa/medusarestorejob_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/medusa/medusarestorejob_controller.go#L279-L281

Added lines #L279 - L281 were not covered by tests

if backup.Status.FinishTime.IsZero() {
return fmt.Errorf("target backup has not finished")
}

Check warning on line 285 in controllers/medusa/medusarestorejob_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/medusa/medusarestorejob_controller.go#L284-L285

Added lines #L284 - L285 were not covered by tests
Expand Down

0 comments on commit 2e6e29b

Please sign in to comment.